From e867a09b5cc02eb988ade6af3e56a947368d697a Mon Sep 17 00:00:00 2001 From: cnr Date: Fri, 30 Sep 2016 21:52:07 -0700 Subject: [PATCH] Update support server to accommodate power play changes --- .../core/powerplayclub/PowerPlayClubRepository.java | 13 +++++++------ .../customerSupport/CustomerSupport.java | 7 +++++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java index 218b37d1c..de013f635 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/powerplayclub/PowerPlayClubRepository.java @@ -137,13 +137,16 @@ public class PowerPlayClubRepository implements Listener { public CompletableFuture loadData(Player player) { - return loadSubscriptions(player).thenCombine(loadClaimMonths(player), PowerPlayData::fromSubsAndClaims); + return loadData(_clientManager.Get(player).getAccountId()); } - public CompletableFuture> loadClaimMonths(Player player) + public CompletableFuture loadData(int accountId) { - int accountId = _clientManager.Get(player).getAccountId(); + return loadSubscriptions(accountId).thenCombine(loadClaimMonths(accountId), PowerPlayData::fromSubsAndClaims); + } + public CompletableFuture> loadClaimMonths(int accountId) + { return CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) @@ -166,10 +169,8 @@ public class PowerPlayClubRepository implements Listener { }); } - public CompletableFuture> loadSubscriptions(Player player) + public CompletableFuture> loadSubscriptions(int accountId) { - int accountId = _clientManager.Get(player).getAccountId(); - return CompletableFuture.supplyAsync(() -> { try (Connection connection = DBPool.getAccount().getConnection()) diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java index 566b9e591..d18740a49 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/customerSupport/CustomerSupport.java @@ -2,6 +2,7 @@ package mineplex.staffServer.customerSupport; import java.sql.ResultSet; import java.sql.SQLException; +import java.time.YearMonth; import java.util.ArrayList; import java.util.Calendar; import java.util.HashSet; @@ -9,6 +10,7 @@ import java.util.List; import java.util.Locale; import java.util.UUID; +import mineplex.core.powerplayclub.PowerPlayData; import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -118,8 +120,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable { _repository.loadBonusLogForAccountId(client.getAccountId(), instance); - boolean powerPlaySub = _powerPlayRepo.hasSubscription(client.getAccountId()).join(); - boolean powerPlayClaim = _powerPlayRepo.hasClaimed(client.getAccountId()).join(); + PowerPlayData powerPlayData = _powerPlayRepo.loadData(client.getAccountId()).join(); + boolean powerPlaySub = powerPlayData.isSubscribed(); + boolean powerPlayClaim = powerPlaySub && !powerPlayData.getUnclaimedMonths().contains(YearMonth.now()); runSync(new Runnable() {