use of me.semx11.autotip.stats.StatsRange in project Hyperium by HyperiumClient.
the class Stats method print.
public void print() {
MessageUtil messageUtil = autotip.getMessageUtil();
messageUtil.separator();
gameStatistics.entrySet().stream().sorted(Map.Entry.<String, Coins>comparingByValue().reversed()).forEach(entry -> {
String game = entry.getKey();
Coins coins = entry.getValue();
messageUtil.getKeyHelper("command.stats").withKey("coins", context -> context.getBuilder(game, coins.getTotal()).setHover(context.getKey("coinsHover"), game, coins.getSent(), coins.getReceived()).send());
});
messageUtil.getKeyHelper("command.stats").withKey("tips", context -> context.getBuilder(getTipsTotal()).setHover(context.getKey("tipsHover"), getTipsSent(), getTipsReceived()).send()).withKey("xp", context -> context.getBuilder(getXpTotal()).setHover(context.getKey("xpHover"), getXpSent(), getXpReceived()).send());
if (this instanceof StatsDaily) {
messageUtil.sendKey("command.stats.date", ((StatsDaily) this).getDateString());
} else if (this instanceof StatsRange) {
StatsRange range = (StatsRange) this;
messageUtil.sendKey("command.stats.dateRange", range.getStartString(), range.getEndString());
}
messageUtil.separator();
}
use of me.semx11.autotip.stats.StatsRange in project Hyperium by HyperiumClient.
the class StatsManager method getRange.
/**
* Get the {@link StatsRange} for the specified date range. This method uses {@link
* #get(LocalDate)} to get all the {@link StatsDaily} that are contained within this range.
*
* @param start The starting {@link LocalDate}
* @param end The ending {@link LocalDate}
* @return {@link StatsRange} for the specified date range
*/
public StatsRange getRange(LocalDate start, LocalDate end) {
if (start.isBefore(fileUtil.getFirstDate()))
start = fileUtil.getFirstDate();
if (end.isAfter(LocalDate.now()))
end = LocalDate.now();
StatsRange range = new StatsRange(autotip, start, end);
Stream.iterate(start, date -> date.plusDays(1)).limit(ChronoUnit.DAYS.between(start, end) + 1).forEach(date -> range.merge(get(date)));
return range;
}
use of me.semx11.autotip.stats.StatsRange 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);
}
Aggregations