Search in sources :

Example 1 with EventUser

use of gg.projecteden.nexus.models.eventuser.EventUser in project Nexus by ProjectEdenGG.

the class Pugmas20 method checkDailyTokens.

public static int checkDailyTokens(HasUniqueId player, String id, int amount) {
    EventUserService service = new EventUserService();
    EventUser user = service.get(player);
    return user.getDailyTokensLeft(("pugmas20_" + id).toLowerCase(), amount, tokenMaxes);
}
Also used : EventUser(gg.projecteden.nexus.models.eventuser.EventUser) EventUserService(gg.projecteden.nexus.models.eventuser.EventUserService)

Example 2 with EventUser

use of gg.projecteden.nexus.models.eventuser.EventUser in project Nexus by ProjectEdenGG.

the class BearFair21StatsCommand method stats.

@Path
void stats() {
    List<BearFair21User> users = userService.getAll();
    EventUserService eventUserService = new EventUserService();
    List<EventUser> eventUsers = eventUserService.getAll();
    // Total time played
    // % of time spent at bf vs other worlds
    // % of people who logged in that visited bf
    // % of playtime per world during bf
    send("&6&lUnique visitors: &e" + users.stream().filter(bearFair21User -> !bearFair21User.isFirstVisit()).count());
    line();
    send("&6&lQuest Stages");
    send(json("- Main").hover(getQuestStages(users, BearFair21UserQuestStageHelper.MAIN)));
    send(json("  - LumberJack").hover(getQuestStages(users, BearFair21UserQuestStageHelper.LUMBERJACK)));
    send(json("  - BeeKeeper").hover(getQuestStages(users, BearFair21UserQuestStageHelper.BEEKEEPER)));
    send(json("  - Recycler").hover(getQuestStages(users, BearFair21UserQuestStageHelper.RECYCLER)));
    send(json("- Minigame Night").hover(getQuestStages(users, BearFair21UserQuestStageHelper.MINIGAME_NIGHT)));
    send(json("- Pugmas").hover(getQuestStages(users, BearFair21UserQuestStageHelper.PUGMAS)));
    send(json("- Halloween").hover(getQuestStages(users, BearFair21UserQuestStageHelper.HALLOWEEN)));
    send(json("- Summer Down Under").hover(getQuestStages(users, BearFair21UserQuestStageHelper.SUMMER_DOWN_UNDER)));
    line();
    send("&6&lEvent Participation");
    for (String event : eventParticipation.keySet()) send(" - " + event + ": " + eventParticipation.get(event).size());
    line();
    send("&6&lDaily Points");
    for (Day day : Day.values()) send(json(" - Day " + (day.ordinal() + 1)).hover(getCompletedSources(eventUsers, day)));
    line();
    send("&6&lTreasure Chests");
    Map<Integer, Integer> data = getTreasureChestData(users);
    send(json("- Found all: " + data.get(20)));
    send(json("- Found some: " + getFoundSomeTreasureChests(data)).hover(getTreasureChestStats(data)));
    send(json("- Found none: " + data.get(0)));
}
Also used : Path(gg.projecteden.nexus.framework.commands.models.annotations.Path) StringUtils(gg.projecteden.nexus.utils.StringUtils) Getter(lombok.Getter) BearFair21(gg.projecteden.nexus.features.events.y2021.bearfair21.BearFair21) CustomCommand(gg.projecteden.nexus.framework.commands.models.CustomCommand) EventUserService(gg.projecteden.nexus.models.eventuser.EventUserService) HashMap(java.util.HashMap) BearFair21User(gg.projecteden.nexus.models.bearfair21.BearFair21User) ArrayList(java.util.ArrayList) Aliases(gg.projecteden.nexus.framework.commands.models.annotations.Aliases) List(java.util.List) BearFair21UserService(gg.projecteden.nexus.models.bearfair21.BearFair21UserService) EventUser(gg.projecteden.nexus.models.eventuser.EventUser) QuestStage(gg.projecteden.nexus.features.events.models.QuestStage) CommandEvent(gg.projecteden.nexus.framework.commands.models.events.CommandEvent) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BF21PointSource(gg.projecteden.nexus.features.events.y2021.bearfair21.BearFair21.BF21PointSource) BearFair21UserQuestStageHelper(gg.projecteden.nexus.features.events.y2021.bearfair21.commands.BearFair21Command.BearFair21UserQuestStageHelper) LocalDate(java.time.LocalDate) Map(java.util.Map) Utils(gg.projecteden.utils.Utils) AllArgsConstructor(lombok.AllArgsConstructor) NotNull(org.jetbrains.annotations.NotNull) Comparator(java.util.Comparator) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) EventUser(gg.projecteden.nexus.models.eventuser.EventUser) BearFair21User(gg.projecteden.nexus.models.bearfair21.BearFair21User) EventUserService(gg.projecteden.nexus.models.eventuser.EventUserService) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 3 with EventUser

