Merge remote-tracking branch 'origin/clans/beta' into clans/beta

This commit is contained in:
Shaun Bennett 2016-04-04 16:46:17 +10:00
commit be8ed78caa
3 changed files with 158 additions and 87 deletions

View File

@ -1,6 +1,10 @@
package mineplex.staffServer.customerSupport;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClient;
@ -13,6 +17,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.serverdata.database.ResultSetCallable;
import mineplex.staffServer.salespackage.SalesPackageManager;
import org.bukkit.GameMode;
@ -27,13 +32,15 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class CustomerSupport extends MiniPlugin
public class CustomerSupport extends MiniPlugin implements ResultSetCallable
{
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private SalesPackageManager _salesPackageManager;
private CustomerSupportRepository _repository;
private NautHashMap<Player, HashSet<String>> _agentCacheMap = new NautHashMap<Player, HashSet<String>>();
private NautHashMap<Integer, List<String>> _accountBonusLog = new NautHashMap<>();
public CustomerSupport(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, SalesPackageManager salesPackageManager)
{
@ -42,6 +49,7 @@ public class CustomerSupport extends MiniPlugin
_clientManager = clientManager;
_donationManager = donationManager;
_salesPackageManager = salesPackageManager;
_repository = new CustomerSupportRepository(getPlugin());
}
@EventHandler
@ -94,98 +102,121 @@ public class CustomerSupport extends MiniPlugin
{
CoreClient client = _clientManager.Get(playerName);
Donor donor = _donationManager.Get(playerName);
CustomerSupport instance = this;
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Name : " + C.cYellow + playerName);
caller.sendMessage(C.cBlue + "Rank : " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name)));
caller.sendMessage(C.cBlue + "Coins : " + C.cYellow + donor.getCoins());
caller.sendMessage(C.cBlue + "Gems : " + C.cYellow + donor.GetGems());
int enjinCoinsReceived = 0;
int oldChestsReceived = 0;
int ancientChestsReceived = 0;
int mythicalChestsReceived = 0;
int winterChestsReceived = 0;
int valentinesGiftsReceived = 0;
for (CoinTransactionToken transaction : donor.getCoinTransactions())
runAsync(new Runnable()
{
if (transaction.Source.equalsIgnoreCase("Poll") || transaction.Source.equalsIgnoreCase("Halloween Pumpkin") || transaction.Source.equalsIgnoreCase("Treasure Chest") || transaction.Source.equalsIgnoreCase("Coin Party Bomb Pickup") || transaction.Source.contains("Reward") || transaction.Source.contains("purchase"))
public void run()
{
if (transaction.Source.contains("purchase"))
enjinCoinsReceived += transaction.Amount;
}
}
_repository.loadBonusLogForAccountId(client.getAccountId(), instance);
runSync(new Runnable()
{
public void run()
{
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Name : " + C.cYellow + playerName);
caller.sendMessage(C.cBlue + "Rank : " + C.cYellow + (client.GetRank() == null ? C.cRed + "Error rank null!" : (client.GetRank().Name.isEmpty() ? "Regular" : client.GetRank().Name)));
caller.sendMessage(C.cBlue + "Coins : " + C.cYellow + donor.getCoins());
caller.sendMessage(C.cBlue + "Gems : " + C.cYellow + donor.GetGems());
for (TransactionToken transaction : donor.getTransactions())
{
if (transaction.SalesPackageName.startsWith("Old Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
oldChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
oldChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Ancient Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
ancientChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
ancientChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Mythical Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
mythicalChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
mythicalChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Winter Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
winterChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
winterChestsReceived += 1;
}
int enjinCoinsReceived = 0;
int oldChestsReceived = 0;
int ancientChestsReceived = 0;
int mythicalChestsReceived = 0;
int winterChestsReceived = 0;
int valentinesGiftsReceived = 0;
for (CoinTransactionToken transaction : donor.getCoinTransactions())
{
if (transaction.Source.equalsIgnoreCase("Poll") || transaction.Source.equalsIgnoreCase("Halloween Pumpkin") || transaction.Source.equalsIgnoreCase("Treasure Chest") || transaction.Source.equalsIgnoreCase("Coin Party Bomb Pickup") || transaction.Source.contains("Reward") || transaction.Source.contains("purchase"))
{
if (transaction.Source.contains("purchase"))
enjinCoinsReceived += transaction.Amount;
}
}
}
if (transaction.SalesPackageName.startsWith("Valentines Gift"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
valentinesGiftsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
valentinesGiftsReceived += 1;
}
for (TransactionToken transaction : donor.getTransactions())
{
if (transaction.SalesPackageName.startsWith("Old Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
oldChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
oldChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Ancient Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
ancientChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
ancientChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Mythical Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
mythicalChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
mythicalChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Winter Chest"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
winterChestsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
winterChestsReceived += 1;
}
}
if (transaction.SalesPackageName.startsWith("Valentines Gift"))
{
if (transaction.Coins == 0 && transaction.Gems == 0)
{
if (transaction.SalesPackageName.split(" ").length == 3)
valentinesGiftsReceived += Integer.parseInt(transaction.SalesPackageName.split(" ")[2]);
else if (transaction.SalesPackageName.split(" ").length == 2)
valentinesGiftsReceived += 1;
}
}
}
caller.sendMessage(C.cBlue + "Enjin Coin Total Received : " + C.cYellow + enjinCoinsReceived);
caller.sendMessage(C.cBlue + "Old Chests Received : " + C.cYellow + oldChestsReceived);
caller.sendMessage(C.cBlue + "Ancient Chests Received : " + C.cYellow + ancientChestsReceived);
caller.sendMessage(C.cBlue + "Mythical Chests Received : " + C.cYellow + mythicalChestsReceived);
caller.sendMessage(C.cBlue + "Winter Chests Received : " + C.cYellow + winterChestsReceived);
caller.sendMessage(C.cBlue + "Valentines Gifts Received : " + C.cYellow + valentinesGiftsReceived);
caller.sendMessage(C.cBlue + "Monthly Bonus Log (Last 6 entries):");
for (String logEntry : _accountBonusLog.get(client.getAccountId()))
{
caller.sendMessage(C.cYellow + logEntry);
}
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
_salesPackageManager.displaySalesPackages(caller, playerName);
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
_accountBonusLog.remove(client.getAccountId());
}
});
}
}
caller.sendMessage(C.cBlue + "Enjin Coin Total Received : " + C.cYellow + enjinCoinsReceived);
caller.sendMessage(C.cBlue + "Old Chests Received : " + C.cYellow + oldChestsReceived);
caller.sendMessage(C.cBlue + "Ancient Chests Received : " + C.cYellow + ancientChestsReceived);
caller.sendMessage(C.cBlue + "Mythical Chests Received : " + C.cYellow + mythicalChestsReceived);
caller.sendMessage(C.cBlue + "Winter Chests Received : " + C.cYellow + winterChestsReceived);
caller.sendMessage(C.cBlue + "Valentines Gifts Received : " + C.cYellow + valentinesGiftsReceived);
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
_salesPackageManager.displaySalesPackages(caller, playerName);
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
});
}
@EventHandler
@ -215,4 +246,19 @@ public class CustomerSupport extends MiniPlugin
event.setCancelled(true);
}
@Override
public void processResultSet(ResultSet resultSet) throws SQLException
{
List<String> log = new ArrayList<String>();
int accountId = 0;
while (resultSet.next() && log.size() < 6)
{
accountId = resultSet.getInt(1);
log.add("Received " + resultSet.getInt(3) + " " + resultSet.getString(2) + " on " + resultSet.getDate(4));
}
_accountBonusLog.put(accountId, log);
}
}

View File

@ -0,0 +1,25 @@
package mineplex.staffServer.customerSupport;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.database.MinecraftRepository;
import mineplex.serverdata.database.DBPool;
public class CustomerSupportRepository extends MinecraftRepository
{
public CustomerSupportRepository(JavaPlugin plugin)
{
super(plugin, DBPool.getAccount());
}
@Override
protected void initialize() { }
@Override
protected void update() { }
public void loadBonusLogForAccountId(int accountId, CustomerSupport customerSupport)
{
executeQuery("SELECT accountId, items.name, itemChange, time FROM bonusLog INNER JOIN items ON itemId = items.id WHERE accountId = " + accountId + " ORDER BY bonusLog.id DESC;", customerSupport);
}
}

View File

@ -34,8 +34,8 @@ public class checkCommand extends CommandBase<CustomerSupport>
{
public void run()
{
Plugin.addAgentMapping(caller, name);
Plugin.showPlayerInfo(caller, name);
Plugin.addAgentMapping(caller, name);
}
});
}