Merge pull request #17 from bluekelp/reduce-event-boilerplate

move boilerplate event stuff
This commit is contained in:
Redned 2019-08-01 22:31:24 -05:00 committed by GitHub
commit 40ff7a038b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 748 additions and 784 deletions

5
.gitignore vendored
View file

@ -25,3 +25,8 @@ hs_err_pid*
*.iml *.iml
*.idea *.idea
# maven target directories
target/
# log directory
logs/

View file

@ -0,0 +1,719 @@
/*
* Copyright (c) 2019 GeyserMC. http://geysermc.org
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @author GeyserMC
* @link https://github.com/GeyserMC/Geyser
*/
package org.geysermc.connector.network;
import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.handler.BedrockPacketHandler;
import com.nukkitx.protocol.bedrock.packet.*;
import org.geysermc.connector.GeyserConnector;
import org.geysermc.connector.network.session.GeyserSession;
/**
* Bare bones implementation of BedrockPacketHandler suitable for extension.
*
* Logs and ignores all packets presented. Allows subclasses to override/implement only
* packets of interest and limit boilerplate code.
*/
public class LoggingPacketHandler implements BedrockPacketHandler {
protected GeyserConnector connector;
protected GeyserSession session;
LoggingPacketHandler(GeyserConnector connector, GeyserSession session) {
this.connector = connector;
this.session = session;
}
boolean defaultHandler(BedrockPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LoginPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ResourcePackClientResponsePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AdventureSettingsPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AnimatePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(BlockEntityDataPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(BlockPickRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(BookEditPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ClientCacheBlobStatusPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ClientCacheMissResponsePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ClientCacheStatusPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ClientToServerHandshakePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(CommandBlockUpdatePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(CommandRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ContainerClosePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(CraftingEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(EntityEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(EntityFallPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(EntityPickRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(EventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(InteractPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(InventoryContentPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(InventorySlotPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(InventoryTransactionPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ItemFrameDropItemPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LabTablePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LecternUpdatePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LevelEventGenericPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LevelSoundEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LevelSoundEvent3Packet packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MapInfoRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MobArmorEquipmentPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MobEquipmentPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ModalFormResponsePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MoveEntityAbsolutePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MovePlayerPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(NetworkStackLatencyPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PhotoTransferPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlayerActionPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlayerHotbarPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlayerInputPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlayerSkinPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PurchaseReceiptPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(RequestChunkRadiusPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ResourcePackChunkRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(RiderJumpPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ServerSettingsRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetDefaultGameTypePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetLocalPlayerAsInitializedPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetPlayerGameTypePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SubClientLoginPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(TextPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AddBehaviorTreePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AddEntityPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AddHangingEntityPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AddItemEntityPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AddPaintingPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AddPlayerPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AvailableCommandsPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(BlockEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(BossEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(CameraPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ChangeDimensionPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ChunkRadiusUpdatedPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ClientboundMapItemDataPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(CommandOutputPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ContainerOpenPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ContainerSetDataPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(CraftingDataPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(DisconnectPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ExplodePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LevelChunkPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(GameRulesChangedPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(GuiDataPickItemPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(HurtArmorPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AutomationClientConnectPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LevelEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MapCreateLockedCopyPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MobEffectPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ModalFormRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(MoveEntityDeltaPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(NpcRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(OnScreenTextureAnimationPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlayerListPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlaySoundPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(PlayStatusPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(RemoveEntityPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(RemoveObjectivePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ResourcePackChunkDataPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ResourcePackDataInfoPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ResourcePacksInfoPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ResourcePackStackPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(RespawnPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ScriptCustomEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ServerSettingsResponsePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ServerToClientHandshakePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetCommandsEnabledPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetDifficultyPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetDisplayObjectivePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetEntityDataPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetEntityLinkPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetEntityMotionPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetHealthPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetLastHurtByPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetScoreboardIdentityPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetScorePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetSpawnPositionPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetTimePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SetTitlePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ShowCreditsPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ShowProfilePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(ShowStoreOfferPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SimpleEventPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SpawnExperienceOrbPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(StartGamePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(StopSoundPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(StructureBlockUpdatePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(StructureTemplateDataExportRequestPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(StructureTemplateDataExportResponsePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(TakeItemEntityPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(TransferPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(UpdateAttributesPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(UpdateBlockPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(UpdateBlockPropertiesPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(UpdateBlockSyncedPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(UpdateEquipPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(UpdateSoftEnumPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(UpdateTradePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(AvailableEntityIdentifiersPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(BiomeDefinitionListPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(LevelSoundEvent2Packet packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(NetworkChunkPublisherUpdatePacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(SpawnParticleEffectPacket packet) {
return defaultHandler(packet);
}
@Override
public boolean handle(VideoStreamConnectPacket packet) {
return defaultHandler(packet);
}
}

View file

@ -28,7 +28,7 @@ package org.geysermc.connector.network;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.nimbusds.jose.JWSObject; import com.nimbusds.jose.JWSObject;
import com.nukkitx.protocol.bedrock.handler.BedrockPacketHandler; import com.nukkitx.protocol.bedrock.BedrockPacket;
import com.nukkitx.protocol.bedrock.packet.*; import com.nukkitx.protocol.bedrock.packet.*;
import com.nukkitx.protocol.bedrock.util.EncryptionUtils; import com.nukkitx.protocol.bedrock.util.EncryptionUtils;
import net.minidev.json.JSONObject; import net.minidev.json.JSONObject;
@ -55,14 +55,15 @@ import java.security.interfaces.ECPublicKey;
import java.security.spec.ECGenParameterSpec; import java.security.spec.ECGenParameterSpec;
import java.util.UUID; import java.util.UUID;
public class UpstreamPacketHandler implements BedrockPacketHandler { public class UpstreamPacketHandler extends LoggingPacketHandler {
private GeyserConnector connector;
private GeyserSession session;
public UpstreamPacketHandler(GeyserConnector connector, GeyserSession session) { public UpstreamPacketHandler(GeyserConnector connector, GeyserSession session) {
this.connector = connector; super(connector, session);
this.session = session; }
private boolean translateAndDefault(BedrockPacket packet) {
Registry.BEDROCK.translate(packet.getClass(), packet, session);
return defaultHandler(packet);
} }
@Override @Override
@ -149,188 +150,6 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
return true; return true;
} }
@Override
public boolean handle(AdventureSettingsPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AnimatePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
Registry.BEDROCK.translate(packet.getClass(), packet, session);
return true;
}
@Override
public boolean handle(BlockEntityDataPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BlockPickRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BookEditPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientCacheBlobStatusPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientCacheMissResponsePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientCacheStatusPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientToServerHandshakePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CommandBlockUpdatePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CommandRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
Registry.BEDROCK.translate(packet.getClass(), packet, session);
return true;
}
@Override
public boolean handle(ContainerClosePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CraftingEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EntityEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EntityFallPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EntityPickRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(EventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InteractPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InventoryContentPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InventorySlotPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(InventoryTransactionPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ItemFrameDropItemPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LabTablePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LecternUpdatePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelEventGenericPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelSoundEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelSoundEvent3Packet packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MapInfoRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MobArmorEquipmentPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MobEquipmentPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override @Override
public boolean handle(ModalFormResponsePacket packet) { public boolean handle(ModalFormResponsePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName()); connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
@ -360,12 +179,6 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
return true; return true;
} }
@Override
public boolean handle(MoveEntityAbsolutePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override @Override
public boolean handle(MovePlayerPacket packet) { public boolean handle(MovePlayerPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName()); connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
@ -383,595 +196,6 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
return false; return false;
} }
@Override
public boolean handle(NetworkStackLatencyPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PhotoTransferPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerActionPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerHotbarPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerInputPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerSkinPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PurchaseReceiptPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RequestChunkRadiusPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackChunkRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RiderJumpPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ServerSettingsRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetDefaultGameTypePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetLocalPlayerAsInitializedPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetPlayerGameTypePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SubClientLoginPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(TextPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
Registry.BEDROCK.translate(packet.getClass(), packet, session);
return true;
}
@Override
public boolean handle(AddBehaviorTreePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddEntityPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddHangingEntityPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddItemEntityPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddPaintingPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AddPlayerPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AvailableCommandsPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BlockEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BossEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CameraPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ChangeDimensionPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ChunkRadiusUpdatedPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ClientboundMapItemDataPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CommandOutputPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ContainerOpenPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ContainerSetDataPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(CraftingDataPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(DisconnectPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ExplodePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelChunkPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(GameRulesChangedPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(GuiDataPickItemPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(HurtArmorPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AutomationClientConnectPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MapCreateLockedCopyPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MobEffectPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ModalFormRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(MoveEntityDeltaPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(NpcRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(OnScreenTextureAnimationPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayerListPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlaySoundPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(PlayStatusPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RemoveEntityPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RemoveObjectivePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackChunkDataPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackDataInfoPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePacksInfoPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ResourcePackStackPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(RespawnPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ScriptCustomEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ServerSettingsResponsePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ServerToClientHandshakePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetCommandsEnabledPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetDifficultyPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetDisplayObjectivePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetEntityDataPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetEntityLinkPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetEntityMotionPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetHealthPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetLastHurtByPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetScoreboardIdentityPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetScorePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetSpawnPositionPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetTimePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SetTitlePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ShowCreditsPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ShowProfilePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(ShowStoreOfferPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SimpleEventPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SpawnExperienceOrbPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StartGamePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StopSoundPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StructureBlockUpdatePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StructureTemplateDataExportRequestPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(StructureTemplateDataExportResponsePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(TakeItemEntityPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(TransferPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateAttributesPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateBlockPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateBlockPropertiesPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateBlockSyncedPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateEquipPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateSoftEnumPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(UpdateTradePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(AvailableEntityIdentifiersPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(BiomeDefinitionListPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(LevelSoundEvent2Packet packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(NetworkChunkPublisherUpdatePacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(SpawnParticleEffectPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
@Override
public boolean handle(VideoStreamConnectPacket packet) {
connector.getLogger().debug("Handled packet: " + packet.getClass().getSimpleName());
return false;
}
private void startEncryptionHandshake(PublicKey key) throws Exception { private void startEncryptionHandshake(PublicKey key) throws Exception {
KeyPairGenerator generator = KeyPairGenerator.getInstance("EC"); KeyPairGenerator generator = KeyPairGenerator.getInstance("EC");
generator.initialize(new ECGenParameterSpec("secp384r1")); generator.initialize(new ECGenParameterSpec("secp384r1"));
@ -985,4 +209,20 @@ public class UpstreamPacketHandler implements BedrockPacketHandler {
packet.setJwt(EncryptionUtils.createHandshakeJwt(serverKeyPair, token).serialize()); packet.setJwt(EncryptionUtils.createHandshakeJwt(serverKeyPair, token).serialize());
session.getUpstream().sendPacketImmediately(packet); session.getUpstream().sendPacketImmediately(packet);
} }
@Override
public boolean handle(AnimatePacket packet) {
return translateAndDefault(packet);
}
@Override
public boolean handle(CommandRequestPacket packet) {
return translateAndDefault(packet);
}
@Override
public boolean handle(TextPacket packet) {
return translateAndDefault(packet);
}
} }