Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. public void handleEncryptionRequest(SPacketEncryptionRequest packetIn) {
  2. final SecretKey secretkey = CryptManager.createNewSharedKey();
  3. String s = packetIn.getServerId();
  4. PublicKey publickey = packetIn.getPublicKey();
  5. String s1 = (new BigInteger(CryptManager.getServerIdHash(s, publickey, secretkey))).toString(16);
  6.  
  7. if (this.mc.getCurrentServerData() != null && this.mc.getCurrentServerData().isOnLAN()) {
  8. try {
  9. this.getSessionService().joinServer(this.mc.getSession().getProfile(), this.mc.getSession().getToken(), s1);
  10. } catch (AuthenticationException var10) {
  11. LOGGER.warn("Couldn't connect to auth servers but will continue to join LAN");
  12. }
  13. } else {
  14. try {
  15. this.getSessionService().joinServer(this.mc.getSession().getProfile(), this.mc.getSession().getToken(), s1);
  16. } catch (AuthenticationUnavailableException var7) {
  17. this.networkManager.closeChannel(new TextComponentTranslation("disconnect.loginFailedInfo", new Object[]{new TextComponentTranslation("disconnect.loginFailedInfo.serversUnavailable", new Object[0])}));
  18. return;
  19. } catch (InvalidCredentialsException var8) {
  20. this.networkManager.closeChannel(new TextComponentTranslation("disconnect.loginFailedInfo", new Object[]{new TextComponentTranslation("disconnect.loginFailedInfo.invalidSession", new Object[0])}));
  21. return;
  22. } catch (AuthenticationException authenticationexception) {
  23. this.networkManager.closeChannel(new TextComponentTranslation("disconnect.loginFailedInfo", new Object[]{authenticationexception.getMessage()}));
  24. return;
  25. }
  26. }
  27.  
  28. this.networkManager.sendPacket(new CPacketEncryptionResponse(secretkey, publickey, packetIn.getVerifyToken()), new GenericFutureListener<Future<? super Void>>() {
  29. public void operationComplete(Future<? super Void> p_operationComplete_1_) throws Exception {
  30. NetHandlerLoginClient.this.networkManager.enableEncryption(secretkey);
  31. }
  32. });
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement