Add power play to support server

This commit is contained in:
cnr 2016-09-02 19:10:30 -05:00
parent 2bce540c5d
commit c9358d8c5a
2 changed files with 45 additions and 9 deletions

View File

@ -111,6 +111,42 @@ public class PowerPlayClubRepository extends MiniClientPlugin<PPCPlayerData> {
return Get(player).hasSubscribed() && !Get(player).hasClaimed();
}
public CompletableFuture<Boolean> hasSubscription(int accountId)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlaySubs WHERE accountId = ?");
statement.setInt(1, accountId);
return statement.executeQuery().next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
});
}
public CompletableFuture<Boolean> hasClaimed(int accountId)
{
return CompletableFuture.supplyAsync(() ->
{
try (Connection connection = DBPool.getAccount().getConnection())
{
PreparedStatement statement = connection.prepareStatement("SELECT * FROM powerPlayClaims WHERE accountId = ?");
statement.setInt(1, accountId);
return statement.executeQuery().next();
} catch (SQLException e) {
e.printStackTrace();
}
return false;
});
}
@Override
protected PPCPlayerData addPlayer(UUID uuid) {
return new PPCPlayerData();

View File

@ -19,6 +19,7 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.donation.Donor;
import mineplex.core.donation.repository.token.CoinTransactionToken;
import mineplex.core.donation.repository.token.TransactionToken;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.serverdata.database.ResultSetCallable;
import mineplex.staffServer.salespackage.SalesPackageManager;
import org.bukkit.GameMode;
@ -39,6 +40,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
private DonationManager _donationManager;
private SalesPackageManager _salesPackageManager;
private CustomerSupportRepository _repository;
private PowerPlayClubRepository _powerPlayRepo;
private NautHashMap<Player, HashSet<String>> _agentCacheMap = new NautHashMap<Player, HashSet<String>>();
private NautHashMap<Integer, List<String>> _accountBonusLog = new NautHashMap<>();
@ -51,6 +53,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
_donationManager = donationManager;
_salesPackageManager = salesPackageManager;
_repository = new CustomerSupportRepository(getPlugin());
_powerPlayRepo = new PowerPlayClubRepository(plugin, clientManager);
}
@EventHandler
@ -110,6 +113,9 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
public void run()
{
_repository.loadBonusLogForAccountId(client.getAccountId(), instance);
boolean powerPlaySub = _powerPlayRepo.hasSubscription(client.getAccountId()).join();
boolean powerPlayClaim = _powerPlayRepo.hasClaimed(client.getAccountId()).join();
runSync(new Runnable()
{
@ -276,17 +282,11 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
_salesPackageManager.displaySalesPackages(caller, playerName);
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Freedom Mount: " + getLockedFreedomStr(client.getUniqueId(), "Freedom Mount"));
caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(client.getUniqueId(), "Uncle Sam Morph"));
caller.sendMessage(C.cBlue + "Freedom Aura: " + getLockedFreedomStr(client.getUniqueId(), "Freedom Aura"));
caller.sendMessage(C.cBlue + "Shock and Awe: " + getLockedFreedomStr(client.getUniqueId(), "Shock and Awe"));
caller.sendMessage(C.cBlue + "Leap of Freedom: " + getLockedFreedomStr(client.getUniqueId(), "Leap of Freedom"));
caller.sendMessage(C.cBlue + "Price of Freedom: " + getLockedFreedomStr(client.getUniqueId(), "Price of Freedom"));
caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(client.getUniqueId(), "Uncle Sam Hat"));
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Usage"));
caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(client.getUniqueId(), "Clan Banner Editor"));
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Power play subscription (September): " + powerPlaySub);
caller.sendMessage(C.cBlue + "Power play claim (September): " + powerPlayClaim);
_accountBonusLog.remove(client.getAccountId());
}