diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java index d2cfef1f8..bb6d8c9f3 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusAmount.java @@ -2,6 +2,8 @@ package mineplex.core.bonuses; import java.util.List; +import org.bukkit.ChatColor; + import mineplex.core.common.util.C; public class BonusAmount @@ -138,6 +140,7 @@ public class BonusAmount public void addLore(List lore) { + lore.add(C.cYellow + "Rewards"); addLore(lore, getTickets(), 0, "Carl Spin Ticket" + (getTickets() > 1 ? "s" : "")); addLore(lore, getCoins(), getBonusCoins(), "Coins"); addLore(lore, getGems(), getBonusGems(), "Gems"); @@ -148,7 +151,7 @@ public class BonusAmount private void addLore(List lore, int amount, int bonus, String suffix) { if (amount > 0) - lore.add(C.cYellow + "Reward: " + C.cWhite + amount + " " + suffix); + lore.add(" " + C.cWhite + amount + " " + suffix); // if (bonus > 0) // lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java index 0a3f72ced..e31bee5e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/BonusManager.java @@ -375,7 +375,8 @@ public class BonusManager extends MiniClientPlugin implements I // DAILY BONUS public static final long TIME_BETWEEN_BONUSES = 1000 * 60 * 60 * 20; - public static final long STREAK_RESET_TIME = 1000 * 60 * 60 * 12; + public static final long DAILY_STREAK_RESET_TIME = 1000 * 60 * 60 * 12; + public static final long VOTE_STREAK_RESET_TIME = 1000 * 60 * 60 * 24; public void attemptDailyBonus(final Player player, final BonusAmount amount, final Callback result) { @@ -496,7 +497,7 @@ public class BonusManager extends MiniClientPlugin implements I if (client.getDailyStreak() > 0 && client.getDailyTime() != null) { long lastBonus = getLocalTime(client.getDailyTime().getTime()); - long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.STREAK_RESET_TIME); + long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME); if (timeLeft < 0) { @@ -505,6 +506,25 @@ public class BonusManager extends MiniClientPlugin implements I } } + public void updateVoteStreak(Player player) + { + updateVoteStreak(Get(player)); + } + + public void updateVoteStreak(BonusClientData client) + { + if (client.getVoteStreak() > 0 && client.getVoteTime() != null) + { + long lastBonus = getLocalTime(client.getDailyTime().getTime()); + long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); + + if (timeLeft < 0) + { + client.setVoteStreak(0); + } + } + } + public void incrementDailyStreak(Player player) { BonusClientData data = Get(player); @@ -666,6 +686,7 @@ public class BonusManager extends MiniClientPlugin implements I if (gems > 0) { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems"))); _donationManager.RewardGems(new Callback() { @Override @@ -673,18 +694,18 @@ public class BonusManager extends MiniClientPlugin implements I { if (data) { - UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gems + " Gems"))); } else { UtilPlayer.message(player, F.main("Carl", "Failed to process Gems")); } } - }, "BonusManager", player.getName(), player.getUniqueId(), gems, true); + }, "Earned", player.getName(), player.getUniqueId(), gems, true); } if (gold > 0) { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold"))); _donationManager.RewardGold(new Callback() { @Override @@ -692,18 +713,18 @@ public class BonusManager extends MiniClientPlugin implements I { if (data) { - UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold"))); } else { UtilPlayer.message(player, F.main("Carl", "Failed to process Gold")); } } - }, "BonusManager", player.getName(), coreClient.getAccountId(), gold, true); + }, "Earned", player.getName(), coreClient.getAccountId(), gold, true); } if (coins > 0) { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Coins"))); _donationManager.RewardCoins(new Callback() { @Override @@ -711,18 +732,18 @@ public class BonusManager extends MiniClientPlugin implements I { if (data) { - UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Coins"))); } else { UtilPlayer.message(player, F.main("Carl", "Failed to process Coins")); } } - }, "BonusManager", player.getName(), coreClient.getAccountId(), coins, true); + }, "Earned", player.getName(), coreClient.getAccountId(), coins, true); } if (tickets > 0) { + UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(tickets + " Carl Spin Ticket"))); final int accountId = _clientManager.Get(player).getAccountId(); runAsync(new Runnable() { @@ -739,7 +760,6 @@ public class BonusManager extends MiniClientPlugin implements I public void run() { bonusClient.setTickets(newTickets); - UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(tickets + " Carl Spin Ticket"))); } }); } @@ -757,7 +777,7 @@ public class BonusManager extends MiniClientPlugin implements I _statsManager.incrementStat(player, "Global.ExpEarned", experience); UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(experience + " Experience"))); } - + UtilPlayer.message(player, F.main("Carl", "Come back tomorrow for more!")); } @@ -897,15 +917,16 @@ public class BonusManager extends MiniClientPlugin implements I @EventHandler public void updateCreeper(UpdateEvent event) { - if (event.getType() != UpdateType.SEC || !_enabled) + if (event.getType() != UpdateType.FASTER || !_enabled) return; for (Player player : UtilServer.getPlayers()) { String prefix = _visualTick % 2 == 0 ? C.cAqua : C.cDAqua; updateCreeperVisual(player, false, prefix); - _visualTick++; } + + _visualTick++; } @Override diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java index 76d58c807..0c2ea37d2 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/DailyBonusButton.java @@ -152,7 +152,7 @@ public class DailyBonusButton implements GuiItem, Listener if (client.getDailyTime() != null) { long lastBonus = _bonusManager.getLocalTime(client.getDailyTime().getTime()); - long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.STREAK_RESET_TIME); + long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.DAILY_STREAK_RESET_TIME); if (timeLeft > 0) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java index 40950cd54..9009fb7e0 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/gui/buttons/VoteButton.java @@ -135,7 +135,7 @@ public class VoteButton implements GuiItem, Listener { if (client.getVoteTime() != null) { long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime()); - long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.STREAK_RESET_TIME); + long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME); if (timeLeft > 0) { diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java index 7c4e6f37d..54f2a820b 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VoteHandler.java @@ -25,7 +25,7 @@ public class VoteHandler implements CommandCallback if (player != null) { - _bonusManager.handleVote(player, v.getGemsRecieved()); + _bonusManager.handleVote(player, v.getGemsReceived()); } } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java index d2574643e..95dbb06a4 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/redis/VotifierCommand.java @@ -1,20 +1,18 @@ package mineplex.core.bonuses.redis; -import java.util.UUID; - import mineplex.serverdata.commands.ServerCommand; public class VotifierCommand extends ServerCommand { private String _playerName; - private int _gemsRecieved; + private int _gemsReceived; - public VotifierCommand(String playerName, int gemsRecieved, String... targetServer) + public VotifierCommand(String playerName, int gemsReceived, String... targetServer) { super(targetServer); _playerName = playerName; - _gemsRecieved = gemsRecieved; + _gemsReceived = gemsReceived; } public String getPlayerName() @@ -22,9 +20,9 @@ public class VotifierCommand extends ServerCommand return _playerName; } - public int getGemsRecieved() + public int getGemsReceived() { - return _gemsRecieved; + return _gemsReceived; } } diff --git a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java index 3d367e424..ff124fa76 100644 --- a/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java +++ b/Plugins/Mineplex.Votifier/src/mineplex/votifier/VotifierManager.java @@ -92,12 +92,12 @@ public class VotifierManager extends MiniPlugin System.out.println("Loaded " + playerName + " with uuid " + uuid); System.out.println("Attempting to award bonus"); - awardBonus(playerName, uuid, new Runnable() + awardBonus(playerName, uuid, new Callback() { @Override - public void run() + public void run(Integer gems) { - notifyServer(playerName, false); + notifyServer(playerName, gems, false); } }); System.out.println(); @@ -138,15 +138,15 @@ public class VotifierManager extends MiniPlugin // notifyServer(playerName, true); } - private void notifyServer(String playerName, boolean eu) + private void notifyServer(String playerName, int gems, boolean eu) { JedisPool writePool = eu ? _euWritePool : _usWritePool; - VotifierCommand command = new VotifierCommand(playerName); + VotifierCommand command = new VotifierCommand(playerName, gems); publishCommand(command, writePool); } - private void awardBonus(final String playerName, UUID uuid, final Runnable onComplete) + private void awardBonus(final String playerName, UUID uuid, final Callback onComplete) { DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL); @@ -162,7 +162,7 @@ public class VotifierManager extends MiniPlugin if (amount.getTickets() > 0) client.setTickets(client.getTickets() + amount.getTickets()); - if (amount.getGems() > 0) + if (amount.getTotalGems() > 0) { _donationManager.RewardGems(new Callback() { @@ -174,10 +174,10 @@ public class VotifierManager extends MiniPlugin else System.out.println("Failed to give " + amount.getGems() + " gems to " + playerName); } - }, "Votifier", playerName, uuid, amount.getGems()); + }, "Votifier", playerName, uuid, amount.getTotalGems()); } - if (amount.getCoins() > 0) + if (amount.getTotalCoins() > 0) { _donationManager.RewardCoins(new Callback() { @@ -189,9 +189,12 @@ public class VotifierManager extends MiniPlugin else System.out.println("Failed to give " + amount.getGems() + " coins to " + playerName); } - }, "Votifier", playerName, accountId, amount.getCoins()); + }, "Votifier", playerName, accountId, amount.getTotalCoins()); } + // Check if we need to reset vote streak + _bonusManager.updateVoteStreak(client); + // Update time _bonusManager.getRepository().attemptVoteBonus(accountId, new Callback() { @@ -207,7 +210,7 @@ public class VotifierManager extends MiniPlugin client.getRecord().store(); System.out.println("Awarded carl ticket to " + playerName); - onComplete.run(); + onComplete.run(amount.getTotalGems()); } } });