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,7 +102,18 @@ public class CustomerSupport extends MiniPlugin
{
CoreClient client = _clientManager.Get(playerName);
Donor donor = _donationManager.Get(playerName);
CustomerSupport instance = this;
runAsync(new Runnable()
{
public void run()
{
_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)));
@ -182,10 +201,22 @@ public class CustomerSupport extends MiniPlugin
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());
}
});
}
});
}
@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);
}
});
}