use of me.semx11.autotip.api.SessionKey in project Hyperium by HyperiumClient.
the class SessionManager method login.
public void login() {
Session session = autotip.getMinecraft().getSession();
GameProfile profile = session.getProfile();
String uuid = profile.getId().toString().replace("-", "");
String serverHash = HashUtil.hash(uuid + HashUtil.getNextSalt());
int statusCode = authenticate(session.getToken(), uuid, serverHash);
if (statusCode / 100 != 2) {
messageUtil.send("&cError {} during authentication: Session servers down?", statusCode);
return;
}
StatsRange all = autotip.getStatsManager().getAll();
LoginRequest request = LoginRequest.of(autotip, profile, serverHash, all.getTipsTotalInt());
long lastLogin = autotip.getEvent(EventClientConnection.class).getLastLogin();
long delay = lastLogin + 5000 - System.currentTimeMillis();
delay /= 1000;
reply = taskManager.scheduleAndAwait(request::execute, (delay < 1) ? 1 : delay);
if (reply == null || !reply.isSuccess()) {
messageUtil.send("&cError during login: {}", reply == null ? "null" : reply.getCause());
return;
}
sessionKey = reply.getSessionKey();
loggedIn = true;
long keepAlive = reply.getKeepAliveRate();
long tipWave = reply.getTipWaveRate();
taskManager.addRepeatingTask(TaskType.KEEP_ALIVE, this::keepAlive, keepAlive, keepAlive);
taskManager.addRepeatingTask(TaskType.TIP_WAVE, this::tipWave, 0, tipWave);
}
use of me.semx11.autotip.api.SessionKey in project Hyperium by HyperiumClient.
the class SessionManager method logout.
public void logout() {
if (!loggedIn)
return;
LogoutReply reply = LogoutRequest.of(sessionKey).execute();
if (!reply.isSuccess()) {
Autotip.LOGGER.warn("Error during logout: {}", reply.getCause());
}
loggedIn = false;
sessionKey = null;
taskManager.cancelTask(TaskType.KEEP_ALIVE);
tipQueue.clear();
}
Aggregations