use of me.semx11.autotip.api.SessionKey in project Hyperium by HyperiumClient.
the class SessionManager method tipWave.
private void tipWave() {
if (!onHypixel || !loggedIn) {
taskManager.cancelTask(TaskType.TIP_WAVE);
return;
}
lastTipWave = System.currentTimeMillis();
nextTipWave = System.currentTimeMillis() + reply.getTipWaveRate() * 1000;
TipReply r = TipRequest.of(sessionKey).execute();
if (r.isSuccess()) {
tipQueue.addAll(r.getTips());
Autotip.LOGGER.info("Current tip queue: {}", StringUtils.join(tipQueue.iterator(), ", "));
} else {
tipQueue.addAll(TipReply.getDefault().getTips());
Autotip.LOGGER.info("Failed to fetch tip queue, tipping 'all' instead.");
}
long tipCycle = reply.getTipCycleRate();
taskManager.addRepeatingTask(TaskType.TIP_CYCLE, this::tipCycle, 0, tipCycle);
}
use of me.semx11.autotip.api.SessionKey in project Hyperium by HyperiumClient.
the class KeepAliveRequest method execute.
@Override
public KeepAliveReply execute() {
HttpUriRequest request = GetBuilder.of(this).addParameter("key", sessionKey).build();
Optional<Reply> optional = RequestHandler.getReply(this, request.getURI());
return optional.map(reply -> (KeepAliveReply) reply).orElseGet(() -> new KeepAliveReply(false));
}
use of me.semx11.autotip.api.SessionKey in project Hyperium by HyperiumClient.
the class ErrorReport method reportException.
public static void reportException(Throwable t) {
Autotip.LOGGER.error(t.getMessage(), t);
HttpURLConnection conn = null;
try {
URL url = new URL("https://api.autotip.pro/error_report.php");
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
JsonObjectBuilder builder = JsonObjectBuilder.newBuilder().addString("username", autotip.getGameProfile().getName()).addString("uuid", autotip.getGameProfile().getId()).addString("v", autotip.getVersion()).addString("mc", autotip.getMcVersion()).addString("os", System.getProperty("os.name")).addString("forge", "hyperium").addString("stackTrace", ExceptionUtils.getStackTrace(t)).addNumber("time", System.currentTimeMillis());
if (autotip.isInitialized()) {
EventClientConnection event = autotip.getEvent(EventClientConnection.class);
builder.addString("sessionKey", autotip.getSessionManager().getKey()).addString("serverIp", event.getServerIp());
}
byte[] jsonBytes = builder.build().toString().getBytes(StandardCharsets.UTF_8);
conn.setFixedLengthStreamingMode(jsonBytes.length);
conn.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
conn.setRequestProperty("User-Agent", "Autotip v" + autotip.getVersion());
conn.connect();
try (OutputStream out = conn.getOutputStream()) {
out.write(jsonBytes);
}
InputStream input = conn.getResponseCode() < HttpURLConnection.HTTP_BAD_REQUEST ? conn.getInputStream() : conn.getErrorStream();
String json = IOUtils.toString(input, StandardCharsets.UTF_8);
Autotip.LOGGER.info("Error JSON: " + json);
input.close();
conn.disconnect();
} catch (IOException e) {
// Hmm... what would happen if I were to report this one?
e.printStackTrace();
} finally {
if (conn != null)
conn.disconnect();
}
}
use of me.semx11.autotip.api.SessionKey in project Hyperium by HyperiumClient.
the class LogoutRequest method execute.
@Override
public LogoutReply execute() {
HttpUriRequest request = GetBuilder.of(this).addParameter("key", sessionKey).build();
Optional<Reply> optional = RequestHandler.getReply(this, request.getURI());
return optional.map(reply -> (LogoutReply) reply).orElseGet(() -> new LogoutReply(false));
}
use of me.semx11.autotip.api.SessionKey in project Hyperium by HyperiumClient.
the class TipRequest method execute.
@Override
public TipReply execute() {
HttpUriRequest request = GetBuilder.of(this).addParameter("key", sessionKey).build();
Optional<Reply> optional = RequestHandler.getReply(this, request.getURI());
return optional.map(reply -> (TipReply) reply).orElseGet(TipReply::getDefault);
}
Aggregations