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:
parent
28806aaf0a
commit
511cc76bef
@ -8,7 +8,7 @@ public class VotifierCommand extends ServerCommand
|
||||
{
|
||||
private String _playerName;
|
||||
|
||||
public VotifierCommand(String playerName, String targetServer)
|
||||
public VotifierCommand(String playerName, String... targetServer)
|
||||
{
|
||||
super(targetServer);
|
||||
|
||||
|
@ -209,11 +209,25 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return _voteStreak;
|
||||
}
|
||||
|
||||
public void handleVote(Player player)
|
||||
public void handleVote(final Player player)
|
||||
{
|
||||
// _repository.attemptDailyBonus();
|
||||
|
||||
addPendingExplosion(player, player.getName());
|
||||
_repository.attemptVoteBonus(player, new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
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
|
||||
|
@ -97,10 +97,6 @@ public class BonusRepository extends RepositoryBase
|
||||
|
||||
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 coins = 0;
|
||||
final int gems = 0;
|
||||
@ -290,10 +286,6 @@ public class BonusRepository extends RepositoryBase
|
||||
public void run()
|
||||
{
|
||||
_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);
|
||||
|
||||
}
|
||||
|
@ -67,64 +67,58 @@ public class VotifierManager extends MiniPlugin
|
||||
public void handleVote(VotifierEvent event)
|
||||
{
|
||||
Vote vote = event.getVote();
|
||||
String playerName = "Phinary";
|
||||
String playerName = vote.getUsername();
|
||||
|
||||
System.out.println("New Vote: " + playerName);
|
||||
|
||||
// UUID uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
UUID uuid = _clientManager.loadUUIDFromDB(playerName);
|
||||
if (uuid != null)
|
||||
{
|
||||
System.out.println("Found UUID:" + uuid.toString());
|
||||
// UUID uuid = _clientManager.loadUUIDFromDB(playerName);
|
||||
// if (uuid != null)
|
||||
// {
|
||||
// System.out.println("Found UUID:" + uuid.toString());
|
||||
// if (playerName.equalsIgnoreCase("Phinary"))
|
||||
// {
|
||||
// System.out.println("award bonus");
|
||||
// awardBonus(uuid);
|
||||
// }
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to load UUID for player: " + playerName);
|
||||
}
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// System.out.println("Failed to load UUID for player: " + playerName);
|
||||
// }
|
||||
|
||||
notifyServer(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);
|
||||
}
|
||||
|
||||
private boolean notifyServer(String playerName)
|
||||
private void notifyServer(String playerName, boolean eu)
|
||||
{
|
||||
JedisPool writePool = null;
|
||||
String serverName = null;
|
||||
JedisPool writePool = eu ? _euWritePool : _usWritePool;
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if (writePool != null && serverName != null)
|
||||
{
|
||||
VotifierCommand command = new VotifierCommand(playerName, serverName);
|
||||
System.out.println("Publishing Server Command!");
|
||||
publishCommand(command, writePool);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
VotifierCommand command = new VotifierCommand(playerName);
|
||||
publishCommand(command, writePool);
|
||||
}
|
||||
|
||||
private void awardBonus(UUID uuid)
|
||||
{
|
||||
// Don't use this right now!
|
||||
DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user