Search in sources :

Example 1 with TipReply

use of me.semx11.autotip.api.reply.impl.TipReply 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);
}
Also used : TipReply(me.semx11.autotip.api.reply.impl.TipReply)

Example 2 with TipReply

use of me.semx11.autotip.api.reply.impl.TipReply 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);
}
Also used : HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) RequestHandler(me.semx11.autotip.api.RequestHandler) SessionKey(me.semx11.autotip.api.SessionKey) TipReply(me.semx11.autotip.api.reply.impl.TipReply) RequestType(me.semx11.autotip.api.RequestType) GetBuilder(me.semx11.autotip.api.GetBuilder) Reply(me.semx11.autotip.api.reply.Reply) Optional(java.util.Optional) HttpUriRequest(org.apache.http.client.methods.HttpUriRequest) Request(me.semx11.autotip.api.request.Request) TipReply(me.semx11.autotip.api.reply.impl.TipReply) Reply(me.semx11.autotip.api.reply.Reply) TipReply(me.semx11.autotip.api.reply.impl.TipReply)

Aggregations

TipReply (me.semx11.autotip.api.reply.impl.TipReply)2 Optional (java.util.Optional)1 GetBuilder (me.semx11.autotip.api.GetBuilder)1 RequestHandler (me.semx11.autotip.api.RequestHandler)1 RequestType (me.semx11.autotip.api.RequestType)1 SessionKey (me.semx11.autotip.api.SessionKey)1 Reply (me.semx11.autotip.api.reply.Reply)1 Request (me.semx11.autotip.api.request.Request)1 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)1