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());
}
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));
}
Aggregations