Allow servers to process votifier votes, redis command gets sent to all servers (Until I can figure out why EU playertracker isnt working)

This commit is contained in:
Shaun Bennett 2015-08-10 00:47:36 -05:00
parent 28806aaf0a
commit 511cc76bef
4 changed files with 53 additions and 53 deletions

View File

@ -8,7 +8,7 @@ public class VotifierCommand extends ServerCommand
{ {
private String _playerName; private String _playerName;
public VotifierCommand(String playerName, String targetServer) public VotifierCommand(String playerName, String... targetServer)
{ {
super(targetServer); super(targetServer);

View File

@ -209,11 +209,25 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return _voteStreak; return _voteStreak;
} }
public void handleVote(Player player) public void handleVote(final Player player)
{
_repository.attemptVoteBonus(player, new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
if (data)
{ {
// _repository.attemptDailyBonus();
addPendingExplosion(player, player.getName()); addPendingExplosion(player, player.getName());
awardBonus(player, getVoteBonusAmount(player));
UtilPlayer.message(player, F.main("Vote", "Thanks for your vote!"));
}
else
{
UtilPlayer.message(player, F.main("Vote", "There was an error processing your vote. Please contact an admin!"));
}
}
});
} }
@EventHandler @EventHandler

View File

@ -97,10 +97,6 @@ public class BonusRepository extends RepositoryBase
public void attemptDailyBonus(final Player player, final Callback<Boolean> result) public void attemptDailyBonus(final Player player, final Callback<Boolean> result)
{ {
if (!Recharge.Instance.usable(player, "AttemptDailyBonus")) {
result.run(false);
return;
}
final int accountId = _manager.getClientManager().Get(player).getAccountId(); final int accountId = _manager.getClientManager().Get(player).getAccountId();
final int coins = 0; final int coins = 0;
final int gems = 0; final int gems = 0;
@ -290,10 +286,6 @@ public class BonusRepository extends RepositoryBase
public void run() public void run()
{ {
_manager.Get(player).setVoteTime(date); _manager.Get(player).setVoteTime(date);
_donationManager.RewardCoins(null, "Vote bonus", player.getName(), accountId, coins);
_donationManager.RewardGems(null, "Vote bonus", player.getName(), player.getUniqueId(), gems);
result.run(true); result.run(true);
} }

View File

@ -67,64 +67,58 @@ public class VotifierManager extends MiniPlugin
public void handleVote(VotifierEvent event) public void handleVote(VotifierEvent event)
{ {
Vote vote = event.getVote(); Vote vote = event.getVote();
String playerName = "Phinary"; String playerName = vote.getUsername();
System.out.println("New Vote: " + playerName); System.out.println("New Vote: " + playerName);
// UUID uuid = UUIDFetcher.getUUIDOf(playerName); // UUID uuid = UUIDFetcher.getUUIDOf(playerName);
UUID uuid = _clientManager.loadUUIDFromDB(playerName); // UUID uuid = _clientManager.loadUUIDFromDB(playerName);
if (uuid != null) // if (uuid != null)
{ // {
System.out.println("Found UUID:" + uuid.toString()); // System.out.println("Found UUID:" + uuid.toString());
// if (playerName.equalsIgnoreCase("Phinary")) // if (playerName.equalsIgnoreCase("Phinary"))
// { // {
// System.out.println("award bonus"); // System.out.println("award bonus");
// awardBonus(uuid); // awardBonus(uuid);
// } // }
} // }
else // else
{ // {
System.out.println("Failed to load UUID for player: " + playerName); // System.out.println("Failed to load UUID for player: " + playerName);
// }
// PlayerStatus usStatus = _usPlayerRepo.getElement(playerName);
// if (usStatus != null)
// {
// System.out.println("Found on US Server: " + usStatus.getServer());
// writePool = _usWritePool;
// serverName = usStatus.getServer();
// }
//
// PlayerStatus euStatus = _euPlayerRepo.getElement(playerName);
// if (euStatus != null)
// {
// System.out.println("Found on EU Server: " + euStatus.getServer());
// writePool = _euWritePool;
// serverName = euStatus.getServer();
// }
// Currently we just notify all servers, and the server with the player on it can deal with it
notifyServer(playerName, false);
notifyServer(playerName, true);
} }
notifyServer(playerName); private void notifyServer(String playerName, boolean eu)
}
private boolean notifyServer(String playerName)
{ {
JedisPool writePool = null; JedisPool writePool = eu ? _euWritePool : _usWritePool;
String serverName = null;
PlayerStatus usStatus = _usPlayerRepo.getElement(playerName); VotifierCommand command = new VotifierCommand(playerName);
if (usStatus != null)
{
System.out.println("Found on US Server: " + usStatus.getServer());
writePool = _usWritePool;
serverName = usStatus.getServer();
}
PlayerStatus euStatus = _euPlayerRepo.getElement(playerName);
if (euStatus != null)
{
System.out.println("Found on EU Server: " + euStatus.getServer());
writePool = _euWritePool;
serverName = euStatus.getServer();
}
if (writePool != null && serverName != null)
{
VotifierCommand command = new VotifierCommand(playerName, serverName);
System.out.println("Publishing Server Command!");
publishCommand(command, writePool); publishCommand(command, writePool);
return true;
}
return false;
} }
private void awardBonus(UUID uuid) private void awardBonus(UUID uuid)
{ {
// Don't use this right now!
DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
int updated = create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(1)) int updated = create.update(Tables.bonus).set(Tables.bonus.tickets, Tables.bonus.tickets.add(1))
.where(Tables.bonus.accountId.eq(DSL.select(Tables.accounts.id).where(Tables.accounts.uuid.eq(uuid.toString())))).execute(); .where(Tables.bonus.accountId.eq(DSL.select(Tables.accounts.id).where(Tables.accounts.uuid.eq(uuid.toString())))).execute();