diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java index d346bf8cb..e3debbc12 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusRepository.java @@ -111,14 +111,7 @@ public class BonusRepository extends RepositoryBase if (!foundClient) { - _manager.runAsync(new Runnable() - { - @Override - public void run() - { - executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null); - } - }); + UtilServer.runAsync(() -> executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null)); } return clientData; diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java index fd1b36deb..3be6ae53a 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayData.java @@ -103,6 +103,8 @@ public class PowerPlayData Set unclaimedMonths = claimDates.stream() .filter(date -> date.isBefore(today) || date.equals(today)) // Filter dates yet to come .map(YearMonth::from) + // Only months that have not been claimed or are before the newest claim can be considered unclaimed + .filter(ym -> !(claimedMonths.contains(ym) || (latestClaimed.isPresent() && latestClaimed.get().isAfter(ym)))) .collect(Collectors.toSet()); return new PowerPlayData(subscriptions, nextClaimDate, unclaimedMonths, cosmeticMonths); diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/ppc/SupportPowerplayPage.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/ppc/SupportPowerplayPage.java index 7ab905b2e..56c90fa87 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/ppc/SupportPowerplayPage.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/ui/ppc/SupportPowerplayPage.java @@ -3,11 +3,14 @@ package mineplex.staffServer.ui.ppc; import java.time.LocalDate; import java.time.YearMonth; import java.time.format.TextStyle; +import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Locale; +import java.util.Set; +import java.util.stream.Collectors; import org.bukkit.Material; import org.bukkit.entity.Player; @@ -49,12 +52,30 @@ public class SupportPowerplayPage extends SupportPage return cal.getTimeInMillis(); } + List getYearMonthRange(YearMonth start, int months) { + List range = new ArrayList<>(); + + for (int i = 0; i < months; i++) { + range.add(start.plusMonths(i)); + } + + return range; + } + public void buildPowerPlayItem(PowerPlayData.Subscription subscription, int slot) { + // We don't care about the claims since they are generated below PowerPlayData subData = PowerPlayData.fromSubsAndClaims(Collections.singletonList(subscription), Collections.emptyList()); LocalDate endDate = subscription._startDate.plusMonths(subscription._duration.getLength()); + List relevantMonths = getYearMonthRange(YearMonth.from(subscription._startDate), subscription._duration.getLength()); + + Set unclaimedMonths = getPowerPlayData().getUnclaimedMonths() + .stream() + .filter(relevantMonths::contains) + .collect(Collectors.toSet()); + ItemBuilder builder = new ItemBuilder(subData.isSubscribed() ? Material.GOLD_BLOCK : Material.IRON_BLOCK) .setTitle(C.cGreenB + subscription._duration.getName() + "ly Subscription") .addLore("") @@ -75,13 +96,19 @@ public class SupportPowerplayPage extends SupportPage builder.addLore(""); - if (subData.getUnclaimedMonths().isEmpty()) + if (unclaimedMonths.isEmpty()) { builder.addLore(C.cAqua + "All current rewards claimed"); } else { builder.addLore(C.cRedB + "Unclaimed rewards"); + builder.addLore(" " + C.cWhite + "Cosmetics: " + C.cYellow + String.join(", ", + unclaimedMonths + .stream() + .map(ym -> ym.getMonthValue() + "/" + ym.getYear()) + .collect(Collectors.toList()) + )); builder.addLore(" " + C.cWhite + (PowerPlayClubRewards.AMPLIFIERS_PER_MONTH * subData.getUnclaimedMonths().size()) + " Game Amplifier"); builder.addLore(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * subData.getUnclaimedMonths().size()) + " Omega Chest"); }