Search in sources :

Example 1 with Origin

use of gg.projecteden.nexus.models.referral.Referral.Origin in project Nexus by ProjectEdenGG.

the class ReferralCommand method run.

@Path
void run() {
    JsonBuilder json = json();
    for (Origin origin : Origin.values()) json.next("&3" + origin.getDisplay()).hover("&e" + origin.getLink()).command("/referral choose " + origin.name().toLowerCase()).group().newline();
    new WrittenBookMenu().addPage(json).open(player());
}
Also used : JsonBuilder(gg.projecteden.nexus.utils.JsonBuilder) Origin(gg.projecteden.nexus.models.referral.Referral.Origin) WrittenBookMenu(gg.projecteden.nexus.features.menus.BookBuilder.WrittenBookMenu) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 2 with Origin

use of gg.projecteden.nexus.models.referral.Referral.Origin in project Nexus by ProjectEdenGG.

the class ReferralCommand method stats.

@Async
@Path("stats")
void stats() {
    List<Referral> referrals = service.getAll();
    if (referrals.isEmpty())
        error("No referral stats available");
    Map<Origin, Integer> manuals = new HashMap<>();
    Map<String, Integer> ips = new HashMap<>();
    for (Referral referral : referrals) {
        if (referral.getOrigin() != null)
            manuals.put(referral.getOrigin(), manuals.getOrDefault(referral.getOrigin(), 0) + 1);
        if (referral.getIp() != null) {
            final String site = getSite(referral.getIp());
            ips.put(site, ips.getOrDefault(site, 0) + 1);
        }
    }
    line();
    send(PREFIX + "Stats:");
    send(" &3Manual input:");
    sortByValueReverse(manuals).forEach((origin, count) -> send("&7  " + count + " - &e" + origin.getDisplay()));
    line();
    send(" &3IPs:");
    sortByValueReverse(ips).forEach((ip, count) -> send("&7  " + count + " - &e" + ip));
}
Also used : Origin(gg.projecteden.nexus.models.referral.Referral.Origin) Referral(gg.projecteden.nexus.models.referral.Referral) HashMap(java.util.HashMap) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Async(gg.projecteden.annotations.Async)

Aggregations

Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)2 Origin (gg.projecteden.nexus.models.referral.Referral.Origin)2 Async (gg.projecteden.annotations.Async)1 WrittenBookMenu (gg.projecteden.nexus.features.menus.BookBuilder.WrittenBookMenu)1 Referral (gg.projecteden.nexus.models.referral.Referral)1 JsonBuilder (gg.projecteden.nexus.utils.JsonBuilder)1 HashMap (java.util.HashMap)1