2014-03-01 19:47:32 -05:00
|
|
|
package org.spacehq.mc.protocol;
|
|
|
|
|
2015-07-22 16:49:42 -04:00
|
|
|
import org.spacehq.mc.auth.data.GameProfile;
|
2015-07-22 16:40:13 -04:00
|
|
|
import org.spacehq.mc.auth.exception.request.RequestException;
|
2015-08-24 23:17:03 -04:00
|
|
|
import org.spacehq.mc.auth.service.AuthenticationService;
|
2015-07-21 20:40:42 -04:00
|
|
|
import org.spacehq.mc.protocol.data.SubProtocol;
|
2014-03-01 19:47:32 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.handshake.client.HandshakePacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientChatPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientKeepAlivePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientPluginMessagePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientRequestPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientResourcePackStatusPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientSettingsPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.ClientTabCompletePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerAbilitiesPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerActionPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerChangeHeldItemPacket;
|
2014-03-22 12:41:46 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerInteractEntityPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerMovementPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerPositionRotationPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerRotationPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerStatePacket;
|
2015-09-24 22:48:19 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerSwingArmPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientTeleportConfirmPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.player.ClientPlayerUseItemPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientConfirmTransactionPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientCreativeInventoryActionPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientEnchantItemPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.window.ClientWindowActionPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientSpectatePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientSteerBoatPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientSteerVehiclePacket;
|
2014-03-01 19:47:32 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientUpdateSignPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.client.world.ClientVehicleMovePacket;
|
2015-08-24 23:17:03 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerBossBarPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerChatPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerCombatPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerDifficultyPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerDisconnectPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerJoinGamePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerKeepAlivePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerPlayerListDataPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerPlayerListEntryPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerPluginMessagePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerResourcePackSendPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerRespawnPacket;
|
2015-08-24 23:17:03 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerSetCooldownPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerStatisticsPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerSwitchCameraPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerTabCompletePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.ServerTitlePacket;
|
2015-09-24 22:48:19 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityAnimationPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityAttachPacket;
|
2015-09-24 22:48:19 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityCollectItemPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityDestroyPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityEffectPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityEquipmentPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityHeadLookPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityMetadataPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityMovementPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPositionRotationPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityPropertiesPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityRemoveEffectPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityRotationPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntitySetPassengersPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityStatusPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityTeleportPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerEntityVelocityPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.ServerVehicleMovePacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerAbilitiesPacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerChangeHeldItemPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerHealthPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket;
|
2015-09-24 22:48:19 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerSetExperiencePacket;
|
2016-03-03 21:32:08 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerUseBedPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnExpOrbPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnGlobalEntityPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnMobPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnObjectPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPaintingPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.entity.spawn.ServerSpawnPlayerPacket;
|
2014-03-01 19:47:32 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerScoreboardObjectivePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerTeamPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.scoreboard.ServerUpdateScorePacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerCloseWindowPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerConfirmTransactionPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerOpenWindowPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerSetSlotPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerWindowItemsPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.window.ServerWindowPropertyPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockBreakAnimPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockChangePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerBlockValuePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerChunkDataPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerExplosionPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMapDataPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerMultiBlockChangePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerNotifyClientPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerOpenTileEntityEditorPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlayEffectPacket;
|
2016-03-04 21:32:10 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlayBuiltinSoundPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerPlaySoundPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerSpawnParticlePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerSpawnPositionPacket;
|
2015-08-24 23:17:03 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUnloadChunkPacket;
|
2015-07-20 14:01:13 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateSignPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTileEntityPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerUpdateTimePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.ingame.server.world.ServerWorldBorderPacket;
|
2014-03-01 19:47:32 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.login.client.EncryptionResponsePacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.login.client.LoginStartPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.login.server.EncryptionRequestPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.login.server.LoginDisconnectPacket;
|
2014-08-11 01:51:41 -04:00
|
|
|
import org.spacehq.mc.protocol.packet.login.server.LoginSetCompressionPacket;
|
2014-03-01 19:47:32 -05:00
|
|
|
import org.spacehq.mc.protocol.packet.login.server.LoginSuccessPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.status.client.StatusPingPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.status.client.StatusQueryPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.status.server.StatusPongPacket;
|
|
|
|
import org.spacehq.mc.protocol.packet.status.server.StatusResponsePacket;
|
|
|
|
import org.spacehq.packetlib.Client;
|
|
|
|
import org.spacehq.packetlib.Server;
|
|
|
|
import org.spacehq.packetlib.Session;
|
|
|
|
import org.spacehq.packetlib.crypt.AESEncryption;
|
|
|
|
import org.spacehq.packetlib.crypt.PacketEncryption;
|
2014-06-20 17:21:53 -04:00
|
|
|
import org.spacehq.packetlib.packet.DefaultPacketHeader;
|
|
|
|
import org.spacehq.packetlib.packet.PacketHeader;
|
2014-03-01 19:47:32 -05:00
|
|
|
import org.spacehq.packetlib.packet.PacketProtocol;
|
2013-12-14 19:40:30 -05:00
|
|
|
|
2015-07-11 15:53:25 -04:00
|
|
|
import java.net.Proxy;
|
2013-12-14 19:40:30 -05:00
|
|
|
import java.security.GeneralSecurityException;
|
|
|
|
import java.security.Key;
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
public class MinecraftProtocol extends PacketProtocol {
|
2015-07-21 20:40:42 -04:00
|
|
|
private SubProtocol subProtocol = SubProtocol.HANDSHAKE;
|
2015-07-20 14:01:13 -04:00
|
|
|
private PacketHeader header = new DefaultPacketHeader();
|
|
|
|
private AESEncryption encrypt;
|
|
|
|
|
|
|
|
private GameProfile profile;
|
|
|
|
private String accessToken = "";
|
|
|
|
|
|
|
|
@SuppressWarnings("unused")
|
|
|
|
private MinecraftProtocol() {
|
|
|
|
}
|
|
|
|
|
2015-07-21 20:40:42 -04:00
|
|
|
public MinecraftProtocol(SubProtocol subProtocol) {
|
|
|
|
if(subProtocol != SubProtocol.LOGIN && subProtocol != SubProtocol.STATUS) {
|
2015-07-20 14:01:13 -04:00
|
|
|
throw new IllegalArgumentException("Only login and status modes are permitted.");
|
|
|
|
}
|
|
|
|
|
2015-07-21 20:40:42 -04:00
|
|
|
this.subProtocol = subProtocol;
|
|
|
|
if(subProtocol == SubProtocol.LOGIN) {
|
2015-07-20 14:01:13 -04:00
|
|
|
this.profile = new GameProfile((UUID) null, "Player");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public MinecraftProtocol(String username) {
|
2015-07-21 20:40:42 -04:00
|
|
|
this(SubProtocol.LOGIN);
|
2015-07-20 14:01:13 -04:00
|
|
|
this.profile = new GameProfile((UUID) null, username);
|
|
|
|
}
|
|
|
|
|
2015-07-22 16:40:13 -04:00
|
|
|
public MinecraftProtocol(String username, String password) throws RequestException {
|
2015-07-20 14:01:13 -04:00
|
|
|
this(username, password, false);
|
|
|
|
}
|
|
|
|
|
2015-07-22 16:40:13 -04:00
|
|
|
public MinecraftProtocol(String username, String using, boolean token) throws RequestException {
|
2015-07-20 14:01:13 -04:00
|
|
|
this(username, using, token, Proxy.NO_PROXY);
|
|
|
|
}
|
|
|
|
|
2015-07-22 16:40:13 -04:00
|
|
|
public MinecraftProtocol(String username, String using, boolean token, Proxy authProxy) throws RequestException {
|
2015-07-21 20:40:42 -04:00
|
|
|
this(SubProtocol.LOGIN);
|
2015-07-20 14:01:13 -04:00
|
|
|
String clientToken = UUID.randomUUID().toString();
|
2015-07-22 00:41:08 -04:00
|
|
|
AuthenticationService auth = new AuthenticationService(clientToken, authProxy);
|
2015-07-20 14:01:13 -04:00
|
|
|
auth.setUsername(username);
|
|
|
|
if(token) {
|
|
|
|
auth.setAccessToken(using);
|
|
|
|
} else {
|
|
|
|
auth.setPassword(using);
|
|
|
|
}
|
|
|
|
|
|
|
|
auth.login();
|
|
|
|
this.profile = auth.getSelectedProfile();
|
|
|
|
this.accessToken = auth.getAccessToken();
|
|
|
|
}
|
|
|
|
|
|
|
|
public MinecraftProtocol(GameProfile profile, String accessToken) {
|
2015-07-21 20:40:42 -04:00
|
|
|
this(SubProtocol.LOGIN);
|
2015-07-20 14:01:13 -04:00
|
|
|
this.profile = profile;
|
|
|
|
this.accessToken = accessToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
public GameProfile getProfile() {
|
|
|
|
return this.profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getAccessToken() {
|
|
|
|
return this.accessToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public String getSRVRecordPrefix() {
|
|
|
|
return "_minecraft";
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PacketHeader getPacketHeader() {
|
|
|
|
return this.header;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public PacketEncryption getEncryption() {
|
|
|
|
return this.encrypt;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void newClientSession(Client client, Session session) {
|
|
|
|
if(this.profile != null) {
|
2015-07-21 20:40:42 -04:00
|
|
|
session.setFlag(MinecraftConstants.PROFILE_KEY, this.profile);
|
|
|
|
session.setFlag(MinecraftConstants.ACCESS_TOKEN_KEY, this.accessToken);
|
2015-07-20 14:01:13 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 20:40:42 -04:00
|
|
|
this.setSubProtocol(this.subProtocol, true, session);
|
2015-08-13 22:34:42 -04:00
|
|
|
session.addListener(new ClientListener());
|
2015-07-20 14:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void newServerSession(Server server, Session session) {
|
2015-07-21 20:40:42 -04:00
|
|
|
this.setSubProtocol(SubProtocol.HANDSHAKE, false, session);
|
2015-07-20 14:01:13 -04:00
|
|
|
session.addListener(new ServerListener());
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void enableEncryption(Key key) {
|
|
|
|
try {
|
|
|
|
this.encrypt = new AESEncryption(key);
|
|
|
|
} catch(GeneralSecurityException e) {
|
|
|
|
throw new Error("Failed to enable protocol encryption.", e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-21 20:40:42 -04:00
|
|
|
public SubProtocol getSubProtocol() {
|
|
|
|
return this.subProtocol;
|
2015-07-20 14:01:13 -04:00
|
|
|
}
|
|
|
|
|
2015-07-21 20:40:42 -04:00
|
|
|
protected void setSubProtocol(SubProtocol subProtocol, boolean client, Session session) {
|
2015-07-20 14:01:13 -04:00
|
|
|
this.clearPackets();
|
2015-07-21 20:40:42 -04:00
|
|
|
switch(subProtocol) {
|
2015-07-20 14:01:13 -04:00
|
|
|
case HANDSHAKE:
|
|
|
|
if(client) {
|
|
|
|
this.initClientHandshake(session);
|
|
|
|
} else {
|
|
|
|
this.initServerHandshake(session);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case LOGIN:
|
|
|
|
if(client) {
|
|
|
|
this.initClientLogin(session);
|
|
|
|
} else {
|
|
|
|
this.initServerLogin(session);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case GAME:
|
|
|
|
if(client) {
|
|
|
|
this.initClientGame(session);
|
|
|
|
} else {
|
|
|
|
this.initServerGame(session);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case STATUS:
|
|
|
|
if(client) {
|
|
|
|
this.initClientStatus(session);
|
|
|
|
} else {
|
|
|
|
this.initServerStatus(session);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-07-21 20:40:42 -04:00
|
|
|
this.subProtocol = subProtocol;
|
2015-07-20 14:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void initClientHandshake(Session session) {
|
|
|
|
this.registerOutgoing(0, HandshakePacket.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initServerHandshake(Session session) {
|
|
|
|
this.registerIncoming(0, HandshakePacket.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initClientLogin(Session session) {
|
|
|
|
this.registerIncoming(0, LoginDisconnectPacket.class);
|
|
|
|
this.registerIncoming(1, EncryptionRequestPacket.class);
|
|
|
|
this.registerIncoming(2, LoginSuccessPacket.class);
|
|
|
|
this.registerIncoming(3, LoginSetCompressionPacket.class);
|
|
|
|
|
|
|
|
this.registerOutgoing(0, LoginStartPacket.class);
|
|
|
|
this.registerOutgoing(1, EncryptionResponsePacket.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initServerLogin(Session session) {
|
|
|
|
this.registerIncoming(0, LoginStartPacket.class);
|
|
|
|
this.registerIncoming(1, EncryptionResponsePacket.class);
|
|
|
|
|
|
|
|
this.registerOutgoing(0, LoginDisconnectPacket.class);
|
|
|
|
this.registerOutgoing(1, EncryptionRequestPacket.class);
|
|
|
|
this.registerOutgoing(2, LoginSuccessPacket.class);
|
|
|
|
this.registerOutgoing(3, LoginSetCompressionPacket.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initClientGame(Session session) {
|
2015-09-24 22:48:19 -04:00
|
|
|
this.registerIncoming(0, ServerSpawnObjectPacket.class);
|
|
|
|
this.registerIncoming(1, ServerSpawnExpOrbPacket.class);
|
|
|
|
this.registerIncoming(2, ServerSpawnGlobalEntityPacket.class);
|
|
|
|
this.registerIncoming(3, ServerSpawnMobPacket.class);
|
|
|
|
this.registerIncoming(4, ServerSpawnPaintingPacket.class);
|
|
|
|
this.registerIncoming(5, ServerSpawnPlayerPacket.class);
|
|
|
|
this.registerIncoming(6, ServerEntityAnimationPacket.class);
|
|
|
|
this.registerIncoming(7, ServerStatisticsPacket.class);
|
|
|
|
this.registerIncoming(8, ServerBlockBreakAnimPacket.class);
|
|
|
|
this.registerIncoming(9, ServerUpdateTileEntityPacket.class);
|
|
|
|
this.registerIncoming(10, ServerBlockValuePacket.class);
|
|
|
|
this.registerIncoming(11, ServerBlockChangePacket.class);
|
|
|
|
this.registerIncoming(12, ServerBossBarPacket.class);
|
|
|
|
this.registerIncoming(13, ServerDifficultyPacket.class);
|
|
|
|
this.registerIncoming(14, ServerTabCompletePacket.class);
|
|
|
|
this.registerIncoming(15, ServerChatPacket.class);
|
|
|
|
this.registerIncoming(16, ServerMultiBlockChangePacket.class);
|
|
|
|
this.registerIncoming(17, ServerConfirmTransactionPacket.class);
|
|
|
|
this.registerIncoming(18, ServerCloseWindowPacket.class);
|
|
|
|
this.registerIncoming(19, ServerOpenWindowPacket.class);
|
|
|
|
this.registerIncoming(20, ServerWindowItemsPacket.class);
|
|
|
|
this.registerIncoming(21, ServerWindowPropertyPacket.class);
|
|
|
|
this.registerIncoming(22, ServerSetSlotPacket.class);
|
|
|
|
this.registerIncoming(23, ServerSetCooldownPacket.class);
|
|
|
|
this.registerIncoming(24, ServerPluginMessagePacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerIncoming(25, ServerPlaySoundPacket.class);
|
|
|
|
this.registerIncoming(26, ServerDisconnectPacket.class);
|
|
|
|
this.registerIncoming(27, ServerEntityStatusPacket.class);
|
|
|
|
this.registerIncoming(28, ServerExplosionPacket.class);
|
|
|
|
this.registerIncoming(29, ServerUnloadChunkPacket.class);
|
2015-09-24 22:48:19 -04:00
|
|
|
this.registerIncoming(30, ServerNotifyClientPacket.class);
|
|
|
|
this.registerIncoming(31, ServerKeepAlivePacket.class);
|
|
|
|
this.registerIncoming(32, ServerChunkDataPacket.class);
|
|
|
|
this.registerIncoming(33, ServerPlayEffectPacket.class);
|
|
|
|
this.registerIncoming(34, ServerSpawnParticlePacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerIncoming(35, ServerJoinGamePacket.class);
|
|
|
|
this.registerIncoming(36, ServerMapDataPacket.class);
|
|
|
|
this.registerIncoming(37, ServerEntityPositionPacket.class);
|
|
|
|
this.registerIncoming(38, ServerEntityPositionRotationPacket.class);
|
|
|
|
this.registerIncoming(39, ServerEntityRotationPacket.class);
|
|
|
|
this.registerIncoming(40, ServerEntityMovementPacket.class);
|
|
|
|
this.registerIncoming(41, ServerVehicleMovePacket.class);
|
2015-09-24 22:48:19 -04:00
|
|
|
this.registerIncoming(42, ServerOpenTileEntityEditorPacket.class);
|
|
|
|
this.registerIncoming(43, ServerPlayerAbilitiesPacket.class);
|
|
|
|
this.registerIncoming(44, ServerCombatPacket.class);
|
|
|
|
this.registerIncoming(45, ServerPlayerListEntryPacket.class);
|
|
|
|
this.registerIncoming(46, ServerPlayerPositionRotationPacket.class);
|
|
|
|
this.registerIncoming(47, ServerPlayerUseBedPacket.class);
|
|
|
|
this.registerIncoming(48, ServerEntityDestroyPacket.class);
|
|
|
|
this.registerIncoming(49, ServerEntityRemoveEffectPacket.class);
|
|
|
|
this.registerIncoming(50, ServerResourcePackSendPacket.class);
|
|
|
|
this.registerIncoming(51, ServerRespawnPacket.class);
|
|
|
|
this.registerIncoming(52, ServerEntityHeadLookPacket.class);
|
|
|
|
this.registerIncoming(53, ServerWorldBorderPacket.class);
|
|
|
|
this.registerIncoming(54, ServerSwitchCameraPacket.class);
|
|
|
|
this.registerIncoming(55, ServerPlayerChangeHeldItemPacket.class);
|
|
|
|
this.registerIncoming(56, ServerDisplayScoreboardPacket.class);
|
|
|
|
this.registerIncoming(57, ServerEntityMetadataPacket.class);
|
|
|
|
this.registerIncoming(58, ServerEntityAttachPacket.class);
|
|
|
|
this.registerIncoming(59, ServerEntityVelocityPacket.class);
|
|
|
|
this.registerIncoming(60, ServerEntityEquipmentPacket.class);
|
|
|
|
this.registerIncoming(61, ServerPlayerSetExperiencePacket.class);
|
|
|
|
this.registerIncoming(62, ServerPlayerHealthPacket.class);
|
|
|
|
this.registerIncoming(63, ServerScoreboardObjectivePacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerIncoming(64, ServerEntitySetPassengersPacket.class);
|
|
|
|
this.registerIncoming(65, ServerTeamPacket.class);
|
|
|
|
this.registerIncoming(66, ServerUpdateScorePacket.class);
|
|
|
|
this.registerIncoming(67, ServerSpawnPositionPacket.class);
|
|
|
|
this.registerIncoming(68, ServerUpdateTimePacket.class);
|
|
|
|
this.registerIncoming(69, ServerTitlePacket.class);
|
|
|
|
this.registerIncoming(70, ServerUpdateSignPacket.class);
|
2016-03-04 21:32:10 -05:00
|
|
|
this.registerIncoming(71, ServerPlayBuiltinSoundPacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerIncoming(72, ServerPlayerListDataPacket.class);
|
|
|
|
this.registerIncoming(73, ServerEntityCollectItemPacket.class);
|
|
|
|
this.registerIncoming(74, ServerEntityTeleportPacket.class);
|
|
|
|
this.registerIncoming(75, ServerEntityPropertiesPacket.class);
|
|
|
|
this.registerIncoming(76, ServerEntityEffectPacket.class);
|
|
|
|
|
|
|
|
this.registerOutgoing(0, ClientTeleportConfirmPacket.class);
|
|
|
|
this.registerOutgoing(1, ClientTabCompletePacket.class);
|
|
|
|
this.registerOutgoing(2, ClientChatPacket.class);
|
|
|
|
this.registerOutgoing(3, ClientRequestPacket.class);
|
|
|
|
this.registerOutgoing(4, ClientSettingsPacket.class);
|
|
|
|
this.registerOutgoing(5, ClientConfirmTransactionPacket.class);
|
|
|
|
this.registerOutgoing(6, ClientEnchantItemPacket.class);
|
|
|
|
this.registerOutgoing(7, ClientWindowActionPacket.class);
|
|
|
|
this.registerOutgoing(8, ClientCloseWindowPacket.class);
|
|
|
|
this.registerOutgoing(9, ClientPluginMessagePacket.class);
|
|
|
|
this.registerOutgoing(10, ClientPlayerInteractEntityPacket.class);
|
|
|
|
this.registerOutgoing(11, ClientKeepAlivePacket.class);
|
|
|
|
this.registerOutgoing(12, ClientPlayerPositionPacket.class);
|
|
|
|
this.registerOutgoing(13, ClientPlayerPositionRotationPacket.class);
|
|
|
|
this.registerOutgoing(14, ClientPlayerRotationPacket.class);
|
|
|
|
this.registerOutgoing(15, ClientPlayerMovementPacket.class);
|
|
|
|
this.registerOutgoing(16, ClientVehicleMovePacket.class);
|
|
|
|
this.registerOutgoing(17, ClientSteerBoatPacket.class);
|
|
|
|
this.registerOutgoing(18, ClientPlayerAbilitiesPacket.class);
|
|
|
|
this.registerOutgoing(19, ClientPlayerActionPacket.class);
|
|
|
|
this.registerOutgoing(20, ClientPlayerStatePacket.class);
|
|
|
|
this.registerOutgoing(21, ClientSteerVehiclePacket.class);
|
|
|
|
this.registerOutgoing(22, ClientResourcePackStatusPacket.class);
|
|
|
|
this.registerOutgoing(23, ClientPlayerChangeHeldItemPacket.class);
|
|
|
|
this.registerOutgoing(24, ClientCreativeInventoryActionPacket.class);
|
|
|
|
this.registerOutgoing(25, ClientUpdateSignPacket.class);
|
|
|
|
this.registerOutgoing(26, ClientPlayerSwingArmPacket.class);
|
|
|
|
this.registerOutgoing(27, ClientSpectatePacket.class);
|
|
|
|
this.registerOutgoing(28, ClientPlayerPlaceBlockPacket.class);
|
|
|
|
this.registerOutgoing(29, ClientPlayerUseItemPacket.class);
|
2015-07-20 14:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void initServerGame(Session session) {
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerIncoming(0, ClientTeleportConfirmPacket.class);
|
|
|
|
this.registerIncoming(1, ClientTabCompletePacket.class);
|
|
|
|
this.registerIncoming(2, ClientChatPacket.class);
|
|
|
|
this.registerIncoming(3, ClientRequestPacket.class);
|
|
|
|
this.registerIncoming(4, ClientSettingsPacket.class);
|
|
|
|
this.registerIncoming(5, ClientConfirmTransactionPacket.class);
|
|
|
|
this.registerIncoming(6, ClientEnchantItemPacket.class);
|
|
|
|
this.registerIncoming(7, ClientWindowActionPacket.class);
|
|
|
|
this.registerIncoming(8, ClientCloseWindowPacket.class);
|
|
|
|
this.registerIncoming(9, ClientPluginMessagePacket.class);
|
|
|
|
this.registerIncoming(10, ClientPlayerInteractEntityPacket.class);
|
|
|
|
this.registerIncoming(11, ClientKeepAlivePacket.class);
|
|
|
|
this.registerIncoming(12, ClientPlayerPositionPacket.class);
|
|
|
|
this.registerIncoming(13, ClientPlayerPositionRotationPacket.class);
|
|
|
|
this.registerIncoming(14, ClientPlayerRotationPacket.class);
|
|
|
|
this.registerIncoming(15, ClientPlayerMovementPacket.class);
|
|
|
|
this.registerIncoming(16, ClientVehicleMovePacket.class);
|
|
|
|
this.registerIncoming(17, ClientSteerBoatPacket.class);
|
|
|
|
this.registerIncoming(18, ClientPlayerAbilitiesPacket.class);
|
|
|
|
this.registerIncoming(19, ClientPlayerActionPacket.class);
|
|
|
|
this.registerIncoming(20, ClientPlayerStatePacket.class);
|
|
|
|
this.registerIncoming(21, ClientSteerVehiclePacket.class);
|
|
|
|
this.registerIncoming(22, ClientResourcePackStatusPacket.class);
|
|
|
|
this.registerIncoming(23, ClientPlayerChangeHeldItemPacket.class);
|
|
|
|
this.registerIncoming(24, ClientCreativeInventoryActionPacket.class);
|
|
|
|
this.registerIncoming(25, ClientUpdateSignPacket.class);
|
|
|
|
this.registerIncoming(26, ClientPlayerSwingArmPacket.class);
|
|
|
|
this.registerIncoming(27, ClientSpectatePacket.class);
|
|
|
|
this.registerIncoming(28, ClientPlayerPlaceBlockPacket.class);
|
|
|
|
this.registerIncoming(29, ClientPlayerUseItemPacket.class);
|
2015-09-24 22:48:19 -04:00
|
|
|
|
|
|
|
this.registerOutgoing(0, ServerSpawnObjectPacket.class);
|
|
|
|
this.registerOutgoing(1, ServerSpawnExpOrbPacket.class);
|
|
|
|
this.registerOutgoing(2, ServerSpawnGlobalEntityPacket.class);
|
|
|
|
this.registerOutgoing(3, ServerSpawnMobPacket.class);
|
|
|
|
this.registerOutgoing(4, ServerSpawnPaintingPacket.class);
|
|
|
|
this.registerOutgoing(5, ServerSpawnPlayerPacket.class);
|
|
|
|
this.registerOutgoing(6, ServerEntityAnimationPacket.class);
|
|
|
|
this.registerOutgoing(7, ServerStatisticsPacket.class);
|
|
|
|
this.registerOutgoing(8, ServerBlockBreakAnimPacket.class);
|
|
|
|
this.registerOutgoing(9, ServerUpdateTileEntityPacket.class);
|
|
|
|
this.registerOutgoing(10, ServerBlockValuePacket.class);
|
|
|
|
this.registerOutgoing(11, ServerBlockChangePacket.class);
|
|
|
|
this.registerOutgoing(12, ServerBossBarPacket.class);
|
|
|
|
this.registerOutgoing(13, ServerDifficultyPacket.class);
|
|
|
|
this.registerOutgoing(14, ServerTabCompletePacket.class);
|
|
|
|
this.registerOutgoing(15, ServerChatPacket.class);
|
|
|
|
this.registerOutgoing(16, ServerMultiBlockChangePacket.class);
|
|
|
|
this.registerOutgoing(17, ServerConfirmTransactionPacket.class);
|
|
|
|
this.registerOutgoing(18, ServerCloseWindowPacket.class);
|
|
|
|
this.registerOutgoing(19, ServerOpenWindowPacket.class);
|
|
|
|
this.registerOutgoing(20, ServerWindowItemsPacket.class);
|
|
|
|
this.registerOutgoing(21, ServerWindowPropertyPacket.class);
|
|
|
|
this.registerOutgoing(22, ServerSetSlotPacket.class);
|
|
|
|
this.registerOutgoing(23, ServerSetCooldownPacket.class);
|
|
|
|
this.registerOutgoing(24, ServerPluginMessagePacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerOutgoing(25, ServerPlaySoundPacket.class);
|
|
|
|
this.registerOutgoing(26, ServerDisconnectPacket.class);
|
|
|
|
this.registerOutgoing(27, ServerEntityStatusPacket.class);
|
|
|
|
this.registerOutgoing(28, ServerExplosionPacket.class);
|
|
|
|
this.registerOutgoing(29, ServerUnloadChunkPacket.class);
|
2015-09-24 22:48:19 -04:00
|
|
|
this.registerOutgoing(30, ServerNotifyClientPacket.class);
|
|
|
|
this.registerOutgoing(31, ServerKeepAlivePacket.class);
|
|
|
|
this.registerOutgoing(32, ServerChunkDataPacket.class);
|
|
|
|
this.registerOutgoing(33, ServerPlayEffectPacket.class);
|
|
|
|
this.registerOutgoing(34, ServerSpawnParticlePacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerOutgoing(35, ServerJoinGamePacket.class);
|
|
|
|
this.registerOutgoing(36, ServerMapDataPacket.class);
|
|
|
|
this.registerOutgoing(37, ServerEntityPositionPacket.class);
|
|
|
|
this.registerOutgoing(38, ServerEntityPositionRotationPacket.class);
|
|
|
|
this.registerOutgoing(39, ServerEntityRotationPacket.class);
|
|
|
|
this.registerOutgoing(40, ServerEntityMovementPacket.class);
|
|
|
|
this.registerOutgoing(41, ServerVehicleMovePacket.class);
|
2015-09-24 22:48:19 -04:00
|
|
|
this.registerOutgoing(42, ServerOpenTileEntityEditorPacket.class);
|
|
|
|
this.registerOutgoing(43, ServerPlayerAbilitiesPacket.class);
|
|
|
|
this.registerOutgoing(44, ServerCombatPacket.class);
|
|
|
|
this.registerOutgoing(45, ServerPlayerListEntryPacket.class);
|
|
|
|
this.registerOutgoing(46, ServerPlayerPositionRotationPacket.class);
|
|
|
|
this.registerOutgoing(47, ServerPlayerUseBedPacket.class);
|
|
|
|
this.registerOutgoing(48, ServerEntityDestroyPacket.class);
|
|
|
|
this.registerOutgoing(49, ServerEntityRemoveEffectPacket.class);
|
|
|
|
this.registerOutgoing(50, ServerResourcePackSendPacket.class);
|
|
|
|
this.registerOutgoing(51, ServerRespawnPacket.class);
|
|
|
|
this.registerOutgoing(52, ServerEntityHeadLookPacket.class);
|
|
|
|
this.registerOutgoing(53, ServerWorldBorderPacket.class);
|
|
|
|
this.registerOutgoing(54, ServerSwitchCameraPacket.class);
|
|
|
|
this.registerOutgoing(55, ServerPlayerChangeHeldItemPacket.class);
|
|
|
|
this.registerOutgoing(56, ServerDisplayScoreboardPacket.class);
|
|
|
|
this.registerOutgoing(57, ServerEntityMetadataPacket.class);
|
|
|
|
this.registerOutgoing(58, ServerEntityAttachPacket.class);
|
|
|
|
this.registerOutgoing(59, ServerEntityVelocityPacket.class);
|
|
|
|
this.registerOutgoing(60, ServerEntityEquipmentPacket.class);
|
|
|
|
this.registerOutgoing(61, ServerPlayerSetExperiencePacket.class);
|
|
|
|
this.registerOutgoing(62, ServerPlayerHealthPacket.class);
|
|
|
|
this.registerOutgoing(63, ServerScoreboardObjectivePacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerOutgoing(64, ServerEntitySetPassengersPacket.class);
|
|
|
|
this.registerOutgoing(65, ServerTeamPacket.class);
|
|
|
|
this.registerOutgoing(66, ServerUpdateScorePacket.class);
|
|
|
|
this.registerOutgoing(67, ServerSpawnPositionPacket.class);
|
|
|
|
this.registerOutgoing(68, ServerUpdateTimePacket.class);
|
|
|
|
this.registerOutgoing(69, ServerTitlePacket.class);
|
|
|
|
this.registerOutgoing(70, ServerUpdateSignPacket.class);
|
2016-03-04 21:32:10 -05:00
|
|
|
this.registerOutgoing(71, ServerPlayBuiltinSoundPacket.class);
|
2016-03-03 21:32:08 -05:00
|
|
|
this.registerOutgoing(72, ServerPlayerListDataPacket.class);
|
|
|
|
this.registerOutgoing(73, ServerEntityCollectItemPacket.class);
|
|
|
|
this.registerOutgoing(74, ServerEntityTeleportPacket.class);
|
|
|
|
this.registerOutgoing(75, ServerEntityPropertiesPacket.class);
|
|
|
|
this.registerOutgoing(76, ServerEntityEffectPacket.class);
|
2015-07-20 14:01:13 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void initClientStatus(Session session) {
|
|
|
|
this.registerIncoming(0, StatusResponsePacket.class);
|
|
|
|
this.registerIncoming(1, StatusPongPacket.class);
|
|
|
|
|
|
|
|
this.registerOutgoing(0, StatusQueryPacket.class);
|
|
|
|
this.registerOutgoing(1, StatusPingPacket.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void initServerStatus(Session session) {
|
|
|
|
this.registerIncoming(0, StatusQueryPacket.class);
|
|
|
|
this.registerIncoming(1, StatusPingPacket.class);
|
|
|
|
|
|
|
|
this.registerOutgoing(0, StatusResponsePacket.class);
|
|
|
|
this.registerOutgoing(1, StatusPongPacket.class);
|
|
|
|
}
|
2013-12-14 19:40:30 -05:00
|
|
|
}
|