Lets hope everything works!
This commit is contained in:
parent
e8963cc2af
commit
30f20801c7
@ -58,6 +58,7 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -128,6 +129,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
private StreakRecord _dailyStreak;
|
||||
private StreakRecord _voteStreak;
|
||||
|
||||
private ArrayList<String> _voteList;
|
||||
|
||||
/**
|
||||
* THIS SHOULD ONLY BE USED FOR VOTIFIER!
|
||||
*/
|
||||
@ -140,6 +143,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
|
||||
_voteList = new ArrayList<String>();
|
||||
_voteList.add("http://vote1.mineplex.com");
|
||||
_voteList.add("http://vote2.mineplex.com");
|
||||
|
||||
updateOffSet();
|
||||
}
|
||||
|
||||
@ -162,7 +169,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
_pollManager = pollManager;
|
||||
_statsManager = statsManager;
|
||||
|
||||
// Hope to god this works!
|
||||
_voteList = new ArrayList<String>();
|
||||
_voteList.add("http://vote1.mineplex.com");
|
||||
_voteList.add("http://vote2.mineplex.com");
|
||||
|
||||
_canVote = true;
|
||||
|
||||
if (npcManager != null)
|
||||
@ -515,7 +525,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
if (client.getVoteStreak() > 0 && client.getVoteTime() != null)
|
||||
{
|
||||
long lastBonus = getLocalTime(client.getDailyTime().getTime());
|
||||
long lastBonus = getLocalTime(client.getVoteTime().getTime());
|
||||
long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME);
|
||||
|
||||
if (timeLeft < 0)
|
||||
@ -795,6 +805,23 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
new BonusGui(_plugin, event.getPlayer(), this, _rewardManager).openInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void openGui(EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (!_enabled)
|
||||
return;
|
||||
|
||||
if (event.getDamager() instanceof Player)
|
||||
{
|
||||
Player player = (Player) event.getDamager();
|
||||
if (event.getEntity().equals(_carlNpc.getEntity()))
|
||||
{
|
||||
updateDailyStreak(player);
|
||||
new BonusGui(_plugin, player, this, _rewardManager).openInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static long getNextVoteTime(long time) {
|
||||
|
||||
@ -853,7 +880,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
int availableRewards = 0;
|
||||
|
||||
if (canVote(player)) availableRewards++;
|
||||
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA)) availableRewards++;
|
||||
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++;
|
||||
if (canDaily(player)) availableRewards++;
|
||||
if (getPollManager().getNextPoll(_pollManager.Get(player), _clientManager.Get(player).GetRank()) != null) availableRewards++;
|
||||
|
||||
@ -1045,7 +1072,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
{
|
||||
if (Recharge.Instance.use(player, "Carl Inform", 240000, false, false))
|
||||
{
|
||||
if(_pollManager.hasPoll(player) || canVote(player) || canRank(player) || canDaily(player))
|
||||
if(_pollManager.hasPoll(player) || canVote(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player))
|
||||
{
|
||||
if(_showCarl.containsKey(player.getName()))
|
||||
UtilPlayer.message(player, C.cDGreen + C.Bold + "Carl the Creeper>" + C.cGreen + " Hey " + player.getName().replace("s", "sss") + "! I have sssome amazing rewardsss for you! Come sssee me!");
|
||||
@ -1053,4 +1080,30 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getVoteLink()
|
||||
{
|
||||
long sqlTime = getSqlTime();
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeInMillis(sqlTime);
|
||||
int date = calendar.get(Calendar.DAY_OF_YEAR);
|
||||
int index = date % _voteList.size();
|
||||
return _voteList.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for disabling rank rewards during first month of release
|
||||
* @return
|
||||
*/
|
||||
public boolean isPastAugust()
|
||||
{
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTimeZone(TIMEZONE);
|
||||
calendar.setTimeInMillis(getSqlTime());
|
||||
|
||||
if (calendar.get(Calendar.YEAR) == 2015 && calendar.get(Calendar.MONTH) == Calendar.AUGUST)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@ -6,9 +6,12 @@ import java.sql.Date;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.Map;
|
||||
|
||||
import com.sun.org.apache.xpath.internal.operations.Bool;
|
||||
import mineplex.core.bonuses.gui.SpinGui;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -289,7 +292,7 @@ public class BonusRepository extends RepositoryBase
|
||||
});
|
||||
}
|
||||
|
||||
public void attemptVoteBonus(final int accountId, final Callback<Date> result)
|
||||
public void attemptVoteBonus(final int accountId, final Callback<Pair<Boolean, Date>> result)
|
||||
{
|
||||
final int coins = 0;
|
||||
final int gems = 0;
|
||||
@ -307,12 +310,12 @@ public class BonusRepository extends RepositoryBase
|
||||
callableStatement.setInt(1, accountId);
|
||||
callableStatement.setInt(2, coins);
|
||||
callableStatement.setInt(3, gems);
|
||||
callableStatement.registerOutParameter(4, java.sql.Types.DATE);
|
||||
callableStatement.registerOutParameter(4, Types.BOOLEAN);
|
||||
callableStatement.registerOutParameter(5, Types.DATE);
|
||||
|
||||
callableStatement.executeUpdate();
|
||||
|
||||
final boolean pass = callableStatement.getBoolean(4);
|
||||
|
||||
final Date date = callableStatement.getDate(5);
|
||||
|
||||
Bukkit.getScheduler().runTask(plug, new Runnable() {
|
||||
@ -321,8 +324,7 @@ public class BonusRepository extends RepositoryBase
|
||||
public void run()
|
||||
{
|
||||
// _manager.Get(player).setVoteTime(date);
|
||||
result.run(date);
|
||||
|
||||
result.run(Pair.create(pass, date));
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
@ -94,7 +95,11 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
i++;
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
|
||||
BonusAmount amount = new BonusAmount();
|
||||
amount.setCoins(_poll.getCoinReward());
|
||||
amount.setGems(_poll.getCoinReward());
|
||||
amount.addLore(lore);
|
||||
// lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
|
||||
lore.add("");
|
||||
lore.add(C.cGreen + "Click to go to the vote page!");
|
||||
return ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, C.cGreen + C.Bold + "Vote on Poll", lore);
|
||||
@ -130,7 +135,10 @@ public class PollButton extends SimpleGui implements GuiItem {
|
||||
i++;
|
||||
}
|
||||
lore.add("");
|
||||
lore.add(C.cYellow + "Reward:" + C.cWhite + " 500 Gems");
|
||||
BonusAmount amount = new BonusAmount();
|
||||
amount.setCoins(_poll.getCoinReward());
|
||||
amount.setGems(_poll.getCoinReward());
|
||||
amount.addLore(lore);
|
||||
|
||||
return new SimpleGuiItem(ItemStackFactory.Instance.CreateStack(Material.BOOK_AND_QUILL, (byte) 0, 1, ChatColor.GREEN + C.cGreen + C.Bold + "Vote on Poll",
|
||||
lore));
|
||||
|
@ -78,7 +78,7 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
@Override
|
||||
public void click(ClickType clickType)
|
||||
{
|
||||
if (isAvailable()) {
|
||||
if (isAvailable() && _bonusManager.isPastAugust()) {
|
||||
_item = ItemStackFactory.Instance.CreateStack(Material.LAPIS_BLOCK, (byte)0, 1, ChatColor.BLUE + "Processing...");
|
||||
refreshItem();
|
||||
new LoadingWindow(getPlugin(), getPlayer(), 6*9);
|
||||
@ -144,44 +144,56 @@ public class RankBonusButton implements GuiItem, Listener {
|
||||
String itemName;
|
||||
byte data = 0;
|
||||
|
||||
if (!hasRank)
|
||||
if (_bonusManager.isPastAugust())
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus";
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly");
|
||||
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly");
|
||||
lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.WHITE + "Purchase a Rank at;");
|
||||
lore.add(ChatColor.WHITE + "www.mineplex.com/shop");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isAvailable())
|
||||
if (!hasRank)
|
||||
{
|
||||
material = Material.ENDER_CHEST;
|
||||
itemName = C.cGreen + C.Bold + "Rank Monthly Bonus";
|
||||
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus";
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click to Claim!");
|
||||
lore.add(ChatColor.WHITE + "Players with a Rank get a Monthly Bonus!");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.AQUA + "Ultra receives 7500 Coins Monthly");
|
||||
lore.add(ChatColor.LIGHT_PURPLE + "Hero receives 15000 Coins Monthly");
|
||||
lore.add(ChatColor.GREEN + "Legend receives 30000 Coins Monthly");
|
||||
lore.add(ChatColor.WHITE + "");
|
||||
lore.add(ChatColor.WHITE + "Purchase a Rank at;");
|
||||
lore.add(ChatColor.WHITE + "www.mineplex.com/shop");
|
||||
}
|
||||
else
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + C.Bold + "Rank Monthly Bonus";
|
||||
if (isAvailable())
|
||||
{
|
||||
material = Material.ENDER_CHEST;
|
||||
itemName = C.cGreen + C.Bold + "Rank Monthly Bonus";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Click to Claim!");
|
||||
}
|
||||
else
|
||||
{
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
itemName = C.cRed + C.Bold + "Rank Monthly Bonus";
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "Next reward in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
|
||||
lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name);
|
||||
BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
}
|
||||
|
||||
lore.add(" ");
|
||||
lore.add(C.cYellow + "Rank: " + C.cWhite + _bonusManager.getClientManager().Get(_player).GetRank().Name);
|
||||
BonusAmount bonusAmount = _bonusManager.getRankBonusAmount(_player);
|
||||
bonusAmount.addLore(lore);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemName = C.cRed + ChatColor.BOLD + "Rank Monthly Bonus";
|
||||
material = Material.REDSTONE_BLOCK;
|
||||
lore.add(" ");
|
||||
lore.add(ChatColor.RESET + "You can claim your Monthly Bonus");
|
||||
lore.add(ChatColor.RESET + "here, starting from September!");
|
||||
}
|
||||
|
||||
|
||||
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public class VoteButton implements GuiItem, Listener {
|
||||
public void setup()
|
||||
{
|
||||
//TODO get url from db
|
||||
_url = "http://minecraftservers.org/vote/121070";
|
||||
_url = _bonusManager.getVoteLink();
|
||||
|
||||
setItem();
|
||||
Bukkit.getPluginManager().registerEvents(this, getPlugin());
|
||||
|
@ -149,6 +149,7 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
{
|
||||
final String name = player.getName();
|
||||
final UUID uuid = player.getUniqueId();
|
||||
final int accountId = getClientManager().getAccountId(player);
|
||||
|
||||
// First update answer locally so we know it was answered
|
||||
Get(player).addAnswer(poll.getId(), answer);
|
||||
@ -169,17 +170,28 @@ public class PollManager extends MiniDbClientPlugin<PlayerPollData>
|
||||
{
|
||||
if (completed)
|
||||
{
|
||||
// Need to get out of Async code
|
||||
_plugin.getServer().getScheduler().runTask(_plugin, new Runnable()
|
||||
_donationManager.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
public void run(Boolean completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Poll", "Thanks for your response!"));
|
||||
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0);
|
||||
UtilPlayer.message(player, F.main("Gem", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!"));
|
||||
if (completed)
|
||||
{
|
||||
// Need to get out of Async code
|
||||
_plugin.getServer().getScheduler().runTask(_plugin, new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Carl", "Thanks for your response!"));
|
||||
player.playSound(player.getEyeLocation(), Sound.LEVEL_UP, 1F, 0);
|
||||
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Gems!"));
|
||||
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem(poll.getCoinReward() + "") + " Coins!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, "Poll", name, accountId, poll.getCoinReward());
|
||||
}
|
||||
}
|
||||
}, "Poll", name, uuid, poll.getCoinReward());
|
||||
|
@ -93,41 +93,45 @@ public class ServerManager
|
||||
public static RedisConfig getConfig(String fileName)
|
||||
{
|
||||
if (_config == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
File configFile = new File(fileName);
|
||||
|
||||
if (configFile.exists())
|
||||
{
|
||||
List<ConnectionData> connections = new ArrayList<ConnectionData>();
|
||||
List<String> lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset());
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
ConnectionData connection = deserializeConnection(line);
|
||||
connections.add(connection);
|
||||
|
||||
}
|
||||
|
||||
_config = new RedisConfig(connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
log(fileName + " not found at " + configFile.toPath().toString());
|
||||
_config = new RedisConfig();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
log("---Unable To Parse Redis Configuration File---");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_config = loadConfig(fileName);
|
||||
|
||||
return _config;
|
||||
}
|
||||
|
||||
public static RedisConfig loadConfig(String fileName)
|
||||
{
|
||||
try
|
||||
{
|
||||
File configFile = new File(fileName);
|
||||
|
||||
if (configFile.exists())
|
||||
{
|
||||
List<ConnectionData> connections = new ArrayList<ConnectionData>();
|
||||
List<String> lines = Files.readAllLines(configFile.toPath(), Charset.defaultCharset());
|
||||
|
||||
for (String line : lines)
|
||||
{
|
||||
ConnectionData connection = deserializeConnection(line);
|
||||
connections.add(connection);
|
||||
|
||||
}
|
||||
|
||||
return new RedisConfig(connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
log(fileName + " not found at " + configFile.toPath().toString());
|
||||
return new RedisConfig();
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
log("---Unable To Parse Redis Configuration File---");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line - the serialized line representing a valid {@link ConnectionData} object.
|
||||
|
@ -13,6 +13,7 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.bonuses.BonusAmount;
|
||||
import mineplex.core.bonuses.BonusClientData;
|
||||
import mineplex.core.bonuses.BonusManager;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.UUIDFetcher;
|
||||
import mineplex.core.database.DBPool;
|
||||
@ -45,8 +46,8 @@ public class VotifierManager extends MiniPlugin
|
||||
|
||||
private RedisConfig _usConfig;
|
||||
private RedisConfig _euConfig;
|
||||
private RedisDataRepository<PlayerStatus> _usPlayerRepo;
|
||||
private RedisDataRepository<PlayerStatus> _euPlayerRepo;
|
||||
// private RedisDataRepository<PlayerStatus> _usPlayerRepo;
|
||||
// private RedisDataRepository<PlayerStatus> _euPlayerRepo;
|
||||
private JedisPool _usWritePool;
|
||||
private JedisPool _euWritePool;
|
||||
|
||||
@ -58,13 +59,13 @@ public class VotifierManager extends MiniPlugin
|
||||
_donationManager = donationManager;
|
||||
_bonusManager = bonusManager;
|
||||
|
||||
_usConfig = ServerManager.getConfig("us-redis.dat");
|
||||
_euConfig = ServerManager.getConfig("eu-redis.dat");
|
||||
_usConfig = ServerManager.loadConfig("us-redis.dat");
|
||||
_euConfig = ServerManager.loadConfig("eu-redis.dat");
|
||||
|
||||
_usPlayerRepo = new RedisDataRepository<PlayerStatus>(_usConfig.getConnection(true, "DefaultConnection"),
|
||||
_usConfig.getConnection(false, "DefaultConnection"), Region.US, PlayerStatus.class, "playerStatus");
|
||||
_euPlayerRepo = new RedisDataRepository<PlayerStatus>(_euConfig.getConnection(true, "DefaultConnection"),
|
||||
_euConfig.getConnection(false, "DefaultConnection"), Region.EU, PlayerStatus.class, "playerStatus");
|
||||
// _usPlayerRepo = new RedisDataRepository<PlayerStatus>(_usConfig.getConnection(true, "DefaultConnection"),
|
||||
// _usConfig.getConnection(false, "DefaultConnection"), Region.US, PlayerStatus.class, "playerStatus");
|
||||
// _euPlayerRepo = new RedisDataRepository<PlayerStatus>(_euConfig.getConnection(true, "DefaultConnection"),
|
||||
// _euConfig.getConnection(false, "DefaultConnection"), Region.EU, PlayerStatus.class, "playerStatus");
|
||||
|
||||
_usWritePool = Utility.generatePool(_usConfig.getConnection(true, "DefaultConnection"));
|
||||
_euWritePool = Utility.generatePool(_euConfig.getConnection(true, "DefaultConnection"));
|
||||
@ -98,6 +99,7 @@ public class VotifierManager extends MiniPlugin
|
||||
public void run(Integer gems)
|
||||
{
|
||||
notifyServer(playerName, gems, false);
|
||||
notifyServer(playerName, gems, true);
|
||||
}
|
||||
});
|
||||
System.out.println();
|
||||
@ -146,7 +148,7 @@ public class VotifierManager extends MiniPlugin
|
||||
publishCommand(command, writePool);
|
||||
}
|
||||
|
||||
private void awardBonus(final String playerName, UUID uuid, final Callback<Integer> onComplete)
|
||||
private void awardBonus(final String playerName, final UUID uuid, final Callback<Integer> onComplete)
|
||||
{
|
||||
DSLContext create = DSL.using(DBPool.ACCOUNT, SQLDialect.MYSQL);
|
||||
|
||||
@ -158,52 +160,50 @@ public class VotifierManager extends MiniPlugin
|
||||
|
||||
final BonusAmount amount = _bonusManager.getVoteBonusAmount(client);
|
||||
|
||||
// Reward Amount
|
||||
if (amount.getTickets() > 0)
|
||||
client.setTickets(client.getTickets() + amount.getTickets());
|
||||
|
||||
if (amount.getTotalGems() > 0)
|
||||
{
|
||||
_donationManager.RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " gems to " + playerName);
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getGems() + " gems to " + playerName);
|
||||
}
|
||||
}, "Votifier", playerName, uuid, amount.getTotalGems());
|
||||
}
|
||||
|
||||
if (amount.getTotalCoins() > 0)
|
||||
{
|
||||
_donationManager.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " coins to " + playerName);
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getGems() + " coins to " + playerName);
|
||||
}
|
||||
}, "Votifier", playerName, accountId, amount.getTotalCoins());
|
||||
}
|
||||
|
||||
// Check if we need to reset vote streak
|
||||
_bonusManager.updateVoteStreak(client);
|
||||
|
||||
// Update time
|
||||
_bonusManager.getRepository().attemptVoteBonus(accountId, new Callback<Date>()
|
||||
_bonusManager.getRepository().attemptVoteBonus(accountId, new Callback<Pair<Boolean, Date>>()
|
||||
{
|
||||
@Override
|
||||
public void run(Date data)
|
||||
public void run(Pair<Boolean, Date> pair)
|
||||
{
|
||||
if (data != null)
|
||||
if (pair.getLeft())
|
||||
{
|
||||
client.getRecord().setVotetime(data);
|
||||
// Reward Amount
|
||||
if (amount.getTickets() > 0)
|
||||
client.setTickets(client.getTickets() + amount.getTickets());
|
||||
|
||||
if (amount.getTotalGems() > 0)
|
||||
{
|
||||
_donationManager.RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " gems to " + playerName);
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getGems() + " gems to " + playerName);
|
||||
}
|
||||
}, "Votifier", playerName, uuid, amount.getTotalGems());
|
||||
}
|
||||
|
||||
if (amount.getTotalCoins() > 0)
|
||||
{
|
||||
_donationManager.RewardCoins(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (data)
|
||||
System.out.println("Gave " + amount.getGems() + " coins to " + playerName);
|
||||
else
|
||||
System.out.println("Failed to give " + amount.getGems() + " coins to " + playerName);
|
||||
}
|
||||
}, "Votifier", playerName, accountId, amount.getTotalCoins());
|
||||
}
|
||||
|
||||
// Check if we need to reset vote streak
|
||||
_bonusManager.updateVoteStreak(client);
|
||||
client.getRecord().setVotetime(pair.getRight());
|
||||
|
||||
// Update Streak
|
||||
_bonusManager.incrementVoteStreak(client);
|
||||
@ -212,6 +212,10 @@ public class VotifierManager extends MiniPlugin
|
||||
System.out.println("Awarded carl ticket to " + playerName);
|
||||
onComplete.run(amount.getTotalGems());
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(playerName + " attempted to vote, vote bonus returned false!");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user