use of gg.projecteden.nexus.models.badge.BadgeUserService in project Nexus by ProjectEdenGG.
the class HandlePurchaseCommand method run.
@Path("<data...>")
void run(String data) {
Nexus.log("Purchase caught; processing... " + data);
String[] args = data.split("\\|");
Purchase purchase = Purchase.builder().id(UUID.randomUUID()).name(args[0]).uuid(UUID.fromString(uuidFormat(args[1]))).transactionId(args[2]).price(Double.parseDouble(args[3])).currency(args[4]).timestamp(LocalDateTime.parse(args[6] + " " + args[5], formatter)).email(args[7]).ip(args[8]).packageId(args[9]).packagePrice(Double.parseDouble(args[10])).packageExpiry(args[11]).packageName(args[12]).purchaserName(args[13]).purchaserUuid(UUID.fromString(uuidFormat(args[14]))).build();
String discordMessage = purchase.toDiscordString();
final ContributorService contributorService = new ContributorService();
final Contributor contributor = contributorService.get(purchase.getPurchaserUuid());
Package packageType = Package.getPackage(purchase.getPackageId());
if (packageType == null)
discordMessage += "\nPackage not recognized!";
else {
if (purchase.getPrice() > 0) {
send(purchase.getUuid(), PREFIX + "Thank you for buying &e" + purchase.getPackageName() + "&3! " + "Your contribution is &3&ogreatly &3appreciated and will be put to good use.");
if (contributor.isBroadcasts())
if (packageType == Package.CUSTOM_DONATION) {
Koda.say("Thank you for your custom donation, " + purchase.getNickname() + "! " + "We greatly appreciate your selfless contribution &4❤");
// this is not necessarily what they donated
// if they make a custom donation and purchase items at the same
// time, i have no way to break down the price from the payload
// but that is very rare, so its better than nothing i guess
contributor.giveCredit(purchase.getPrice());
} else
Koda.say("Thank you for your purchase, " + purchase.getNickname() + "! " + "Enjoy your " + purchase.getPackageName() + " perk!");
if (packageType.getCategory() == StoreCategory.BOOSTS)
send(purchase.getUuid(), PREFIX + "Make sure you activate your boost with &c/boost menu");
if (isV4Uuid(purchase.getPurchaserUuid())) {
new BadgeUserService().edit(purchase.getPurchaserUuid(), badgeUser -> badgeUser.give(Badge.SUPPORTER));
DiscordUser user = new DiscordUserService().get(purchase.getPurchaserUuid());
if (user.getUserId() != null)
Discord.addRole(user.getUserId(), Role.SUPPORTER);
else
discordMessage += "\nUser does not have a linked discord account";
}
} else {
send(purchase.getUuid(), PREFIX + "Your free " + purchase.getPackageName() + " has been successfully processed, enjoy!");
}
packageType.apply(purchase.getUuid());
discordMessage += "\nPurchase successfully processed.";
}
Discord.send(discordMessage, TextChannel.ADMIN_LOG);
contributor.add(purchase);
contributorService.save(contributor);
}
use of gg.projecteden.nexus.models.badge.BadgeUserService in project Nexus by ProjectEdenGG.
the class Nerd method getChatFormat.
public JsonBuilder getChatFormat(Chatter viewer) {
String prefix = getFullPrefix(viewer);
final ChatColor rankColor = isKoda() ? Koda.getChatColor() : getRank().getChatColor();
final JsonBuilder badge = new BadgeUserService().get(this).getBadgeJson(viewer);
return badge.next(prefix).next(rankColor + getNickname());
}
use of gg.projecteden.nexus.models.badge.BadgeUserService in project Nexus by ProjectEdenGG.
the class DiscordListener method onGuildMemberJoin.
@Override
public void onGuildMemberJoin(@Nonnull GuildMemberJoinEvent event) {
Tasks.async(() -> {
SettingService service = new SettingService();
Setting setting = service.get("discord", "lockdown");
if (setting.getBoolean())
event.getMember().kick("This discord is currently on lockdown mode").queue();
else {
Tasks.waitAsync(5, () -> {
Discord.addRole(event.getUser().getId(), Role.NERD);
DiscordUser user = new DiscordUserService().getFromUserId(event.getUser().getId());
if (user != null) {
Discord.addRole(event.getUser().getId(), Role.VERIFIED);
if (user.getRank() == Rank.VETERAN)
Discord.addRole(event.getUser().getId(), Role.VETERAN);
if (new BadgeUserService().get(user).owns(Badge.SUPPORTER))
Discord.addRole(event.getUser().getId(), Role.SUPPORTER);
user.updatePronouns(new NerdService().get(user).getPronouns());
}
});
}
});
}
Aggregations