Search in sources :

Example 1 with PerkOwner

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()));
}
Also used : PerkOwner(gg.projecteden.nexus.models.perkowner.PerkOwner) PerkOwnerService(gg.projecteden.nexus.models.perkowner.PerkOwnerService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 2 with PerkOwner

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);
}
Also used : ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) StringUtils.plural(gg.projecteden.nexus.utils.StringUtils.plural) SoundCategory(org.bukkit.SoundCategory) SmartInventory(fr.minuskube.inv.SmartInventory) DecimalFormat(java.text.DecimalFormat) Sound(org.bukkit.Sound) Player(org.bukkit.entity.Player) Perk(gg.projecteden.nexus.features.minigames.models.perks.Perk) Collectors(java.util.stream.Collectors) PerkCategory(gg.projecteden.nexus.features.minigames.models.perks.PerkCategory) SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) List(java.util.List) InventoryProvider(fr.minuskube.inv.content.InventoryProvider) InventoryContents(fr.minuskube.inv.content.InventoryContents) PerkType(gg.projecteden.nexus.features.minigames.models.perks.PerkType) Comparator(java.util.Comparator) PerkOwner(gg.projecteden.nexus.models.perkowner.PerkOwner) Material(org.bukkit.Material) ClickableItem(fr.minuskube.inv.ClickableItem) PerkOwner(gg.projecteden.nexus.models.perkowner.PerkOwner) ArrayList(java.util.ArrayList) ClickableItem(fr.minuskube.inv.ClickableItem) Perk(gg.projecteden.nexus.features.minigames.models.perks.Perk) PerkType(gg.projecteden.nexus.features.minigames.models.perks.PerkType) ItemBuilder(gg.projecteden.nexus.utils.ItemBuilder) ItemStack(org.bukkit.inventory.ItemStack)

Example 3 with PerkOwner

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");
}
Also used : PerkOwner(gg.projecteden.nexus.models.perkowner.PerkOwner) Perk(gg.projecteden.nexus.features.minigames.models.perks.Perk)

Example 4 with PerkOwner

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());
}
Also used : PerkOwner(gg.projecteden.nexus.models.perkowner.PerkOwner)

Example 5 with PerkOwner

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();
}
Also used : PerkOwner(gg.projecteden.nexus.models.perkowner.PerkOwner) Banker(gg.projecteden.nexus.models.banker.Banker) Contributor(gg.projecteden.nexus.models.store.Contributor) VoterService(gg.projecteden.nexus.models.voter.VoterService) BigDecimal(java.math.BigDecimal) PerkOwnerService(gg.projecteden.nexus.models.perkowner.PerkOwnerService) ShopGroup(gg.projecteden.nexus.models.shop.Shop.ShopGroup) ContributorService(gg.projecteden.nexus.models.store.ContributorService) EventUser(gg.projecteden.nexus.models.eventuser.EventUser) Voter(gg.projecteden.nexus.models.voter.Voter) BankerService(gg.projecteden.nexus.models.banker.BankerService) EventUserService(gg.projecteden.nexus.models.eventuser.EventUserService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) Description(gg.projecteden.nexus.framework.commands.models.annotations.Description)

Aggregations

PerkOwner (gg.projecteden.nexus.models.perkowner.PerkOwner)15 PerkOwnerService (gg.projecteden.nexus.models.perkowner.PerkOwnerService)10 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)5 ClickableItem (fr.minuskube.inv.ClickableItem)4 SmartInventory (fr.minuskube.inv.SmartInventory)3 InventoryContents (fr.minuskube.inv.content.InventoryContents)3 InventoryProvider (fr.minuskube.inv.content.InventoryProvider)3 Perk (gg.projecteden.nexus.features.minigames.models.perks.Perk)3 PerkCategory (gg.projecteden.nexus.features.minigames.models.perks.PerkCategory)3 PerkType (gg.projecteden.nexus.features.minigames.models.perks.PerkType)3 ItemBuilder (gg.projecteden.nexus.utils.ItemBuilder)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Collectors (java.util.stream.Collectors)3 Player (org.bukkit.entity.Player)3 ParticleBuilder (com.destroystokyo.paper.ParticleBuilder)2 Permission (gg.projecteden.nexus.framework.commands.models.annotations.Permission)2 Named (gg.projecteden.interfaces.Named)1 Nicknamed (gg.projecteden.interfaces.Nicknamed)1 MenuUtils (gg.projecteden.nexus.features.menus.MenuUtils)1