use of gg.projecteden.nexus.models.perkowner.PerkOwner in project Nexus by ProjectEdenGG.
the class MinigamesCommand method getTokens.
@Path("tokens [user]")
void getTokens(@Arg("self") Nerd nerd) {
PerkOwnerService service = new PerkOwnerService();
PerkOwner perkOwner = service.get(nerd);
String username = nerd.getUuid().equals(player().getUniqueId()) ? "You have" : (perkOwner.getNickname() + " has");
send(PREFIX + username + " " + perkOwner.getTokens() + plural(" token", perkOwner.getTokens()));
}
use of gg.projecteden.nexus.models.perkowner.PerkOwner in project Nexus by ProjectEdenGG.
the class BuyPerksMenu method init.
@Override
public void init(Player player, InventoryContents contents) {
addBackItem(contents, $ -> new CategoryMenu<>(getClass()).open(player));
PerkOwner perkOwner = service.get(player);
contents.set(0, 8, ClickableItem.empty(new ItemBuilder(Material.EMERALD).name("&2&lBalance").lore("&f" + FORMATTER.format(perkOwner.getTokens()) + plural(" token", perkOwner.getTokens())).build()));
// get perks and sort them
List<PerkSortWrapper> perkSortWrappers = new ArrayList<>();
PerkType.getByCategory(category).forEach(perkType -> perkSortWrappers.add(PerkSortWrapper.of(perkOwner, perkType)));
perkSortWrappers.sort(Comparator.comparing(PerkSortWrapper::isOwned).thenComparing(PerkSortWrapper::getPrice).thenComparing(PerkSortWrapper::getName));
List<PerkType> perks = perkSortWrappers.stream().map(PerkSortWrapper::getPerkType).collect(Collectors.toList());
// create the items
List<ClickableItem> clickableItems = new ArrayList<>();
perks.forEach(perkType -> {
Perk perk = perkType.getPerk();
boolean userOwned = perkOwner.getPurchasedPerks().containsKey(perkType);
List<String> lore = getLore(player, perk);
lore.add(1, userOwned ? "&cPurchased" : ("&aPurchase for &e" + perk.getPrice() + "&a " + plural("token", perk.getPrice())));
if (lore.size() > 2)
lore.add(2, "");
ItemStack item = getItem(perk, lore);
clickableItems.add(ClickableItem.from(item, e -> buyItem(player, perkType, contents)));
});
paginator(player, contents, clickableItems);
}
use of gg.projecteden.nexus.models.perkowner.PerkOwner in project Nexus by ProjectEdenGG.
the class BuyPerksMenu method buyItem.
protected void buyItem(Player player, PerkType perkType, InventoryContents contents) {
Perk perk = perkType.getPerk();
PerkOwner perkOwner = service.get(player);
if (perkOwner.getPurchasedPerks().containsKey(perkType))
error(player, "You already own that item");
else if (perkOwner.purchase(perkType)) {
send(player, "You purchased the &e" + perk.getName() + "&3 collectible for &e" + perk.getPrice() + plural(" token", perk.getPrice()));
open(player, contents.pagination().getPage());
} else
error(player, "You don't have enough tokens to purchase that");
}
use of gg.projecteden.nexus.models.perkowner.PerkOwner in project Nexus by ProjectEdenGG.
the class PlayerPerksMenu method toggleBoolean.
protected void toggleBoolean(Player player, PerkType perkType, InventoryContents contents) {
PerkOwner perkOwner = service.get(player);
perkOwner.toggle(perkType);
open(player, contents.pagination().getPage());
}
use of gg.projecteden.nexus.models.perkowner.PerkOwner 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