use of gg.projecteden.nexus.models.store.ContributorService 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.store.ContributorService in project Nexus by ProjectEdenGG.
the class BankCommand method wallet.
@Path("[player]")
@Description("Displays all currencies owned by the player")
void wallet(@Arg("self") Nerd nerd) {
send(PREFIX + "&e" + nerd.getNickname() + "&3's Wallet: ");
// Store Credit
Contributor contributor = new ContributorService().get(nerd);
send("&3Store Credit: &e" + contributor.getCreditFormatted());
// Vote Points
Voter voter = new VoterService().get(nerd);
send("&3Vote Points: &e" + voter.getPoints());
// Event Store
EventUser eventUser = new EventUserService().get(nerd);
send("&3Event Tokens: &e" + eventUser.getTokens());
// Minigames
PerkOwner perkOwner = new PerkOwnerService().get(nerd);
send("&3Minigame Tokens: &e" + perkOwner.getTokens());
// Economy
send("&3Economy Balances: &e");
Banker banker = new BankerService().get(nerd);
Map<ShopGroup, BigDecimal> balances = banker.getBalances();
for (ShopGroup shopGroup : balances.keySet()) {
String name = StringUtils.camelCase(shopGroup);
String bal = banker.getBalanceFormatted(shopGroup);
send("&3 - " + name + ": &e" + bal);
}
line();
}
Aggregations