Fix PPC claims not properly updating in cust check UI
This commit is contained in:
parent
5bd7a2c89e
commit
674906c9bf
|
@ -111,14 +111,7 @@ public class BonusRepository extends RepositoryBase
|
||||||
|
|
||||||
if (!foundClient)
|
if (!foundClient)
|
||||||
{
|
{
|
||||||
_manager.runAsync(new Runnable()
|
UtilServer.runAsync(() -> executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null));
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return clientData;
|
return clientData;
|
||||||
|
|
|
@ -103,6 +103,8 @@ public class PowerPlayData
|
||||||
Set<YearMonth> unclaimedMonths = claimDates.stream()
|
Set<YearMonth> unclaimedMonths = claimDates.stream()
|
||||||
.filter(date -> date.isBefore(today) || date.equals(today)) // Filter dates yet to come
|
.filter(date -> date.isBefore(today) || date.equals(today)) // Filter dates yet to come
|
||||||
.map(YearMonth::from)
|
.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());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
return new PowerPlayData(subscriptions, nextClaimDate, unclaimedMonths, cosmeticMonths);
|
return new PowerPlayData(subscriptions, nextClaimDate, unclaimedMonths, cosmeticMonths);
|
||||||
|
|
|
@ -3,11 +3,14 @@ package mineplex.staffServer.ui.ppc;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
import java.time.format.TextStyle;
|
import java.time.format.TextStyle;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -49,12 +52,30 @@ public class SupportPowerplayPage extends SupportPage
|
||||||
return cal.getTimeInMillis();
|
return cal.getTimeInMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<YearMonth> getYearMonthRange(YearMonth start, int months) {
|
||||||
|
List<YearMonth> 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)
|
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());
|
PowerPlayData subData = PowerPlayData.fromSubsAndClaims(Collections.singletonList(subscription), Collections.emptyList());
|
||||||
|
|
||||||
LocalDate endDate = subscription._startDate.plusMonths(subscription._duration.getLength());
|
LocalDate endDate = subscription._startDate.plusMonths(subscription._duration.getLength());
|
||||||
|
|
||||||
|
List<YearMonth> relevantMonths = getYearMonthRange(YearMonth.from(subscription._startDate), subscription._duration.getLength());
|
||||||
|
|
||||||
|
Set<YearMonth> unclaimedMonths = getPowerPlayData().getUnclaimedMonths()
|
||||||
|
.stream()
|
||||||
|
.filter(relevantMonths::contains)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
ItemBuilder builder = new ItemBuilder(subData.isSubscribed() ? Material.GOLD_BLOCK : Material.IRON_BLOCK)
|
ItemBuilder builder = new ItemBuilder(subData.isSubscribed() ? Material.GOLD_BLOCK : Material.IRON_BLOCK)
|
||||||
.setTitle(C.cGreenB + subscription._duration.getName() + "ly Subscription")
|
.setTitle(C.cGreenB + subscription._duration.getName() + "ly Subscription")
|
||||||
.addLore("")
|
.addLore("")
|
||||||
|
@ -75,13 +96,19 @@ public class SupportPowerplayPage extends SupportPage
|
||||||
|
|
||||||
builder.addLore("");
|
builder.addLore("");
|
||||||
|
|
||||||
if (subData.getUnclaimedMonths().isEmpty())
|
if (unclaimedMonths.isEmpty())
|
||||||
{
|
{
|
||||||
builder.addLore(C.cAqua + "All current rewards claimed");
|
builder.addLore(C.cAqua + "All current rewards claimed");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
builder.addLore(C.cRedB + "Unclaimed rewards");
|
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.AMPLIFIERS_PER_MONTH * subData.getUnclaimedMonths().size()) + " Game Amplifier");
|
||||||
builder.addLore(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * subData.getUnclaimedMonths().size()) + " Omega Chest");
|
builder.addLore(" " + C.cWhite + (PowerPlayClubRewards.CHESTS_PER_MONTH * subData.getUnclaimedMonths().size()) + " Omega Chest");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue