mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Fix user verification.
This commit is contained in:
parent
aff6600deb
commit
6cc87bcbdb
1 changed files with 27 additions and 26 deletions
|
@ -1,8 +1,8 @@
|
|||
package org.spacehq.mc.protocol;
|
||||
|
||||
import org.spacehq.mc.auth.data.GameProfile;
|
||||
import org.spacehq.mc.auth.exception.request.RequestException;
|
||||
import org.spacehq.mc.auth.service.SessionService;
|
||||
import org.spacehq.mc.auth.exception.request.ServiceUnavailableException;
|
||||
import org.spacehq.mc.protocol.data.SubProtocol;
|
||||
import org.spacehq.mc.protocol.data.status.ServerStatusInfo;
|
||||
import org.spacehq.mc.protocol.data.status.handler.ServerInfoBuilder;
|
||||
|
@ -120,6 +120,7 @@ public class ServerListener extends SessionAdapter {
|
|||
ServerInfoBuilder builder = event.getSession().getFlag(MinecraftConstants.SERVER_INFO_BUILDER_KEY);
|
||||
if(builder == null) {
|
||||
event.getSession().disconnect("No server info builder set.");
|
||||
return;
|
||||
}
|
||||
|
||||
ServerStatusInfo info = builder.buildInfo(event.getSession());
|
||||
|
@ -161,23 +162,26 @@ public class ServerListener extends SessionAdapter {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
MinecraftProtocol protocol = (MinecraftProtocol) this.session.getPacketProtocol();
|
||||
try {
|
||||
Proxy proxy = this.session.<Proxy>getFlag(MinecraftConstants.AUTH_PROXY_KEY);
|
||||
if(proxy == null) {
|
||||
proxy = Proxy.NO_PROXY;
|
||||
}
|
||||
|
||||
String serverHash = new BigInteger(CryptUtil.getServerIdHash(serverId, pair.getPublic(), this.key)).toString(16);
|
||||
SessionService service = new SessionService(proxy);
|
||||
GameProfile profile = service.getProfileByServer(username, serverHash);
|
||||
GameProfile profile = null;
|
||||
try {
|
||||
profile = new SessionService(proxy).getProfileByServer(username, new BigInteger(CryptUtil.getServerIdHash(serverId, pair.getPublic(), this.key)).toString(16));
|
||||
} catch(RequestException e) {
|
||||
this.session.disconnect("Failed to make session service request.", e);
|
||||
return;
|
||||
}
|
||||
|
||||
if(profile != null) {
|
||||
int threshold = this.session.getFlag(MinecraftConstants.SERVER_COMPRESSION_THRESHOLD);
|
||||
this.session.send(new LoginSetCompressionPacket(threshold));
|
||||
this.session.setCompressionThreshold(threshold);
|
||||
this.session.send(new LoginSuccessPacket(profile));
|
||||
this.session.setFlag(MinecraftConstants.PROFILE_KEY, profile);
|
||||
protocol.setSubProtocol(SubProtocol.GAME, false, this.session);
|
||||
((MinecraftProtocol) this.session.getPacketProtocol()).setSubProtocol(SubProtocol.GAME, false, this.session);
|
||||
ServerLoginHandler handler = this.session.getFlag(MinecraftConstants.SERVER_LOGIN_HANDLER_KEY);
|
||||
if(handler != null) {
|
||||
handler.loggedIn(this.session);
|
||||
|
@ -185,10 +189,7 @@ public class ServerListener extends SessionAdapter {
|
|||
|
||||
new Thread(new KeepAlive(this.session)).start();
|
||||
} else {
|
||||
this.session.disconnect("Failed to verify username!");
|
||||
}
|
||||
} catch(ServiceUnavailableException e) {
|
||||
this.session.disconnect("Authentication servers are down. Please try again later, sorry!");
|
||||
this.session.disconnect("Failed to verify username.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue