Properly award all values in BonusAmount wherever it is used for rewarding
This commit is contained in:
parent
a4c875b4bd
commit
7e70d02751
@ -209,7 +209,9 @@ public class BonusAmount
|
||||
private void addLore(List<String> lore, int amount, int bonus, String suffix)
|
||||
{
|
||||
if (amount > 0)
|
||||
{
|
||||
lore.add(" " + C.cWhite + amount + " " + suffix);
|
||||
}
|
||||
|
||||
// if (bonus > 0)
|
||||
// lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + bonus + " " + suffix);
|
||||
@ -218,8 +220,12 @@ public class BonusAmount
|
||||
private void addLore(List<String> lore, int amount, int bonus, String suffix, String plural)
|
||||
{
|
||||
if (amount == 1)
|
||||
{
|
||||
lore.add(" " + C.cWhite + amount + " " + plural);
|
||||
}
|
||||
else if (amount > 0)
|
||||
{
|
||||
lore.add(" " + C.cWhite + amount + " " + suffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import java.sql.Date;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
import mineplex.core.hologram.Hologram;
|
||||
import mineplex.database.tables.records.BonusRecord;
|
||||
|
||||
public class BonusClientData
|
||||
{
|
||||
|
@ -7,6 +7,9 @@ import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -90,7 +93,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
private ArrayList<Object> _pendingExplosions = new ArrayList<>();
|
||||
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
|
||||
private HashMap<String, Boolean> _showCarl = new HashMap<>();
|
||||
private Map<String, Boolean> _showCarl = new HashMap<>();
|
||||
private long _explode;
|
||||
private boolean _canVote;
|
||||
private boolean _animationRunning;
|
||||
@ -471,7 +474,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
return nextRankBonus(player) - getLocalTime();
|
||||
}
|
||||
|
||||
|
||||
// This calculates the the next rank bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
|
||||
public long nextRankBonus(Player player)
|
||||
{
|
||||
@ -482,7 +484,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
long lastBonus = date.getTime();
|
||||
|
||||
|
||||
return getNextRankBonusTime(getLocalTime(lastBonus));
|
||||
}
|
||||
|
||||
@ -549,7 +550,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
public static long getNextRankBonusTime(long time)
|
||||
{
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeZone(TIMEZONE);
|
||||
calendar.setTimeInMillis(time);
|
||||
@ -680,7 +680,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
|
||||
final int gems = amount.getTotalGems();
|
||||
final int gold = amount.getTotalGold();
|
||||
final int coins = amount.getTotalShards();
|
||||
final int shards = amount.getTotalShards();
|
||||
final int tickets = amount.getTickets();
|
||||
int experience = amount.getTotalExperience();
|
||||
int oldChests = amount.getOldChests();
|
||||
@ -728,18 +728,25 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
if (gold > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(gold + " Gold")));
|
||||
Set<Integer> serverIds = new HashSet<>();
|
||||
serverIds.addAll(amount.getGold().getServerIds());
|
||||
serverIds.addAll(amount.getBonusGold().getServerIds());
|
||||
for (Integer serverId : serverIds)
|
||||
{
|
||||
_donationManager.getGoldRepository().rewardGold(null, serverId, coreClient.getAccountId(), amount.getGold().getGoldFor(serverId) + amount.getBonusGold().getGoldFor(serverId));
|
||||
}
|
||||
}
|
||||
|
||||
if (coins > 0)
|
||||
if (shards > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(coins + " Treasure Shards")));
|
||||
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Earned", coins);
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(shards + " Treasure Shards")));
|
||||
_donationManager.rewardCurrencyUntilSuccess(GlobalCurrency.TREASURE_SHARD, player, "Earned", shards);
|
||||
}
|
||||
|
||||
if (tickets > 0)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Rewarded " + F.elem(tickets + " Carl Spin Ticket")));
|
||||
final int accountId = _clientManager.Get(player).getAccountId();
|
||||
final int accountId = coreClient.getAccountId();
|
||||
runAsync(() ->
|
||||
{
|
||||
try
|
||||
|
@ -82,4 +82,4 @@ public class CarlSpinButton implements GuiItem
|
||||
|
||||
return new ShopItem(material, data, name, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
}
|
||||
}
|
@ -40,10 +40,10 @@ public class VoteButton implements GuiItem, Listener
|
||||
|
||||
public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
|
||||
{
|
||||
this._bonusManager = bonusManager;
|
||||
this._player = player;
|
||||
this._plugin = plugin;
|
||||
this._gui = gui;
|
||||
_bonusManager = bonusManager;
|
||||
_player = player;
|
||||
_plugin = plugin;
|
||||
_gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,8 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
|
||||
public class Votifier extends JavaPlugin
|
||||
{
|
||||
@ -25,7 +27,9 @@ public class Votifier extends JavaPlugin
|
||||
CoreClientManager clientManager = new CoreClientManager(this);
|
||||
DonationManager donationManager = Managers.require(DonationManager.class);
|
||||
BonusManager bonusManager = new BonusManager(this, clientManager, donationManager);
|
||||
InventoryManager inventoryManager = new InventoryManager(this, clientManager);
|
||||
StatsManager statsManager = new StatsManager(this, clientManager);
|
||||
|
||||
VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager);
|
||||
VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager, inventoryManager, statsManager);
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package mineplex.votifier;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -23,6 +25,9 @@ import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.treasure.TreasureType;
|
||||
import mineplex.database.Tables;
|
||||
import mineplex.database.tables.records.BonusRecord;
|
||||
import mineplex.serverdata.Region;
|
||||
@ -41,6 +46,8 @@ public class VotifierManager extends MiniPlugin
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private BonusManager _bonusManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private StatsManager _statsManager;
|
||||
|
||||
private RedisConfig _usConfig;
|
||||
private RedisConfig _euConfig;
|
||||
@ -49,13 +56,15 @@ public class VotifierManager extends MiniPlugin
|
||||
private JedisPool _usWritePool;
|
||||
private JedisPool _euWritePool;
|
||||
|
||||
public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager)
|
||||
public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager, InventoryManager inventoryManager, StatsManager statsManager)
|
||||
{
|
||||
super("Votifier", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
_bonusManager = bonusManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_statsManager = statsManager;
|
||||
|
||||
_usConfig = ServerManager.loadConfig("us-redis.dat");
|
||||
_euConfig = ServerManager.loadConfig("eu-redis.dat");
|
||||
@ -194,31 +203,155 @@ public class VotifierManager extends MiniPlugin
|
||||
if (pair.getLeft())
|
||||
{
|
||||
// Reward Amount
|
||||
if (amount.getTickets() > 0)
|
||||
client.setTickets(client.getTickets() + amount.getTickets());
|
||||
final int gems = amount.getTotalGems();
|
||||
final int gold = amount.getTotalGold();
|
||||
final int shards = amount.getTotalShards();
|
||||
final int tickets = amount.getTickets();
|
||||
int experience = amount.getTotalExperience();
|
||||
int oldChests = amount.getOldChests();
|
||||
int ancientChests = amount.getAncientChests();
|
||||
int mythicalChests = amount.getMythicalChests();
|
||||
int illuminatedChests = amount.getIlluminatedChests();
|
||||
int omegaChests = amount.getOmegaChests();
|
||||
|
||||
if (amount.getTotalGems() > 0)
|
||||
if (oldChests > 0)
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.GEM, playerName, uuid, "Votifier", amount.getTotalGems(), data ->
|
||||
_inventoryManager.addItemToInventoryForOffline(data ->
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " gems to " + playerName);
|
||||
{
|
||||
System.out.println("Gave " + oldChests + " old chest(s) to " + playerName);
|
||||
}
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getTotalGems() + " gems to " + playerName);
|
||||
{
|
||||
System.out.println("Failed to give " + oldChests + " old chest(s) to " + playerName);
|
||||
}
|
||||
}, accountId, TreasureType.OLD.getItemName(), oldChests);
|
||||
}
|
||||
|
||||
if (ancientChests > 0)
|
||||
{
|
||||
_inventoryManager.addItemToInventoryForOffline(data ->
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
System.out.println("Gave " + ancientChests + " ancient chest(s) to " + playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to give " + ancientChests + " ancient chest(s) to " + playerName);
|
||||
}
|
||||
}, accountId, TreasureType.ANCIENT.getItemName(), ancientChests);
|
||||
}
|
||||
|
||||
if (mythicalChests > 0)
|
||||
{
|
||||
_inventoryManager.addItemToInventoryForOffline(data ->
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
System.out.println("Gave " + mythicalChests + " mythical chest(s) to " + playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to give " + mythicalChests + " mythical chest(s) to " + playerName);
|
||||
}
|
||||
}, accountId, TreasureType.MYTHICAL.getItemName(), mythicalChests);
|
||||
}
|
||||
|
||||
if (illuminatedChests > 0)
|
||||
{
|
||||
_inventoryManager.addItemToInventoryForOffline(data ->
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
System.out.println("Gave " + illuminatedChests + " illuminated chest(s) to " + playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to give " + illuminatedChests + " illuminated chest(s) to " + playerName);
|
||||
}
|
||||
}, accountId, TreasureType.ILLUMINATED.getItemName(), illuminatedChests);
|
||||
}
|
||||
|
||||
if (omegaChests > 0)
|
||||
{
|
||||
_inventoryManager.addItemToInventoryForOffline(data ->
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
System.out.println("Gave " + omegaChests + " omega chest(s) to " + playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to give " + omegaChests + " omega chest(s) to " + playerName);
|
||||
}
|
||||
}, accountId, TreasureType.OMEGA.getItemName(), omegaChests);
|
||||
}
|
||||
|
||||
if (gems > 0)
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.GEM, playerName, uuid, "Votifier", gems, data ->
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
System.out.println("Gave " + gems + " gems to " + playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to give " + gems + " gems to " + playerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (amount.getTotalShards() > 0)
|
||||
if (gold > 0)
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, playerName, uuid, "Votifier", amount.getTotalShards(), data ->
|
||||
Set<Integer> serverIds = new HashSet<>();
|
||||
serverIds.addAll(amount.getGold().getServerIds());
|
||||
serverIds.addAll(amount.getBonusGold().getServerIds());
|
||||
for (Integer serverId : serverIds)
|
||||
{
|
||||
int goldCount = amount.getGold().getGoldFor(serverId) + amount.getBonusGold().getGoldFor(serverId);
|
||||
_donationManager.getGoldRepository().rewardGold(data ->
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
System.out.println("Gave " + goldCount + " gold to " + playerName + " on clans server id " + serverId);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Failed to give " + goldCount + " gold to " + playerName + " on clans server id " + serverId);
|
||||
}
|
||||
}, serverId, accountId, goldCount);
|
||||
}
|
||||
}
|
||||
|
||||
if (shards > 0)
|
||||
{
|
||||
_donationManager.rewardCurrency(GlobalCurrency.TREASURE_SHARD, playerName, uuid, "Votifier", shards, data ->
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " shards to " + playerName);
|
||||
{
|
||||
System.out.println("Gave " + shards + " shards to " + playerName);
|
||||
}
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getTotalShards() + " shards to " + playerName);
|
||||
{
|
||||
System.out.println("Failed to give " + shards + " shards to " + playerName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (experience > 0)
|
||||
{
|
||||
_statsManager.incrementStat(accountId, "Global.ExpEarned", experience);
|
||||
System.out.println("Gave " + experience + " experience to " + playerName);
|
||||
}
|
||||
|
||||
if (tickets > 0)
|
||||
{
|
||||
client.setTickets(client.getTickets() + tickets);
|
||||
}
|
||||
|
||||
// Check if we need to reset vote streak
|
||||
_bonusManager.updateVoteStreak(client);
|
||||
client.setVotetime(pair.getRight());
|
||||
@ -227,7 +360,7 @@ public class VotifierManager extends MiniPlugin
|
||||
_bonusManager.incrementVoteStreak(client);
|
||||
|
||||
client.store();
|
||||
System.out.println("Awarded carl ticket to " + playerName);
|
||||
System.out.println("Awarded " + tickets + " carl ticket(s) to " + playerName);
|
||||
onComplete.run(amount.getTotalGems());
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user