From 511cc76befbb3ca1cb81f22501926f76dcd59fe5 Mon Sep 17 00:00:00 2001 From: Shaun Bennett Date: Mon, 10 Aug 2015 00:47:36 -0500 Subject: [PATCH] Allow servers to process votifier votes, redis command gets sent to all servers (Until I can figure out why EU playertracker isnt working) --- .../core/votifier/VotifierCommand.java | 2 +- .../mineplex/hub/bonuses/BonusManager.java | 22 +++++- .../mineplex/hub/bonuses/BonusRepository.java | 8 -- .../mineplex/votifier/VotifierManager.java | 74 +++++++++---------- 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/votifier/VotifierCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/votifier/VotifierCommand.java index a84087fb0..0d8454d2d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/votifier/VotifierCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/votifier/VotifierCommand.java @@ -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); diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusManager.java b/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusManager.java index b91ff0527..a63556c77 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusManager.java @@ -209,11 +209,25 @@ public class BonusManager extends MiniClientPlugin 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() + { + @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 diff --git a/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusRepository.java b/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusRepository.java index bed58e3dd..f34c71296 100644 --- a/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusRepository.java +++ b/Plugins/Mineplex.Hub/src/mineplex/hub/bonuses/BonusRepository.java @@ -97,10 +97,6 @@ public class BonusRepository extends RepositoryBase public void attemptDailyBonus(final Player player, final Callback 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); } diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java index 3ff5e1f0f..420fb5adf 100644 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -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();