From 7195d20fae8dbfb1d165e3cdb0d4dbca4cc3d3d7 Mon Sep 17 00:00:00 2001 From: Luke <32024335+lukeeey@users.noreply.github.com> Date: Tue, 5 May 2020 16:51:43 +0100 Subject: [PATCH] Implement helper methods for sending packets (#487) * Implement helper methods for sending packets, fixes an NPE when chatting before connecting to the remote server * Change method names * Add a space between doc comment lines * Add debug messages --- .../command/defaults/OffhandCommand.java | 2 +- .../org/geysermc/connector/entity/Entity.java | 16 +++---- .../geysermc/connector/entity/ItemEntity.java | 2 +- .../connector/entity/ItemFrameEntity.java | 6 +-- .../connector/entity/LivingEntity.java | 6 +-- .../connector/entity/PaintingEntity.java | 2 +- .../connector/entity/PlayerEntity.java | 10 ++-- .../living/animal/horse/LlamaEntity.java | 2 +- .../living/monster/EnderDragonEntity.java | 4 +- .../network/UpstreamPacketHandler.java | 6 +-- .../network/session/GeyserSession.java | 46 ++++++++++++++++++- .../network/session/cache/BossBar.java | 12 ++--- .../network/session/cache/WindowCache.java | 4 +- .../bedrock/BedrockActionTranslator.java | 26 +++++------ .../bedrock/BedrockAnimateTranslator.java | 2 +- .../BedrockBlockEntityDataTranslator.java | 2 +- .../BedrockCommandRequestTranslator.java | 2 +- .../BedrockContainerCloseTranslator.java | 2 +- .../bedrock/BedrockEntityEventTranslator.java | 2 +- .../bedrock/BedrockInteractTranslator.java | 4 +- ...BedrockInventoryTransactionTranslator.java | 22 ++++----- .../BedrockItemFrameDropItemTranslator.java | 2 +- .../BedrockLevelSoundEventTranslator.java | 2 +- .../BedrockMobEquipmentTranslator.java | 2 +- .../bedrock/BedrockMovePlayerTranslator.java | 8 ++-- .../bedrock/BedrockRespawnTranslator.java | 4 +- .../bedrock/BedrockShowCreditsTranslator.java | 2 +- .../bedrock/BedrockTextTranslator.java | 2 +- .../inventory/AnvilInventoryTranslator.java | 4 +- .../inventory/BrewingInventoryTranslator.java | 4 +- .../CraftingInventoryTranslator.java | 2 +- .../DoubleChestInventoryTranslator.java | 14 +++--- .../inventory/FurnaceInventoryTranslator.java | 2 +- .../inventory/PlayerInventoryTranslator.java | 17 ++++--- .../inventory/action/ClickPlan.java | 4 +- .../action/InventoryActionDataTranslator.java | 12 ++--- .../holder/BlockInventoryHolder.java | 8 ++-- .../updater/ChestInventoryUpdater.java | 4 +- .../updater/ContainerInventoryUpdater.java | 4 +- .../updater/CursorInventoryUpdater.java | 4 +- .../inventory/updater/InventoryUpdater.java | 4 +- .../translators/java/JavaChatTranslator.java | 2 +- .../java/JavaDeclareRecipesTranslator.java | 2 +- .../java/JavaDifficultyTranslator.java | 2 +- .../java/JavaJoinGameTranslator.java | 10 ++-- .../JavaLoginPluginMessageTranslator.java | 2 +- .../java/JavaPluginMessageTranslator.java | 2 +- .../java/JavaRespawnTranslator.java | 4 +- .../JavaServerDeclareCommandsTranslator.java | 2 +- .../translators/java/JavaTitleTranslator.java | 2 +- .../entity/JavaEntityAnimationTranslator.java | 2 +- .../entity/JavaEntityEffectTranslator.java | 2 +- .../entity/JavaEntityHeadLookTranslator.java | 4 +- .../JavaEntityRemoveEffectTranslator.java | 2 +- .../entity/JavaEntityRotationTranslator.java | 4 +- .../entity/JavaEntityStatusTranslator.java | 2 +- .../entity/JavaEntityVelocityTranslator.java | 2 +- .../player/JavaPlayerAbilitiesTranslator.java | 4 +- .../player/JavaPlayerActionAckTranslator.java | 6 +-- .../JavaPlayerChangeHeldItemTranslator.java | 2 +- .../player/JavaPlayerHealthTranslator.java | 2 +- .../player/JavaPlayerListEntryTranslator.java | 2 +- .../JavaPlayerPositionRotationTranslator.java | 12 ++--- .../player/JavaPlayerStopSoundTranslator.java | 2 +- .../window/JavaCloseWindowTranslator.java | 2 +- .../JavaConfirmTransactionTranslator.java | 5 +- .../java/window/JavaOpenWindowTranslator.java | 4 +- .../java/world/JavaBlockChangeTranslator.java | 2 +- .../java/world/JavaBlockValueTranslator.java | 14 +++--- .../java/world/JavaChunkDataTranslator.java | 2 +- .../java/world/JavaCollectItemTranslator.java | 2 +- .../java/world/JavaExplosionTranslator.java | 5 +- .../world/JavaNotifyClientTranslator.java | 14 +++--- .../world/JavaPlayBuiltinSoundTranslator.java | 4 +- .../java/world/JavaPlayEffectTranslator.java | 12 ++--- .../world/JavaPlayerPlaySoundTranslator.java | 2 +- .../world/JavaSpawnParticleTranslator.java | 12 ++--- .../world/JavaSpawnPositionTranslator.java | 2 +- .../java/world/JavaUpdateTimeTranslator.java | 4 +- .../block/BucketSoundInteractionHandler.java | 2 +- .../block/ComparatorSoundInteractHandler.java | 2 +- .../block/DoorSoundInteractionHandler.java | 2 +- .../FlintAndSteelInteractionHandler.java | 2 +- .../block/GrassPathInteractionHandler.java | 2 +- .../sound/block/HoeInteractionHandler.java | 2 +- .../block/LeverSoundInteractionHandler.java | 2 +- .../MilkCowSoundInteractionHandler.java | 2 +- .../FlowerPotBlockEntityTranslator.java | 2 +- .../NoteblockBlockEntityTranslator.java | 2 +- .../connector/scoreboard/Scoreboard.java | 12 ++--- .../connector/utils/BlockEntityUtils.java | 2 +- .../geysermc/connector/utils/ChunkUtils.java | 10 ++-- .../connector/utils/DimensionUtils.java | 4 +- .../connector/utils/InventoryUtils.java | 2 +- .../connector/utils/LoginEncryptionUtils.java | 4 +- .../geysermc/connector/utils/SkinUtils.java | 4 +- 96 files changed, 270 insertions(+), 235 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java b/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java index d181d07e..5392baed 100644 --- a/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java +++ b/connector/src/main/java/org/geysermc/connector/command/defaults/OffhandCommand.java @@ -55,7 +55,7 @@ public class OffhandCommand extends GeyserCommand { GeyserSession session = (GeyserSession) sender; ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.SWAP_HANDS, new Position(0,0,0), BlockFace.DOWN); - session.getDownstream().getSession().send(releaseItemPacket); + session.sendDownstreamPacket(releaseItemPacket); } } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/Entity.java b/connector/src/main/java/org/geysermc/connector/entity/Entity.java index 7e8a190d..186c0ae8 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/Entity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/Entity.java @@ -119,7 +119,7 @@ public class Entity { addEntityPacket.getMetadata().putAll(metadata); valid = true; - session.getUpstream().sendPacket(addEntityPacket); + session.sendUpstreamPacket(addEntityPacket); session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); } @@ -135,7 +135,7 @@ public class Entity { RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket(); removeEntityPacket.setUniqueEntityId(geyserId); - session.getUpstream().sendPacket(removeEntityPacket); + session.sendUpstreamPacket(removeEntityPacket); valid = false; return true; @@ -156,7 +156,7 @@ public class Entity { moveEntityPacket.setOnGround(isOnGround); moveEntityPacket.setTeleported(false); - session.getUpstream().sendPacket(moveEntityPacket); + session.sendUpstreamPacket(moveEntityPacket); } public void moveAbsolute(GeyserSession session, Vector3f position, float yaw, float pitch, boolean isOnGround, boolean teleported) { @@ -174,7 +174,7 @@ public class Entity { moveEntityPacket.setOnGround(isOnGround); moveEntityPacket.setTeleported(teleported); - session.getUpstream().sendPacket(moveEntityPacket); + session.sendUpstreamPacket(moveEntityPacket); } public void updateBedrockAttributes(GeyserSession session) { @@ -191,7 +191,7 @@ public class Entity { UpdateAttributesPacket updateAttributesPacket = new UpdateAttributesPacket(); updateAttributesPacket.setRuntimeEntityId(geyserId); updateAttributesPacket.setAttributes(attributes); - session.getUpstream().sendPacket(updateAttributesPacket); + session.sendUpstreamPacket(updateAttributesPacket); } public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) { @@ -218,13 +218,13 @@ public class Entity { else { useItemPacket = new ClientPlayerUseItemPacket(Hand.OFF_HAND); } - session.getDownstream().getSession().send(useItemPacket); + session.sendDownstreamPacket(useItemPacket); } } else if (session.getPlayerEntity().getEntityId() == entityId && !metadata.getFlags().getFlag(EntityFlag.SNEAKING) && metadata.getFlags().getFlag(EntityFlag.BLOCKING)) { metadata.getFlags().setFlag(EntityFlag.BLOCKING, false); metadata.getFlags().setFlag(EntityFlag.DISABLE_BLOCKING, true); ClientPlayerActionPacket releaseItemPacket = new ClientPlayerActionPacket(PlayerAction.RELEASE_USE_ITEM, new Position(0,0,0), BlockFace.DOWN); - session.getDownstream().getSession().send(releaseItemPacket); + session.sendDownstreamPacket(releaseItemPacket); } // metadata.getFlags().setFlag(EntityFlag.INVISIBLE, (xd & 0x20) == 0x20); if ((xd & 0x20) == 0x20) @@ -265,7 +265,7 @@ public class Entity { SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); entityDataPacket.setRuntimeEntityId(geyserId); entityDataPacket.getMetadata().putAll(metadata); - session.getUpstream().sendPacket(entityDataPacket); + session.sendUpstreamPacket(entityDataPacket); } /** diff --git a/connector/src/main/java/org/geysermc/connector/entity/ItemEntity.java b/connector/src/main/java/org/geysermc/connector/entity/ItemEntity.java index a28b563b..b321213e 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/ItemEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/ItemEntity.java @@ -50,7 +50,7 @@ public class ItemEntity extends Entity { itemPacket.setFromFishing(false); itemPacket.getMetadata().putAll(metadata); itemPacket.setItemInHand(Translators.getItemTranslator().translateToBedrock(session, (ItemStack) entityMetadata.getValue())); - session.getUpstream().sendPacket(itemPacket); + session.sendUpstreamPacket(itemPacket); } super.updateBedrockMetadata(entityMetadata, session); diff --git a/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java b/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java index d49f6e17..16942898 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/ItemFrameEntity.java @@ -149,7 +149,7 @@ public class ItemFrameEntity extends Entity { updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); - session.getUpstream().sendPacket(updateBlockPacket); + session.sendUpstreamPacket(updateBlockPacket); session.getItemFrameCache().remove(position, entityId); valid = false; return true; @@ -179,7 +179,7 @@ public class ItemFrameEntity extends Entity { updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); - session.getUpstream().sendPacket(updateBlockPacket); + session.sendUpstreamPacket(updateBlockPacket); BlockEntityDataPacket blockEntityDataPacket = new BlockEntityDataPacket(); blockEntityDataPacket.setBlockPosition(bedrockPosition); @@ -189,7 +189,7 @@ public class ItemFrameEntity extends Entity { blockEntityDataPacket.setData(getDefaultTag()); } - session.getUpstream().sendPacket(blockEntityDataPacket); + session.sendUpstreamPacket(blockEntityDataPacket); }, 500, TimeUnit.MILLISECONDS); } diff --git a/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java b/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java index 40b30f70..f5aa4a54 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/LivingEntity.java @@ -96,8 +96,8 @@ public class LivingEntity extends Entity { offHandPacket.setInventorySlot(0); offHandPacket.setContainerId(ContainerId.OFFHAND); - session.getUpstream().sendPacket(armorEquipmentPacket); - session.getUpstream().sendPacket(handPacket); - session.getUpstream().sendPacket(offHandPacket); + session.sendUpstreamPacket(armorEquipmentPacket); + session.sendUpstreamPacket(handPacket); + session.sendUpstreamPacket(offHandPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java b/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java index 87ff9a35..56e07733 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/PaintingEntity.java @@ -55,7 +55,7 @@ public class PaintingEntity extends Entity { addPaintingPacket.setName(paintingName.getBedrockName()); addPaintingPacket.setPosition(fixOffset(true)); addPaintingPacket.setDirection(direction); - session.getUpstream().sendPacket(addPaintingPacket); + session.sendUpstreamPacket(addPaintingPacket); valid = true; diff --git a/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java b/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java index d4732168..82e91f55 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/PlayerEntity.java @@ -94,7 +94,7 @@ public class PlayerEntity extends LivingEntity { addPlayerPacket.getMetadata().putAll(metadata); valid = true; - session.getUpstream().sendPacket(addPlayerPacket); + session.sendUpstreamPacket(addPlayerPacket); updateEquipment(session); updateBedrockAttributes(session); @@ -108,7 +108,7 @@ public class PlayerEntity extends LivingEntity { PlayerListPacket playerList = new PlayerListPacket(); playerList.setAction(PlayerListPacket.Action.ADD); playerList.getEntries().add(SkinUtils.buildDefaultEntry(profile, geyserId)); - session.getUpstream().sendPacket(playerList); + session.sendUpstreamPacket(playerList); } } @@ -124,7 +124,7 @@ public class PlayerEntity extends LivingEntity { PlayerListPacket playerList = new PlayerListPacket(); playerList.setAction(PlayerListPacket.Action.REMOVE); playerList.getEntries().add(new PlayerListPacket.Entry(uuid)); - session.getUpstream().sendPacket(playerList); + session.sendUpstreamPacket(playerList); }); } } @@ -145,7 +145,7 @@ public class PlayerEntity extends LivingEntity { movePlayerPacket.setTeleportationCause(MovePlayerPacket.TeleportationCause.UNKNOWN); } - session.getUpstream().sendPacket(movePlayerPacket); + session.sendUpstreamPacket(movePlayerPacket); } @Override @@ -159,7 +159,7 @@ public class PlayerEntity extends LivingEntity { movePlayerPacket.setRotation(getBedrockRotation()); movePlayerPacket.setOnGround(isOnGround); movePlayerPacket.setMode(MovePlayerPacket.Mode.NORMAL); - session.getUpstream().sendPacket(movePlayerPacket); + session.sendUpstreamPacket(movePlayerPacket); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java index c2dad7a5..d4d7b726 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/animal/horse/LlamaEntity.java @@ -65,7 +65,7 @@ public class LlamaEntity extends ChestedHorseEntity { equipmentPacket.setHelmet(ItemData.AIR); equipmentPacket.setLeggings(ItemData.AIR); - session.getUpstream().sendPacket(equipmentPacket); + session.sendUpstreamPacket(equipmentPacket); } // Color of the llama if (entityMetadata.getId() == 21) { diff --git a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java index b0737738..394be544 100644 --- a/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java +++ b/connector/src/main/java/org/geysermc/connector/entity/living/monster/EnderDragonEntity.java @@ -53,7 +53,7 @@ public class EnderDragonEntity extends InsentientEntity { entityEventPacket.setType(EntityEventType.DRAGON_FLAMING); entityEventPacket.setRuntimeEntityId(geyserId); entityEventPacket.setData(0); - session.getUpstream().sendPacket(entityEventPacket); + session.sendUpstreamPacket(entityEventPacket); case 6: case 7: metadata.getFlags().setFlag(EntityFlag.SITTING, true); @@ -79,7 +79,7 @@ public class EnderDragonEntity extends InsentientEntity { addEntityPacket.getAttributes().add(new Attribute("minecraft:health", 0.0f, 200f, 200f, 200f)); valid = true; - session.getUpstream().sendPacket(addEntityPacket); + session.sendUpstreamPacket(addEntityPacket); session.getConnector().getLogger().debug("Spawned entity " + entityType + " at location " + position + " with id " + geyserId + " (java id " + entityId + ")"); } diff --git a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java index 2839237e..dfc3112b 100644 --- a/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/UpstreamPacketHandler.java @@ -58,10 +58,10 @@ public class UpstreamPacketHandler extends LoggingPacketHandler { PlayStatusPacket playStatus = new PlayStatusPacket(); playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS); - session.getUpstream().sendPacket(playStatus); + session.sendUpstreamPacket(playStatus); ResourcePacksInfoPacket resourcePacksInfo = new ResourcePacksInfoPacket(); - session.getUpstream().sendPacket(resourcePacksInfo); + session.sendUpstreamPacket(resourcePacksInfo); return true; } @@ -77,7 +77,7 @@ public class UpstreamPacketHandler extends LoggingPacketHandler { stack.setExperimental(false); stack.setForcedToAccept(false); stack.setGameVersion("*"); - session.getUpstream().sendPacket(stack); + session.sendUpstreamPacket(stack); break; default: session.disconnect("disconnectionScreen.resourcePack"); diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index 51cc0923..9068456c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -29,6 +29,7 @@ import com.github.steveice10.mc.auth.data.GameProfile; import com.github.steveice10.mc.auth.exception.request.InvalidCredentialsException; import com.github.steveice10.mc.auth.exception.request.RequestException; import com.github.steveice10.mc.protocol.MinecraftProtocol; +import com.github.steveice10.mc.protocol.data.SubProtocol; import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode; import com.github.steveice10.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket; import com.github.steveice10.mc.protocol.data.game.world.block.BlockState; @@ -41,6 +42,7 @@ import com.github.steveice10.packetlib.tcp.TcpSessionFactory; import com.nukkitx.math.GenericMath; import com.nukkitx.math.TrigMath; import com.nukkitx.math.vector.*; +import com.nukkitx.protocol.bedrock.BedrockPacket; import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.data.ContainerId; import com.nukkitx.protocol.bedrock.data.GamePublishSetting; @@ -156,6 +158,8 @@ public class GeyserSession implements CommandSender { @Setter private int craftSlot = 0; + private MinecraftProtocol protocol; + public GeyserSession(GeyserConnector connector, BedrockServerSession bedrockServerSession) { this.connector = connector; this.upstream = new UpstreamSession(bedrockServerSession); @@ -227,7 +231,6 @@ public class GeyserSession implements CommandSender { // new thread so clients don't timeout new Thread(() -> { try { - MinecraftProtocol protocol; if (password != null && !password.isEmpty()) { protocol = new MinecraftProtocol(username, password); } else { @@ -481,8 +484,47 @@ public class GeyserSession implements CommandSender { int teleportId = teleportCache.getTeleportConfirmId(); teleportCache = null; ClientTeleportConfirmPacket teleportConfirmPacket = new ClientTeleportConfirmPacket(teleportId); - getDownstream().getSession().send(teleportConfirmPacket); + sendDownstreamPacket(teleportConfirmPacket); } return true; } + + /** + * Queue a packet to be sent to player. + * + * @param packet the bedrock packet from the NukkitX protocol lib + */ + public void sendUpstreamPacket(BedrockPacket packet) { + if (upstream != null && !upstream.isClosed()) { + upstream.sendPacket(packet); + } else { + connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " but the session was null"); + } + } + + /** + * Send a packet immediately to the player. + * + * @param packet the bedrock packet from the NukkitX protocol lib + */ + public void sendUpstreamPacketImmediately(BedrockPacket packet) { + if (upstream != null && !upstream.isClosed()) { + upstream.sendPacketImmediately(packet); + } else { + connector.getLogger().debug("Tried to send upstream packet " + packet.getClass().getSimpleName() + " immediately but the session was null"); + } + } + + /** + * Send a packet to the remote server. + * + * @param packet the java edition packet from MCProtocolLib + */ + public void sendDownstreamPacket(Packet packet) { + if (downstream != null && downstream.getSession() != null && protocol.getSubProtocol().equals(SubProtocol.GAME)) { + downstream.getSession().send(packet); + } else { + connector.getLogger().debug("Tried to send downstream packet " + packet.getClass().getSimpleName() + " before connected to the server"); + } + } } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/BossBar.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/BossBar.java index abb9016a..1fde179d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/BossBar.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/BossBar.java @@ -62,7 +62,7 @@ public class BossBar { bossEventPacket.setOverlay(overlay); bossEventPacket.setDarkenSky(darkenSky); - session.getUpstream().sendPacket(bossEventPacket); + session.sendUpstreamPacket(bossEventPacket); } public void updateTitle(Message title) { @@ -72,7 +72,7 @@ public class BossBar { bossEventPacket.setAction(BossEventPacket.Action.TITLE); bossEventPacket.setTitle(MessageUtils.getTranslatedBedrockMessage(title, session.getClientData().getLanguageCode())); - session.getUpstream().sendPacket(bossEventPacket); + session.sendUpstreamPacket(bossEventPacket); } public void updateHealth(float health) { @@ -82,7 +82,7 @@ public class BossBar { bossEventPacket.setAction(BossEventPacket.Action.HEALTH_PERCENTAGE); bossEventPacket.setHealthPercentage(health); - session.getUpstream().sendPacket(bossEventPacket); + session.sendUpstreamPacket(bossEventPacket); } public void removeBossBar() { @@ -90,7 +90,7 @@ public class BossBar { bossEventPacket.setBossUniqueEntityId(entityId); bossEventPacket.setAction(BossEventPacket.Action.HIDE); - session.getUpstream().sendPacket(bossEventPacket); + session.sendUpstreamPacket(bossEventPacket); removeBossEntity(); } @@ -109,13 +109,13 @@ public class BossBar { addEntityPacket.setMotion(Vector3f.ZERO); addEntityPacket.getMetadata().put(EntityData.SCALE, 0.01F); // scale = 0 doesn't work? - session.getUpstream().sendPacket(addEntityPacket); + session.sendUpstreamPacket(addEntityPacket); } private void removeBossEntity() { RemoveEntityPacket removeEntityPacket = new RemoveEntityPacket(); removeEntityPacket.setUniqueEntityId(entityId); - session.getUpstream().sendPacket(removeEntityPacket); + session.sendUpstreamPacket(removeEntityPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/cache/WindowCache.java b/connector/src/main/java/org/geysermc/connector/network/session/cache/WindowCache.java index 1d10e4db..15b9a770 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/cache/WindowCache.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/cache/WindowCache.java @@ -66,7 +66,7 @@ public class WindowCache { formRequestPacket.setFormId(id); formRequestPacket.setFormData(windows.get(id).getJSONData()); - session.getUpstream().sendPacket(formRequestPacket); + session.sendUpstreamPacket(formRequestPacket); } public void showWindow(FormWindow window, int id) { @@ -74,7 +74,7 @@ public class WindowCache { formRequestPacket.setFormId(id); formRequestPacket.setFormData(window.getJSONData()); - session.getUpstream().sendPacket(formRequestPacket); + session.sendUpstreamPacket(formRequestPacket); addWindow(window, id); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java index d7248aa3..2c44e4fd 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockActionTranslator.java @@ -64,44 +64,44 @@ public class BedrockActionTranslator extends PacketTranslator { case SWING_ARM: // Delay so entity damage can be processed first session.getConnector().getGeneralThreadPool().schedule(() -> - session.getDownstream().getSession().send(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)), + session.sendDownstreamPacket(new ClientPlayerSwingArmPacket(Hand.MAIN_HAND)), 25, TimeUnit.MILLISECONDS ); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockBlockEntityDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockBlockEntityDataTranslator.java index dc076a91..9fe62bb4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockBlockEntityDataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockBlockEntityDataTranslator.java @@ -79,7 +79,7 @@ public class BedrockBlockEntityDataTranslator extends PacketTranslator } ClientPlayerInteractEntityPacket interactPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(), InteractAction.INTERACT, Hand.MAIN_HAND); - session.getDownstream().getSession().send(interactPacket); + session.sendDownstreamPacket(interactPacket); break; case DAMAGE: ClientPlayerInteractEntityPacket attackPacket = new ClientPlayerInteractEntityPacket((int) entity.getEntityId(), InteractAction.ATTACK, Hand.MAIN_HAND); - session.getDownstream().getSession().send(attackPacket); + session.sendDownstreamPacket(attackPacket); break; } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java index ed928959..71ba20e4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockInventoryTransactionTranslator.java @@ -84,8 +84,8 @@ public class BedrockInventoryTransactionTranslator extends PacketTranslator { respawnPacket.setRuntimeEntityId(0); respawnPacket.setPosition(Vector3f.ZERO); respawnPacket.setState(RespawnPacket.State.SERVER_SEARCHING); - session.getUpstream().sendPacket(respawnPacket); + session.sendUpstreamPacket(respawnPacket); ClientRequestPacket javaRespawnPacket = new ClientRequestPacket(ClientRequest.RESPAWN); - session.getDownstream().getSession().send(javaRespawnPacket); + session.sendDownstreamPacket(javaRespawnPacket); } } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockShowCreditsTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockShowCreditsTranslator.java index 161397b6..4f0af78c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockShowCreditsTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockShowCreditsTranslator.java @@ -40,7 +40,7 @@ public class BedrockShowCreditsTranslator extends PacketTranslator { } ClientChatPacket chatPacket = new ClientChatPacket(message); - session.getDownstream().getSession().send(chatPacket); + session.sendDownstreamPacket(chatPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java index 8df72d36..f301d2b5 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/AnvilInventoryTranslator.java @@ -108,7 +108,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { rename = ""; } ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename); - session.getDownstream().getSession().send(renameItemPacket); + session.sendDownstreamPacket(renameItemPacket); } if (anvilResult != null) { //client will send another packet to grab anvil output @@ -138,7 +138,7 @@ public class AnvilInventoryTranslator extends BlockInventoryTranslator { rename = ""; } ClientRenameItemPacket renameItemPacket = new ClientRenameItemPacket(rename); - session.getDownstream().getSession().send(renameItemPacket); + session.sendDownstreamPacket(renameItemPacket); } } super.updateSlot(session, inventory, slot); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingInventoryTranslator.java index bd143698..acda7c91 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/BrewingInventoryTranslator.java @@ -44,7 +44,7 @@ public class BrewingInventoryTranslator extends BlockInventoryTranslator { dataPacket.setWindowId((byte) inventory.getId()); dataPacket.setProperty(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL); dataPacket.setValue(20); - session.getUpstream().sendPacket(dataPacket); + session.sendUpstreamPacket(dataPacket); } @Override @@ -62,7 +62,7 @@ public class BrewingInventoryTranslator extends BlockInventoryTranslator { return; } dataPacket.setValue(value); - session.getUpstream().sendPacket(dataPacket); + session.sendUpstreamPacket(dataPacket); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/CraftingInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/CraftingInventoryTranslator.java index 92a1d90e..3f887001 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/CraftingInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/CraftingInventoryTranslator.java @@ -59,7 +59,7 @@ public class CraftingInventoryTranslator extends BaseInventoryTranslator { containerOpenPacket.setType((byte) ContainerType.WORKBENCH.id()); containerOpenPacket.setBlockPosition(inventory.getHolderPosition()); containerOpenPacket.setUniqueEntityId(inventory.getHolderId()); - session.getUpstream().sendPacket(containerOpenPacket); + session.sendUpstreamPacket(containerOpenPacket); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java index 720280b4..8c5b2cf2 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/DoubleChestInventoryTranslator.java @@ -60,7 +60,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator { blockPacket.setBlockPosition(position); blockPacket.setRuntimeId(blockId); blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY); - session.getUpstream().sendPacket(blockPacket); + session.sendUpstreamPacket(blockPacket); CompoundTag tag = CompoundTag.builder() .stringTag("id", "Chest") @@ -73,14 +73,14 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator { BlockEntityDataPacket dataPacket = new BlockEntityDataPacket(); dataPacket.setData(tag); dataPacket.setBlockPosition(position); - session.getUpstream().sendPacket(dataPacket); + session.sendUpstreamPacket(dataPacket); blockPacket = new UpdateBlockPacket(); blockPacket.setDataLayer(0); blockPacket.setBlockPosition(pairPosition); blockPacket.setRuntimeId(blockId); blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY); - session.getUpstream().sendPacket(blockPacket); + session.sendUpstreamPacket(blockPacket); tag = CompoundTag.builder() .stringTag("id", "Chest") @@ -93,7 +93,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator { dataPacket = new BlockEntityDataPacket(); dataPacket.setData(tag); dataPacket.setBlockPosition(pairPosition); - session.getUpstream().sendPacket(dataPacket); + session.sendUpstreamPacket(dataPacket); inventory.setHolderPosition(position); } @@ -105,7 +105,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator { containerOpenPacket.setType((byte) ContainerType.CONTAINER.id()); containerOpenPacket.setBlockPosition(inventory.getHolderPosition()); containerOpenPacket.setUniqueEntityId(inventory.getHolderId()); - session.getUpstream().sendPacket(containerOpenPacket); + session.sendUpstreamPacket(containerOpenPacket); } @Override @@ -117,7 +117,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator { blockPacket.setDataLayer(0); blockPacket.setBlockPosition(holderPos); blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock)); - session.getUpstream().sendPacket(blockPacket); + session.sendUpstreamPacket(blockPacket); holderPos = holderPos.add(Vector3i.UNIT_X); pos = new Position(holderPos.getX(), holderPos.getY(), holderPos.getZ()); @@ -126,7 +126,7 @@ public class DoubleChestInventoryTranslator extends BaseInventoryTranslator { blockPacket.setDataLayer(0); blockPacket.setBlockPosition(holderPos); blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock)); - session.getUpstream().sendPacket(blockPacket); + session.sendUpstreamPacket(blockPacket); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java index 9b45201e..5c6de0e8 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/FurnaceInventoryTranslator.java @@ -58,7 +58,7 @@ public class FurnaceInventoryTranslator extends BlockInventoryTranslator { return; } dataPacket.setValue(value); - session.getUpstream().sendPacket(dataPacket); + session.sendUpstreamPacket(dataPacket); } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java index 668612c5..b711bddc 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/PlayerInventoryTranslator.java @@ -34,7 +34,6 @@ import com.nukkitx.protocol.bedrock.data.InventorySource; import com.nukkitx.protocol.bedrock.data.ItemData; import com.nukkitx.protocol.bedrock.packet.InventoryContentPacket; import com.nukkitx.protocol.bedrock.packet.InventorySlotPacket; -import it.unimi.dsi.fastutil.longs.LongArraySet; import org.geysermc.connector.inventory.Inventory; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.Translators; @@ -66,7 +65,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator { contents[i - 36] = Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i)); } inventoryContentPacket.setContents(contents); - session.getUpstream().sendPacket(inventoryContentPacket); + session.sendUpstreamPacket(inventoryContentPacket); // Armor InventoryContentPacket armorContentPacket = new InventoryContentPacket(); @@ -76,13 +75,13 @@ public class PlayerInventoryTranslator extends InventoryTranslator { contents[i - 5] = Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i)); } armorContentPacket.setContents(contents); - session.getUpstream().sendPacket(armorContentPacket); + session.sendUpstreamPacket(armorContentPacket); // Offhand InventoryContentPacket offhandPacket = new InventoryContentPacket(); offhandPacket.setContainerId(ContainerId.OFFHAND); offhandPacket.setContents(new ItemData[]{Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(45))}); - session.getUpstream().sendPacket(offhandPacket); + session.sendUpstreamPacket(offhandPacket); } /** @@ -103,7 +102,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator { slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i))); } - session.getUpstream().sendPacket(slotPacket); + session.sendUpstreamPacket(slotPacket); } } @@ -126,12 +125,12 @@ public class PlayerInventoryTranslator extends InventoryTranslator { slotPacket.setSlot(slot + 27); } slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(slot))); - session.getUpstream().sendPacket(slotPacket); + session.sendUpstreamPacket(slotPacket); } else if (slot == 45) { InventoryContentPacket offhandPacket = new InventoryContentPacket(); offhandPacket.setContainerId(ContainerId.OFFHAND); offhandPacket.setContents(new ItemData[]{Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(slot))}); - session.getUpstream().sendPacket(offhandPacket); + session.sendUpstreamPacket(offhandPacket); } } @@ -204,7 +203,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator { javaItem = Translators.getItemTranslator().translateToJava(session, action.getToItem()); } ClientCreativeInventoryActionPacket creativePacket = new ClientCreativeInventoryActionPacket(javaSlot, javaItem); - session.getDownstream().getSession().send(creativePacket); + session.sendDownstreamPacket(creativePacket); inventory.setItem(javaSlot, javaItem); break; case ContainerId.CURSOR: @@ -217,7 +216,7 @@ public class PlayerInventoryTranslator extends InventoryTranslator { && action.getSource().getFlag() == InventorySource.Flag.DROP_ITEM) { javaItem = Translators.getItemTranslator().translateToJava(session, action.getToItem()); ClientCreativeInventoryActionPacket creativeDropPacket = new ClientCreativeInventoryActionPacket(-1, javaItem); - session.getDownstream().getSession().send(creativeDropPacket); + session.sendDownstreamPacket(creativeDropPacket); } break; } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/ClickPlan.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/ClickPlan.java index cdc42f96..a9c1eddc 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/ClickPlan.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/ClickPlan.java @@ -104,8 +104,8 @@ class ClickPlan { break; } } - session.getDownstream().getSession().send(clickPacket); - session.getDownstream().getSession().send(new ClientConfirmTransactionPacket(inventory.getId(), actionId, true)); + session.sendDownstreamPacket(clickPacket); + session.sendDownstreamPacket(new ClientConfirmTransactionPacket(inventory.getId(), actionId, true)); } /*if (refresh) { diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/InventoryActionDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/InventoryActionDataTranslator.java index 370d4177..0c267775 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/InventoryActionDataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/action/InventoryActionDataTranslator.java @@ -94,7 +94,7 @@ public class InventoryActionDataTranslator { ClientPlayerActionPacket actionPacket = new ClientPlayerActionPacket( sourceAction.getToItem().getCount() == 0 ? PlayerAction.DROP_ITEM_STACK : PlayerAction.DROP_ITEM, new Position(0, 0, 0), BlockFace.DOWN); - session.getDownstream().getSession().send(actionPacket); + session.sendDownstreamPacket(actionPacket); ItemStack item = session.getInventory().getItem(heldSlot); if (item != null) { session.getInventory().setItem(heldSlot, new ItemStack(item.getId(), item.getAmount() - 1, item.getNbt())); @@ -110,14 +110,14 @@ public class InventoryActionDataTranslator { inventory.getTransactionId().getAndIncrement(), javaSlot, null, WindowAction.DROP_ITEM, DropItemParam.DROP_SELECTED_STACK); - session.getDownstream().getSession().send(dropPacket); + session.sendDownstreamPacket(dropPacket); } else { for (int i = 0; i < dropAmount; i++) { ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(), inventory.getTransactionId().getAndIncrement(), javaSlot, null, WindowAction.DROP_ITEM, DropItemParam.DROP_FROM_SELECTED); - session.getDownstream().getSession().send(dropPacket); + session.sendDownstreamPacket(dropPacket); } } ItemStack item = session.getInventory().getItem(javaSlot); @@ -129,7 +129,7 @@ public class InventoryActionDataTranslator { ClientWindowActionPacket dropPacket = new ClientWindowActionPacket(inventory.getId(), inventory.getTransactionId().getAndIncrement(), -999, null, WindowAction.CLICK_ITEM, dropAmount > 1 ? ClickItemParam.LEFT_CLICK : ClickItemParam.RIGHT_CLICK); - session.getDownstream().getSession().send(dropPacket); + session.sendDownstreamPacket(dropPacket); ItemStack cursor = session.getInventory().getCursor(); if (cursor != null) { session.getInventory().setCursor(new ItemStack(cursor.getId(), dropAmount > 1 ? 0 : cursor.getAmount() - 1, cursor.getNbt())); @@ -180,7 +180,7 @@ public class InventoryActionDataTranslator { inventory.getTransactionId().getAndIncrement(), javaSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM, ShiftClickItemParam.LEFT_CLICK); - session.getDownstream().getSession().send(shiftClickPacket); + session.sendDownstreamPacket(shiftClickPacket); translator.updateInventory(session, inventory); return; } @@ -266,7 +266,7 @@ public class InventoryActionDataTranslator { inventory.getTransactionId().getAndIncrement(), fromSlot, InventoryUtils.REFRESH_ITEM, WindowAction.SHIFT_CLICK_ITEM, ShiftClickItemParam.LEFT_CLICK); - session.getDownstream().getSession().send(shiftClickPacket); + session.sendDownstreamPacket(shiftClickPacket); translator.updateInventory(session, inventory); return; } else if (translator.getSlotType(fromSlot) == SlotType.OUTPUT) { diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/holder/BlockInventoryHolder.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/holder/BlockInventoryHolder.java index a6e5b2dd..67ce2ce1 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/holder/BlockInventoryHolder.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/holder/BlockInventoryHolder.java @@ -54,7 +54,7 @@ public class BlockInventoryHolder extends InventoryHolder { blockPacket.setBlockPosition(position); blockPacket.setRuntimeId(blockId); blockPacket.getFlags().addAll(UpdateBlockPacket.FLAG_ALL_PRIORITY); - session.getUpstream().sendPacket(blockPacket); + session.sendUpstreamPacket(blockPacket); inventory.setHolderPosition(position); CompoundTag tag = CompoundTag.builder() @@ -65,7 +65,7 @@ public class BlockInventoryHolder extends InventoryHolder { BlockEntityDataPacket dataPacket = new BlockEntityDataPacket(); dataPacket.setData(tag); dataPacket.setBlockPosition(position); - session.getUpstream().sendPacket(dataPacket); + session.sendUpstreamPacket(dataPacket); } @Override @@ -75,7 +75,7 @@ public class BlockInventoryHolder extends InventoryHolder { containerOpenPacket.setType((byte) containerType.id()); containerOpenPacket.setBlockPosition(inventory.getHolderPosition()); containerOpenPacket.setUniqueEntityId(inventory.getHolderId()); - session.getUpstream().sendPacket(containerOpenPacket); + session.sendUpstreamPacket(containerOpenPacket); } @Override @@ -87,6 +87,6 @@ public class BlockInventoryHolder extends InventoryHolder { blockPacket.setDataLayer(0); blockPacket.setBlockPosition(holderPos); blockPacket.setRuntimeId(BlockTranslator.getBedrockBlockId(realBlock)); - session.getUpstream().sendPacket(blockPacket); + session.sendUpstreamPacket(blockPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ChestInventoryUpdater.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ChestInventoryUpdater.java index e8e0fc45..8318081d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ChestInventoryUpdater.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ChestInventoryUpdater.java @@ -54,7 +54,7 @@ public class ChestInventoryUpdater extends InventoryUpdater { InventoryContentPacket contentPacket = new InventoryContentPacket(); contentPacket.setContainerId(inventory.getId()); contentPacket.setContents(bedrockItems); - session.getUpstream().sendPacket(contentPacket); + session.sendUpstreamPacket(contentPacket); } @Override @@ -66,7 +66,7 @@ public class ChestInventoryUpdater extends InventoryUpdater { slotPacket.setContainerId(inventory.getId()); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); - session.getUpstream().sendPacket(slotPacket); + session.sendUpstreamPacket(slotPacket); return true; } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ContainerInventoryUpdater.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ContainerInventoryUpdater.java index d187ffd9..d25705e2 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ContainerInventoryUpdater.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/ContainerInventoryUpdater.java @@ -46,7 +46,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater { InventoryContentPacket contentPacket = new InventoryContentPacket(); contentPacket.setContainerId(inventory.getId()); contentPacket.setContents(bedrockItems); - session.getUpstream().sendPacket(contentPacket); + session.sendUpstreamPacket(contentPacket); } @Override @@ -58,7 +58,7 @@ public class ContainerInventoryUpdater extends InventoryUpdater { slotPacket.setContainerId(inventory.getId()); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); - session.getUpstream().sendPacket(slotPacket); + session.sendUpstreamPacket(slotPacket); return true; } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/CursorInventoryUpdater.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/CursorInventoryUpdater.java index e3dc1864..6a93ecd3 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/CursorInventoryUpdater.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/CursorInventoryUpdater.java @@ -45,7 +45,7 @@ public class CursorInventoryUpdater extends InventoryUpdater { slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setSlot(bedrockSlot); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(i))); - session.getUpstream().sendPacket(slotPacket); + session.sendUpstreamPacket(slotPacket); } } @@ -58,7 +58,7 @@ public class CursorInventoryUpdater extends InventoryUpdater { slotPacket.setContainerId(ContainerId.CURSOR); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); - session.getUpstream().sendPacket(slotPacket); + session.sendUpstreamPacket(slotPacket); return true; } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/InventoryUpdater.java b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/InventoryUpdater.java index 2f139e27..ebca038a 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/InventoryUpdater.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/inventory/updater/InventoryUpdater.java @@ -44,7 +44,7 @@ public abstract class InventoryUpdater { InventoryContentPacket contentPacket = new InventoryContentPacket(); contentPacket.setContainerId(ContainerId.INVENTORY); contentPacket.setContents(bedrockItems); - session.getUpstream().sendPacket(contentPacket); + session.sendUpstreamPacket(contentPacket); } public boolean updateSlot(InventoryTranslator translator, GeyserSession session, Inventory inventory, int javaSlot) { @@ -53,7 +53,7 @@ public abstract class InventoryUpdater { slotPacket.setContainerId(ContainerId.INVENTORY); slotPacket.setSlot(translator.javaSlotToBedrock(javaSlot)); slotPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, inventory.getItem(javaSlot))); - session.getUpstream().sendPacket(slotPacket); + session.sendUpstreamPacket(slotPacket); return true; } return false; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaChatTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaChatTranslator.java index a527866c..53ce6811 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaChatTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaChatTranslator.java @@ -76,6 +76,6 @@ public class JavaChatTranslator extends PacketTranslator { textPacket.setMessage(MessageUtils.getTranslatedBedrockMessage(packet.getMessage(), locale, false)); } - session.getUpstream().sendPacket(textPacket); + session.sendUpstreamPacket(textPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java index c78493a3..b6a25e54 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaDeclareRecipesTranslator.java @@ -90,7 +90,7 @@ public class JavaDeclareRecipesTranslator extends PacketTranslator skinParts = Arrays.asList(SkinPart.values()); ClientSettingsPacket clientSettingsPacket = new ClientSettingsPacket(locale, (byte) session.getRenderDistance(), ChatVisibility.FULL, true, skinParts, Hand.MAIN_HAND); - session.getDownstream().getSession().send(clientSettingsPacket); + session.sendDownstreamPacket(clientSettingsPacket); if (DimensionUtils.javaToBedrock(packet.getDimension()) != entity.getDimension()) { DimensionUtils.switchDimension(session, packet.getDimension()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaLoginPluginMessageTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaLoginPluginMessageTranslator.java index 1ce17fe9..f2a2bf02 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaLoginPluginMessageTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaLoginPluginMessageTranslator.java @@ -12,7 +12,7 @@ public class JavaLoginPluginMessageTranslator extends PacketTranslator SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket(); playerGameTypePacket.setGamemode(packet.getGamemode().ordinal()); - session.getUpstream().sendPacket(playerGameTypePacket); + session.sendUpstreamPacket(playerGameTypePacket); session.setGameMode(packet.getGamemode()); LevelEventPacket stopRainPacket = new LevelEventPacket(); stopRainPacket.setType(LevelEventType.STOP_RAIN); stopRainPacket.setData(ThreadLocalRandom.current().nextInt(50000) + 10000); stopRainPacket.setPosition(Vector3f.ZERO); - session.getUpstream().sendPacket(stopRainPacket); + session.sendUpstreamPacket(stopRainPacket); if (entity.getDimension() != DimensionUtils.javaToBedrock(packet.getDimension())) { DimensionUtils.switchDimension(session, packet.getDimension()); diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java index 0e329669..6f16f8b4 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaServerDeclareCommandsTranslator.java @@ -100,7 +100,7 @@ public class JavaServerDeclareCommandsTranslator extends PacketTranslator { break; } - session.getUpstream().sendPacket(titlePacket); + session.sendUpstreamPacket(titlePacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityAnimationTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityAnimationTranslator.java index 9d8853e7..4f2fe022 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityAnimationTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/JavaEntityAnimationTranslator.java @@ -62,6 +62,6 @@ public class JavaEntityAnimationTranslator extends PacketTranslator playerFlags = new ObjectOpenHashSet<>(); playerFlags.add(AdventureSettingsPacket.Flag.AUTO_JUMP); @@ -73,6 +73,6 @@ public class JavaPlayerAbilitiesTranslator extends PacketTranslator " + stopSoundPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/window/JavaCloseWindowTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/window/JavaCloseWindowTranslator.java index 8162b82a..7360cbb2 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/window/JavaCloseWindowTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/window/JavaCloseWindowTranslator.java @@ -39,7 +39,7 @@ public class JavaCloseWindowTranslator extends PacketTranslator { @@ -41,7 +38,7 @@ public class JavaConfirmTransactionTranslator extends PacketTranslator 0 ? 1 : 0); - session.getUpstream().sendPacket(blockEventPacket); + session.sendUpstreamPacket(blockEventPacket); } if (packet.getValue() instanceof EndGatewayValue) { blockEventPacket.setEventType(1); - session.getUpstream().sendPacket(blockEventPacket); + session.sendUpstreamPacket(blockEventPacket); } if (packet.getValue() instanceof NoteBlockValue) { NoteblockBlockEntityTranslator.translate(session, packet.getPosition()); @@ -77,15 +77,15 @@ public class JavaBlockValueTranslator extends PacketTranslator extendPiston(session, position, (progress >= 1.0f) ? 1.0f : progress + 0.5f, progress), @@ -121,7 +121,7 @@ public class JavaBlockValueTranslator extends PacketTranslator retractPiston(session, position, (progress <= 0.0f) ? 0.0f : progress - 0.5f, progress), diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java index 9e2d2ae7..2af7bb5b 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaChunkDataTranslator.java @@ -98,7 +98,7 @@ public class JavaChunkDataTranslator extends PacketTranslator blockEntityEntry : chunkData.getLoadBlockEntitiesLater().object2IntEntrySet()) { diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaCollectItemTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaCollectItemTranslator.java index b4287b08..31379bd2 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaCollectItemTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaCollectItemTranslator.java @@ -50,6 +50,6 @@ public class JavaCollectItemTranslator extends PacketTranslator playerFlags = new ObjectOpenHashSet<>(); @@ -89,14 +89,14 @@ public class JavaNotifyClientTranslator extends PacketTranslator " + soundPacket.toString()); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayEffectTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayEffectTranslator.java index e22db97e..8e76d7d8 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayEffectTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaPlayEffectTranslator.java @@ -90,12 +90,12 @@ public class JavaPlayEffectTranslator extends PacketTranslator " + playSoundPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaSpawnParticleTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaSpawnParticleTranslator.java index 1f9bcba3..d6da1c81 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaSpawnParticleTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/world/JavaSpawnParticleTranslator.java @@ -52,7 +52,7 @@ public class JavaSpawnParticleTranslator extends PacketTranslator("dodaylightcycle", doCycle)); - session.getUpstream().sendPacket(gameRulesChangedPacket); + session.sendUpstreamPacket(gameRulesChangedPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/BucketSoundInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/BucketSoundInteractionHandler.java index 00269cc7..031782c1 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/BucketSoundInteractionHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/BucketSoundInteractionHandler.java @@ -67,7 +67,7 @@ public class BucketSoundInteractionHandler implements BlockSoundInteractionHandl } if (soundEvent != null) { soundEventPacket.setSound(soundEvent); - session.getUpstream().sendPacket(soundEventPacket); + session.sendUpstreamPacket(soundEventPacket); } } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/ComparatorSoundInteractHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/ComparatorSoundInteractHandler.java index 260ad814..4b74a678 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/ComparatorSoundInteractHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/ComparatorSoundInteractHandler.java @@ -43,6 +43,6 @@ public class ComparatorSoundInteractHandler implements BlockSoundInteractionHand levelEventPacket.setPosition(position); levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER); levelEventPacket.setData(powered ? 500 : 550); - session.getUpstream().sendPacket(levelEventPacket); + session.sendUpstreamPacket(levelEventPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/DoorSoundInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/DoorSoundInteractionHandler.java index b8e2854d..39a07c3a 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/DoorSoundInteractionHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/DoorSoundInteractionHandler.java @@ -42,6 +42,6 @@ public class DoorSoundInteractionHandler implements BlockSoundInteractionHandler levelEventPacket.setType(LevelEventType.SOUND_DOOR); levelEventPacket.setPosition(position); levelEventPacket.setData(0); - session.getUpstream().sendPacket(levelEventPacket); + session.sendUpstreamPacket(levelEventPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/FlintAndSteelInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/FlintAndSteelInteractionHandler.java index b28133b3..290aa7bd 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/FlintAndSteelInteractionHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/FlintAndSteelInteractionHandler.java @@ -45,6 +45,6 @@ public class FlintAndSteelInteractionHandler implements BlockSoundInteractionHan levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setSound(SoundEvent.IGNITE); levelSoundEventPacket.setExtraData(-1); - session.getUpstream().sendPacket(levelSoundEventPacket); + session.sendUpstreamPacket(levelSoundEventPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/GrassPathInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/GrassPathInteractionHandler.java index e2957103..e5445e9d 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/GrassPathInteractionHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/GrassPathInteractionHandler.java @@ -46,6 +46,6 @@ public class GrassPathInteractionHandler implements BlockSoundInteractionHandler levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON); levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier))); - session.getUpstream().sendPacket(levelSoundEventPacket); + session.sendUpstreamPacket(levelSoundEventPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/HoeInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/HoeInteractionHandler.java index c9d4299b..17d346ae 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/HoeInteractionHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/HoeInteractionHandler.java @@ -46,6 +46,6 @@ public class HoeInteractionHandler implements BlockSoundInteractionHandler { levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setSound(SoundEvent.ITEM_USE_ON); levelSoundEventPacket.setExtraData(BlockTranslator.getBedrockBlockId(BlockTranslator.getJavaBlockState(identifier))); - session.getUpstream().sendPacket(levelSoundEventPacket); + session.sendUpstreamPacket(levelSoundEventPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/LeverSoundInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/LeverSoundInteractionHandler.java index cfbe7727..fb39d4ac 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/LeverSoundInteractionHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/block/LeverSoundInteractionHandler.java @@ -43,6 +43,6 @@ public class LeverSoundInteractionHandler implements BlockSoundInteractionHandle levelEventPacket.setPosition(position); levelEventPacket.setType(LevelEventType.REDSTONE_TRIGGER); levelEventPacket.setData(powered ? 600 : 500); - session.getUpstream().sendPacket(levelEventPacket); + session.sendUpstreamPacket(levelEventPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/sound/entity/MilkCowSoundInteractionHandler.java b/connector/src/main/java/org/geysermc/connector/network/translators/sound/entity/MilkCowSoundInteractionHandler.java index d4046eea..42e2e601 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/sound/entity/MilkCowSoundInteractionHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/sound/entity/MilkCowSoundInteractionHandler.java @@ -50,6 +50,6 @@ public class MilkCowSoundInteractionHandler implements EntitySoundInteractionHan levelSoundEventPacket.setIdentifier(":"); levelSoundEventPacket.setSound(SoundEvent.MILK); levelSoundEventPacket.setExtraData(-1); - session.getUpstream().sendPacket(levelSoundEventPacket); + session.sendUpstreamPacket(levelSoundEventPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/FlowerPotBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/FlowerPotBlockEntityTranslator.java index 6861a953..c4748c82 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/FlowerPotBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/FlowerPotBlockEntityTranslator.java @@ -53,7 +53,7 @@ public class FlowerPotBlockEntityTranslator implements BedrockOnlyBlockEntity, R updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.PRIORITY); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NONE); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); - session.getUpstream().sendPacket(updateBlockPacket); + session.sendUpstreamPacket(updateBlockPacket); } /** diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/NoteblockBlockEntityTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/NoteblockBlockEntityTranslator.java index c538f09e..168015f6 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/NoteblockBlockEntityTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/world/block/entity/NoteblockBlockEntityTranslator.java @@ -50,7 +50,7 @@ public class NoteblockBlockEntityTranslator implements RequiresBlockState { blockEventPacket.setBlockPosition(Vector3i.from(position.getX(), position.getY(), position.getZ())); blockEventPacket.setEventType(0); blockEventPacket.setEventData(BlockStateValues.getNoteblockPitch(blockState)); - session.getUpstream().sendPacket(blockEventPacket); + session.sendUpstreamPacket(blockEventPacket); ChunkUtils.CACHED_BLOCK_ENTITIES.remove(position); } diff --git a/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java b/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java index 03ccb2fd..59d9b25f 100644 --- a/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java +++ b/connector/src/main/java/org/geysermc/connector/scoreboard/Scoreboard.java @@ -187,7 +187,7 @@ public class Scoreboard { if (objective.getUpdateType() == REMOVE || update) { RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket(); removeObjectivePacket.setObjectiveId(objective.getObjectiveName()); - session.getUpstream().sendPacket(removeObjectivePacket); + session.sendUpstreamPacket(removeObjectivePacket); if (objective.getUpdateType() == REMOVE) { objectives.remove(objective.getObjectiveName()); // now we can deregister } @@ -199,7 +199,7 @@ public class Scoreboard { displayObjectivePacket.setCriteria("dummy"); displayObjectivePacket.setDisplaySlot(objective.getDisplaySlot()); displayObjectivePacket.setSortOrder(1); // ?? - session.getUpstream().sendPacket(displayObjectivePacket); + session.sendUpstreamPacket(displayObjectivePacket); } objective.setUpdateType(NOTHING); } @@ -208,21 +208,21 @@ public class Scoreboard { SetScorePacket setScorePacket = new SetScorePacket(); setScorePacket.setAction(SetScorePacket.Action.REMOVE); setScorePacket.setInfos(removeScores); - session.getUpstream().sendPacket(setScorePacket); + session.sendUpstreamPacket(setScorePacket); } if (!addScores.isEmpty()) { SetScorePacket setScorePacket = new SetScorePacket(); setScorePacket.setAction(SetScorePacket.Action.SET); setScorePacket.setInfos(addScores); - session.getUpstream().sendPacket(setScorePacket); + session.sendUpstreamPacket(setScorePacket); } } public void despawnObjective(Objective objective) { RemoveObjectivePacket removeObjectivePacket = new RemoveObjectivePacket(); removeObjectivePacket.setObjectiveId(objective.getObjectiveName()); - session.getUpstream().sendPacket(removeObjectivePacket); + session.sendUpstreamPacket(removeObjectivePacket); objectives.remove(objective.getDisplayName()); List toRemove = new ArrayList<>(); @@ -238,7 +238,7 @@ public class Scoreboard { SetScorePacket setScorePacket = new SetScorePacket(); setScorePacket.setAction(SetScorePacket.Action.REMOVE); setScorePacket.setInfos(toRemove); - session.getUpstream().sendPacket(setScorePacket); + session.sendUpstreamPacket(setScorePacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java b/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java index b0794e20..c595eee4 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/BlockEntityUtils.java @@ -49,6 +49,6 @@ public class BlockEntityUtils { BlockEntityDataPacket blockEntityPacket = new BlockEntityDataPacket(); blockEntityPacket.setBlockPosition(position); blockEntityPacket.setData(blockEntity); - session.getUpstream().sendPacket(blockEntityPacket); + session.sendUpstreamPacket(blockEntityPacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java index fcc596eb..7afb8e6a 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/ChunkUtils.java @@ -156,7 +156,7 @@ public class ChunkUtils { NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket(); chunkPublisherUpdatePacket.setPosition(position); chunkPublisherUpdatePacket.setRadius(session.getRenderDistance() << 4); - session.getUpstream().sendPacket(chunkPublisherUpdatePacket); + session.sendUpstreamPacket(chunkPublisherUpdatePacket); session.setLastChunkPosition(newChunkPos); } @@ -188,7 +188,7 @@ public class ChunkUtils { updateBlockPacket.setBlockPosition(position); updateBlockPacket.setRuntimeId(blockId); updateBlockPacket.getFlags().add(UpdateBlockPacket.Flag.NEIGHBORS); - session.getUpstream().sendPacket(updateBlockPacket); + session.sendUpstreamPacket(updateBlockPacket); UpdateBlockPacket waterPacket = new UpdateBlockPacket(); waterPacket.setDataLayer(1); @@ -198,7 +198,7 @@ public class ChunkUtils { } else { waterPacket.setRuntimeId(0); } - session.getUpstream().sendPacket(waterPacket); + session.sendUpstreamPacket(waterPacket); // Since Java stores bed colors/skull information as part of the namespaced ID and Bedrock stores it as a tag // This is the only place I could find that interacts with the Java block state and block updates @@ -228,7 +228,7 @@ public class ChunkUtils { data.setSubChunksLength(0); data.setData(Translators.EMPTY_LEVEL_CHUNK_DATA); data.setCachingEnabled(false); - session.getUpstream().sendPacket(data); + session.sendUpstreamPacket(data); if (forceUpdate) { Vector3i pos = Vector3i.from(chunkX + x << 4, 80, chunkZ + z << 4); @@ -236,7 +236,7 @@ public class ChunkUtils { blockPacket.setBlockPosition(pos); blockPacket.setDataLayer(0); blockPacket.setRuntimeId(1); - session.getUpstream().sendPacket(blockPacket); + session.sendUpstreamPacket(blockPacket); } } } diff --git a/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java b/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java index 6dd182a7..2c3933e2 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/DimensionUtils.java @@ -49,7 +49,7 @@ public class DimensionUtils { changeDimensionPacket.setDimension(bedrockDimension); changeDimensionPacket.setRespawn(true); changeDimensionPacket.setPosition(pos.toFloat()); - session.getUpstream().sendPacket(changeDimensionPacket); + session.sendUpstreamPacket(changeDimensionPacket); player.setDimension(bedrockDimension); player.setPosition(pos.toFloat()); session.setSpawned(false); @@ -59,7 +59,7 @@ public class DimensionUtils { StopSoundPacket stopSoundPacket = new StopSoundPacket(); stopSoundPacket.setStoppingAllSound(true); stopSoundPacket.setSoundName(""); - session.getUpstream().sendPacket(stopSoundPacket); + session.sendUpstreamPacket(stopSoundPacket); } /** diff --git a/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java b/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java index 3717b432..60938119 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/InventoryUtils.java @@ -84,7 +84,7 @@ public class InventoryUtils { cursorPacket.setContainerId(ContainerId.CURSOR); cursorPacket.setSlot(0); cursorPacket.setItem(Translators.getItemTranslator().translateToBedrock(session, session.getInventory().getCursor())); - session.getUpstream().sendPacket(cursorPacket); + session.sendUpstreamPacket(cursorPacket); } public static boolean canStack(ItemStack item1, ItemStack item2) { diff --git a/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java b/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java index 300294a2..7f6c4760 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/LoginEncryptionUtils.java @@ -35,8 +35,6 @@ import com.nukkitx.protocol.bedrock.packet.LoginPacket; import com.nukkitx.protocol.bedrock.packet.ServerToClientHandshakePacket; import com.nukkitx.protocol.bedrock.util.EncryptionUtils; -import net.minidev.json.JSONObject; - import org.geysermc.common.window.CustomFormBuilder; import org.geysermc.common.window.CustomFormWindow; import org.geysermc.common.window.FormWindow; @@ -152,7 +150,7 @@ public class LoginEncryptionUtils { ServerToClientHandshakePacket packet = new ServerToClientHandshakePacket(); packet.setJwt(EncryptionUtils.createHandshakeJwt(serverKeyPair, token).serialize()); - session.getUpstream().sendPacketImmediately(packet); + session.sendUpstreamPacketImmediately(packet); } private static int AUTH_FORM_ID = 1336; diff --git a/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java b/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java index 9ce025e7..db88f2fa 100644 --- a/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java +++ b/connector/src/main/java/org/geysermc/connector/utils/SkinUtils.java @@ -177,12 +177,12 @@ public class SkinUtils { PlayerListPacket playerRemovePacket = new PlayerListPacket(); playerRemovePacket.setAction(PlayerListPacket.Action.REMOVE); playerRemovePacket.getEntries().add(updatedEntry); - session.getUpstream().sendPacket(playerRemovePacket); + session.sendUpstreamPacket(playerRemovePacket); PlayerListPacket playerAddPacket = new PlayerListPacket(); playerAddPacket.setAction(PlayerListPacket.Action.ADD); playerAddPacket.getEntries().add(updatedEntry); - session.getUpstream().sendPacket(playerAddPacket); + session.sendUpstreamPacket(playerAddPacket); } } } catch (Exception e) {