Skip to content

Commit

Permalink
Less raw casting
Browse files Browse the repository at this point in the history
  • Loading branch information
Konicai committed Sep 29, 2023
1 parent f26ca36 commit 8d40fd0
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private boolean checkAndHandleLogin(Object packet) {
}

// we have to fake the offline player (login) cycle
if (!(networkManager.getPacketListener() instanceof ServerLoginPacketListenerImpl)) {
if (!(networkManager.getPacketListener() instanceof ServerLoginPacketListenerImpl packetListener)) {
// player is not in the login state, abort
ctx.pipeline().remove(this);
return true;
Expand All @@ -102,9 +102,9 @@ private boolean checkAndHandleLogin(Object packet) {
GameProfile gameProfile = new GameProfile(player.getCorrectUniqueId(), player.getCorrectUsername());

if (player.isLinked() && player.getCorrectUniqueId().version() == 4) {
verifyLinkedPlayerAsync(gameProfile);
verifyLinkedPlayerAsync(packetListener, gameProfile);
} else {
((ServerLoginPacketListenerImpl) networkManager.getPacketListener()).startClientVerification(gameProfile);
packetListener.startClientVerification(gameProfile);
}

ctx.pipeline().remove(this);
Expand All @@ -117,9 +117,10 @@ private boolean checkAndHandleLogin(Object packet) {
* Starts a new thread that fetches the linked player's textures,
* and then starts client verification with the more accurate game profile.
*
* @param packetListener the login packet listener for this connection
* @param gameProfile the player's initial profile. it will NOT be mutated.
*/
private void verifyLinkedPlayerAsync(GameProfile gameProfile) {
private void verifyLinkedPlayerAsync(ServerLoginPacketListenerImpl packetListener, GameProfile gameProfile) {
Thread texturesThread = new Thread("Bedrock Linked Player Texture Download") {
@Override
public void run() {
Expand All @@ -130,7 +131,7 @@ public void run() {
} catch (Exception e) {
LOGGER.error("Unable to get Bedrock linked player textures for " + effectiveProfile.getName(), e);
}
((ServerLoginPacketListenerImpl) networkManager.getPacketListener()).startClientVerification(effectiveProfile);
packetListener.startClientVerification(effectiveProfile);
}
};
texturesThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
Expand Down

0 comments on commit 8d40fd0

Please sign in to comment.