use of gg.projecteden.nexus.models.eventuser.EventUser in project Nexus by ProjectEdenGG.

the class EventsCommand method tokens_pay.

/* TODO
	@Path("tokens daily [player]")
	void tokensDaily(@Arg("self") EventUser user) {
		if (isSelf(user))
			send(PREFIX + "&3Daily tokens:");
		else
			send(PREFIX + "&3" + user.getOfflinePlayer().getName() + "'s Daily tokens:");

		for (BFtokensource tokensource : BFtokensource.values()) {
			Map<LocalDate, Integer> dailyMap = user.getTokensReceivedToday().get(tokensource);
			int tokens = 0;
			if (dailyMap != null)
				tokens = dailyMap.getOrDefault(LocalDate.now(), 0);

			int dailyMax = EventUser.DAILY_SOURCE_MAX;
			String sourceColor = tokens == dailyMax ? "&a" : "&3";
			String sourceName = StringUtils.camelCase(tokensource.name());
			send(" " + sourceColor + sourceName + " &7- &e" + tokens + "&3/&e" + dailyMax);
		}
	}
	*/
@Path("tokens pay <player> <tokens>")
void tokens_pay(EventUser toUser, int tokens) {
    EventUser fromUser = service.get(player());
    if (isSelf(toUser))
        error("You cannot pay yourself");
    fromUser.takeTokens(tokens);
    toUser.giveTokens(tokens);
    fromUser.sendMessage(PREFIX + "&e" + tokens + " event tokens &3have been sent to &e" + toUser.getNickname());
    toUser.sendMessage(PREFIX + "&e" + tokens + " event tokens &3have been received from &e" + fromUser.getNickname());
    service.save(fromUser);
    service.save(toUser);
}
Also used : EventUser(gg.projecteden.nexus.models.eventuser.EventUser) Path(gg.projecteden.nexus.framework.commands.models.annotations.Path)

Example 4 with EventUser

use of gg.projecteden.nexus.models.eventuser.EventUser in project Nexus by ProjectEdenGG.

the class BuyFlagsMenu method purchase.

private void purchase(Flags flag, Player player, boolean bunting) {
    ItemStack item = bunting ? flag.getBunting() : flag.getFlag();
    Pride21User user = service.get(player);
    EventUser eventUser = eventService.get(player);
    if (user.claimReward()) {
    /* this method removes tokens and saves for us so we don't need to do anything here */
    } else if (eventUser.getTokens() >= COST) {
        eventUser.takeTokens(COST);
        eventService.save(eventUser);
    } else {
        player.sendMessage(JsonBuilder.fromPrefix(Pride21.PREFIX).next("&cYou don't have enough event tokens to purchase this item"));
        new SoundBuilder(Sound.ENTITY_VILLAGER_NO).receiver(player).category(SoundCategory.VOICE).volume(0.8f).play();
        return;
    }
    PlayerUtils.giveItemAndMailExcess(player, item, "Pride 2021 Purchase", WorldGroup.SURVIVAL);
    open(player);
}
Also used : SoundBuilder(gg.projecteden.nexus.utils.SoundBuilder) Pride21User(gg.projecteden.nexus.models.pride21.Pride21User) EventUser(gg.projecteden.nexus.models.eventuser.EventUser) ItemStack(org.bukkit.inventory.ItemStack)

Example 5 with EventUser

use of gg.projecteden.nexus.models.eventuser.EventUser 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

EventUser (gg.projecteden.nexus.models.eventuser.EventUser)9 EventUserService (gg.projecteden.nexus.models.eventuser.EventUserService)6 Path (gg.projecteden.nexus.framework.commands.models.annotations.Path)3 BF21PointSource (gg.projecteden.nexus.features.events.y2021.bearfair21.BearFair21.BF21PointSource)2 Pride21User (gg.projecteden.nexus.models.pride21.Pride21User)2 SoundBuilder (gg.projecteden.nexus.utils.SoundBuilder)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Player (org.bukkit.entity.Player)2 EventHandler (org.bukkit.event.EventHandler)2 ItemStack (org.bukkit.inventory.ItemStack)2 ProtectedRegion (com.sk89q.worldguard.protection.regions.ProtectedRegion)1 QuestStage (gg.projecteden.nexus.features.events.models.QuestStage)1 BearFair21 (gg.projecteden.nexus.features.events.y2021.bearfair21.BearFair21)1 BearFair21UserQuestStageHelper (gg.projecteden.nexus.features.events.y2021.bearfair21.commands.BearFair21Command.BearFair21UserQuestStageHelper)1 CustomCommand (gg.projecteden.nexus.framework.commands.models.CustomCommand)1 Aliases (gg.projecteden.nexus.framework.commands.models.annotations.Aliases)1 Description (gg.projecteden.nexus.framework.commands.models.annotations.Description)1 CommandEvent (gg.projecteden.nexus.framework.commands.models.events.CommandEvent)1