Remove voting code

This commit is contained in:
Shaun Bennett 2016-10-12 22:51:46 -04:00 committed by Shaun Bennett
parent 87122e9904
commit 62d08e74e3
9 changed files with 1 additions and 753 deletions

View File

@ -14,8 +14,6 @@ import mineplex.core.bonuses.event.CarlSpinnerEvent;
import mineplex.core.bonuses.gui.BonusGui;
import mineplex.core.bonuses.gui.SpinGui;
import mineplex.core.bonuses.gui.buttons.PowerPlayClubButton;
import mineplex.core.bonuses.redis.VoteHandler;
import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
@ -48,8 +46,6 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.youtube.YoutubeManager;
import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord;
import mineplex.serverdata.commands.ServerCommandManager;
import mineplex.serverdata.database.DBPool;
import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.EntityCreeper;
@ -93,7 +89,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private ArrayList<Player> _pendingExplosionsPlayers = new ArrayList<>();
private HashMap<String, Boolean> _showCarl = new HashMap<>();
private long _explode;
private boolean _canVote;
public static long getSqlTime()
{
@ -140,43 +135,10 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
private AnimationCarl _animation;
private int _visualTick;
// Streak
// private StreakRecord _dailyStreak;
// private StreakRecord _voteStreak;
private ArrayList<String> _voteList;
// Donor Queues
private Queue<GiveDonorData> _coinQueue;
private Queue<GiveDonorData> _gemQueue;
/**
* THIS SHOULD ONLY BE USED FOR VOTIFIER!
*/
public BonusManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager)
{
super("Bonus", plugin);
_enabled = false;
_repository = new BonusRepository(plugin, this, donationManager);
_clientManager = clientManager;
_donationManager = donationManager;
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, clientManager, donationManager);
System.out.print("VOTIFIER: ");
System.out.print("DONATION MANAGER - > " + _donationManager.toString());
_voteList = new ArrayList<>();
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
_coinQueue = new LinkedList<>();
_gemQueue = new LinkedList<>();
updateOffSet();
}
public BonusManager(JavaPlugin plugin, Location carlLocation, PlayWireManager playWireManager, CoreClientManager clientManager, DonationManager donationManager, PollManager pollManager, NpcManager npcManager, HologramManager hologramManager, StatsManager statsManager, InventoryManager inventoryManager, PetManager petManager, FacebookManager facebookManager, YoutubeManager youtubeManager, GadgetManager gadgetManager, ThankManager thankManager)
{
super("Bonus", plugin);
@ -204,12 +166,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_powerPlayClubRepository = new PowerPlayClubRepository(plugin, _clientManager, _donationManager);
_voteList = new ArrayList<>();
_voteList.add("http://vote1.mineplex.com");
_voteList.add("http://vote2.mineplex.com");
_voteList.add("http://vote3.mineplex.com");
_canVote = true;
_coinQueue = new LinkedList<>();
_gemQueue = new LinkedList<>();
@ -239,10 +195,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
clientManager.addStoredProcedureLoginProcessor(this);
//ServerCommandManager.getInstance().registerCommandType("VotifierCommand", VotifierCommand.class, new VoteHandler(this));
updateOffSet();
// updateStreakRecord();
}
@ -263,25 +216,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return;
updateOffSet();
}
public void handleVote(final Player player, final int shardsReceived)
{
final int accountId = _clientManager.getAccountId(player);
runAsync(() -> _repository.getClientData(accountId, data -> runSync(() ->
{
BonusClientData oldData = Get(player);
if (oldData != null) data.setHologram(oldData.getHologram());
Set(player, data);
_statsManager.incrementStat(player, "Global.DailyVote", 1);
addPendingExplosion(player, player.getName());
UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!"));
UtilPlayer.message(player, F.main("Carl", "You received " + F.elem("1 Carl Spinner Ticket") + "!"));
})));
}
@EventHandler
public void fireCreeper(UpdateEvent event)
@ -292,15 +226,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if(_pendingExplosions.isEmpty())
return;
if(!_canVote)
return;
if (!_enabled)
return;
_explode = System.currentTimeMillis();
_animation.setTicks(0);
_canVote = false;
}
@EventHandler
@ -311,9 +241,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
_animation.itemClean();
if(_canVote)
return;
if (!_enabled)
return;
@ -347,7 +274,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
DecreaseSize(creeper);
_pendingExplosions.remove(0);
_pendingExplosionsPlayers.remove(0);
_canVote = true;
}
@EventHandler
@ -385,7 +311,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
public static final long TIME_BETWEEN_BONUSES = 1000 * 60 * 60 * 20;
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<Boolean> result)
@ -509,20 +434,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
}
public void updateVoteStreak(BonusRecord client)
{
if (client.getVoteStreak() > 0 && client.getVotetime() != null)
{
long lastBonus = getLocalTime(client.getVotetime().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);
@ -533,14 +444,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
data.setMaxDailyStreak(data.getDailyStreak());
}
public void incrementVoteStreak(BonusRecord client)
{
client.setVoteStreak(client.getVoteStreak() + 1);
if (client.getVoteStreak() > client.getMaxVoteStreak())
client.setMaxVoteStreak(client.getVoteStreak());
}
public boolean continueStreak(long localLastBonus, long extendTime)
{
long maxTime = localLastBonus + TIME_BETWEEN_BONUSES + extendTime;
@ -581,13 +484,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return multiplier;
}
public int getVoteMultiplier(int streak)
{
int multiplier = Math.min(100, 5 * streak);
if (streak >= 20) multiplier += (1 * (streak - 40));
return multiplier;
}
public BonusAmount getDailyBonusAmount(Player player)
{
double mult = getDailyMultiplier(player) / 100.0;
@ -607,21 +503,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return amount;
}
public BonusAmount getVoteBonusAmount(Player player)
{
return getVoteBonusAmount(Get(player).getVoteStreak());
}
public BonusAmount getVoteBonusAmount(int voteStreak)
{
double mult = getVoteMultiplier(voteStreak) / 100.0;
BonusAmount amount = new BonusAmount();
amount.setTickets(1);
return amount;
}
public BonusAmount getRankBonusAmount(Player player)
{
Rank rank = _clientManager.Get(player).GetRank();
@ -648,25 +529,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
return data;
}
//VOTE
public long timeTillVoteBonus(Player player)
{
return nextVoteTime(player) - getLocalTime();
}
// This calculates the the next vote bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
public long nextVoteTime(Player player)
{
Date date = Get(player).getVoteTime();
if (date == null)
return 0;
long lastBonus = date.getTime();
return getNextVoteTime(getLocalTime(lastBonus));
}
public void awardBonus(final Player player, BonusAmount amount)
{
final BonusClientData bonusClient = Get(player);
@ -774,27 +636,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
}
}
public static long getNextVoteTime(long time) {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TIMEZONE);
calendar.setTimeInMillis(time);
calendar.add(Calendar.DAY_OF_YEAR, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTimeInMillis();
}
public boolean canVote(Player player)
{
long nextVoteTime = nextVoteTime(player);
return System.currentTimeMillis() >= nextVoteTime;
}
public boolean canDaily(Player player)
{
long nextDailyTime = nextDailyBonus(player);
@ -826,7 +667,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
int availableRewards = 0;
//if (canVote(player)) availableRewards++;
if (_playWireManager.canRedeem(player)) availableRewards++;
if (_youtubeManager.canYoutube(player)) availableRewards++;
if (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) availableRewards++;
@ -992,7 +832,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)*/_playWireManager.canRedeem(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
if(_pollManager.hasPoll(player) || _playWireManager.canRedeem(player) || (canRank(player) && _clientManager.hasRank(player, Rank.ULTRA) && isPastAugust()) || canDaily(player) || PowerPlayClubButton.isAvailable(player, _powerPlayClubRepository))
{
if(_showCarl.containsKey(player.getName()))
{
@ -1049,16 +889,6 @@ 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

View File

@ -1,185 +0,0 @@
package mineplex.core.bonuses.gui.buttons;
import java.util.ArrayList;
import mineplex.core.bonuses.BonusAmount;
import mineplex.core.bonuses.BonusClientData;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.gui.GuiItem;
import mineplex.core.gui.ItemRefresher;
import mineplex.core.shop.item.ShopItem;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
public class VoteButton implements GuiItem, Listener {
private ItemStack _item;
private String _url;
private Player _player;
private Plugin _plugin;
private ItemRefresher _gui;
private BonusManager _bonusManager;
public VoteButton(Plugin plugin, Player player, ItemRefresher gui, BonusManager bonusManager)
{
this._bonusManager = bonusManager;
this._player = player;
this._plugin = plugin;
this._gui = gui;
}
@Override
public void setup()
{
//TODO get url from db
_url = _bonusManager.getVoteLink();
setItem();
Bukkit.getPluginManager().registerEvents(this, getPlugin());
}
@Override
public void close()
{
HandlerList.unregisterAll(this);
}
@Override
public void click(ClickType clickType)
{
if (isAvailable())
{
getPlayer().closeInventory();
getPlayer().playSound(getPlayer().getLocation(), Sound.NOTE_PLING, 1, 1.6f);
UtilPlayer.message(getPlayer(), C.cGold + C.Bold + C.Strike + "=============================================");
UtilPlayer.message(getPlayer(), "");
new JsonMessage(" " + C.Bold + "Click to Open in Web Browser").click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
new JsonMessage( " " + C.cGreen + C.Line + _url).click(ClickEvent.OPEN_URL, _url).sendToPlayer(getPlayer());
UtilPlayer.message(getPlayer(), "");
UtilPlayer.message(getPlayer(), " Please be patient. Votes may take a few minutes to register.");
UtilPlayer.message(getPlayer(), "");
UtilPlayer.message(getPlayer(), C.cGold + C.Bold + C.Strike + "=============================================");
getPlayer().closeInventory();
}
else
{
getPlayer().playSound(getPlayer().getLocation(), Sound.ITEM_BREAK, 1, 10);
}
}
@Override
public ItemStack getObject()
{
return _item;
}
private void setItem()
{
ArrayList<String> lore = new ArrayList<String>();
Material material;
String itemName;
byte data = 0;
if (isAvailable())
{
material = Material.JUKEBOX;
itemName = C.cGreen + C.Bold + "Vote for Mineplex";
lore.add(" ");
lore.add(ChatColor.RESET + "Click to Vote!");
}
else
{
material = Material.REDSTONE_BLOCK;
itemName = C.cRed + C.Bold + "Vote for Mineplex";
lore.add(" ");
lore.add(ChatColor.RESET + "Next vote in " + UtilTime.convertString(timeLeft(), 0, TimeUnit.FIT) + "!");
}
lore.add(" ");
BonusClientData client = _bonusManager.Get(_player);
BonusAmount bonusAmount = _bonusManager.getVoteBonusAmount(_player);
bonusAmount.addLore(lore);
lore.add(" ");
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak());
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplier(client.getVoteStreak()) + "%");
if (client.getVoteTime() != null)
{
long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime());
long timeLeft = _bonusManager.getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME);
if (timeLeft > 0)
{
lore.add(C.cYellow + "Streak Reset: " + C.cWhite + UtilTime.convertString(timeLeft, 1, TimeUnit.FIT));
}
}
lore.add(" ");
lore.add(C.cYellow + "Highest Streak: " + C.cWhite + client.getMaxVoteStreak());
// StreakRecord streakRecord = _bonusManager.getVoteStreak();
// if (streakRecord != null)
// {
// lore.add(" ");
// lore.add(C.cYellow + "Record: " + C.cWhite + streakRecord.getPlayerName());
// lore.add(C.cYellow + "Streak: " + C.cWhite + streakRecord.getStreak());
// }
_item = new ShopItem(material, itemName, lore.toArray(new String[0]), 1, false, false);
}
public long timeLeft()
{
return _bonusManager.nextVoteTime(getPlayer()) - System.currentTimeMillis();
}
public boolean isAvailable()
{
if (_url == null)
return false;
return (timeLeft() <= 0);
}
public Plugin getPlugin()
{
return _plugin;
}
public Player getPlayer()
{
return _player;
}
public ItemRefresher getGui()
{
return _gui;
}
}

View File

@ -1,31 +0,0 @@
package mineplex.core.bonuses.redis;
import org.bukkit.entity.Player;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.common.util.UtilPlayer;
import mineplex.serverdata.commands.CommandCallback;
import mineplex.serverdata.commands.ServerCommand;
public class VoteHandler implements CommandCallback
{
private BonusManager _bonusManager;
public VoteHandler(BonusManager bonusManager)
{
_bonusManager = bonusManager;
}
@Override
public void run(ServerCommand command)
{
VotifierCommand v = ((VotifierCommand) command);
Player player = UtilPlayer.searchExact(v.getPlayerName());
if (player != null)
{
_bonusManager.handleVote(player, v.getShardsReceived());
}
}
}

View File

@ -1,28 +0,0 @@
package mineplex.core.bonuses.redis;
import mineplex.serverdata.commands.ServerCommand;
public class VotifierCommand extends ServerCommand
{
private String _playerName;
private int _shardsReceived;
public VotifierCommand(String playerName, int shardsReceived, String... targetServer)
{
super(targetServer);
_playerName = playerName;
_shardsReceived = shardsReceived;
}
public String getPlayerName()
{
return _playerName;
}
public int getShardsReceived()
{
return _shardsReceived;
}
}

View File

@ -1,3 +0,0 @@
name: MineplexVotifier
main: mineplex.votifier.Votifier
version: 0.1

View File

@ -1,27 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.mineplex</groupId>
<artifactId>mineplex-plugin</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../plugin.xml</relativePath>
</parent>
<name>MineplexVotifier</name>
<artifactId>mineplex-votifier</artifactId>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>mineplex-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>votifier</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -1,33 +0,0 @@
package mineplex.votifier;
import mineplex.core.account.CoreClientManager;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.command.CommandCenter;
import mineplex.core.donation.DonationManager;
import org.bukkit.plugin.java.JavaPlugin;
/**
* Created by shaun on 15-08-05.
*/
public class Votifier extends JavaPlugin
{
private String WEB_CONFIG = "webServer";
@Override
public void onEnable()
{
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
String webServerAddress = getConfig().getString(WEB_CONFIG);
CommandCenter.Initialize(this);
CoreClientManager clientManager = new CoreClientManager(this, webServerAddress);
DonationManager donationManager = new DonationManager(this, clientManager, webServerAddress);
BonusManager bonusManager = new BonusManager(this, clientManager, donationManager);
VotifierManager vote = new VotifierManager(this, clientManager, donationManager, bonusManager);
}
}

View File

@ -1,268 +0,0 @@
package mineplex.votifier;
import java.sql.Date;
import java.util.UUID;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.bonuses.BonusAmount;
import mineplex.core.bonuses.BonusManager;
import mineplex.core.bonuses.redis.VotifierCommand;
import mineplex.core.common.Pair;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.donation.DonationManager;
import mineplex.database.Tables;
import mineplex.database.tables.records.BonusRecord;
import mineplex.serverdata.Region;
import mineplex.serverdata.Utility;
import mineplex.serverdata.commands.ServerCommand;
import mineplex.serverdata.data.PlayerStatus;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.redis.RedisConfig;
import mineplex.serverdata.redis.RedisDataRepository;
import mineplex.serverdata.servers.ServerManager;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import org.jooq.DSLContext;
import org.jooq.Record1;
import org.jooq.SQLDialect;
import org.jooq.impl.DSL;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import com.vexsoftware.votifier.model.Vote;
import com.vexsoftware.votifier.model.VotifierEvent;
/**
* Created by shaun on 15-08-05.
*/
public class VotifierManager extends MiniPlugin
{
private CoreClientManager _clientManager;
private DonationManager _donationManager;
private BonusManager _bonusManager;
private RedisConfig _usConfig;
private RedisConfig _euConfig;
private RedisDataRepository<PlayerStatus> _usPlayerRepo;
private RedisDataRepository<PlayerStatus> _euPlayerRepo;
private JedisPool _usWritePool;
private JedisPool _euWritePool;
public VotifierManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, BonusManager bonusManager)
{
super("Votifier", plugin);
_clientManager = clientManager;
_donationManager = donationManager;
_bonusManager = bonusManager;
_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");
_usWritePool = Utility.generatePool(_usConfig.getConnection(true, "DefaultConnection"));
_euWritePool = Utility.generatePool(_euConfig.getConnection(true, "DefaultConnection"));
}
@EventHandler
public void handleVote(VotifierEvent event)
{
final Vote vote = event.getVote();
final String playerName = vote.getUsername();
System.out.println("New Vote: " + playerName);
runAsync(new Runnable()
{
@Override
public void run()
{
UUID uuid = UUIDFetcher.getUUIDOf(playerName);
if (uuid == null)
{
System.out.println("Failed to load UUID of " + playerName + " from UUIDFetcher. Trying with database");
uuid = _clientManager.loadUUIDFromDB(playerName);
if (uuid == null)
{
System.out.println("Failed to load UUID from database. Giving up on " + playerName);
}
}
String lowerPlayerName = playerName.toLowerCase();
final PlayerStatus usStatus = _usPlayerRepo.getElement(lowerPlayerName);
final PlayerStatus euStatus = _euPlayerRepo.getElement(lowerPlayerName);
System.out.println("Loaded " + playerName + " with uuid " + uuid);
System.out.println("Attempting to award bonus");
final UUID finalUuid = uuid;
awardBonus(playerName, finalUuid, new Callback<Integer>()
{
@Override
public void run(final Integer shards)
{
runSync(new Runnable()
{
@Override
public void run()
{
if (usStatus != null)
{
System.out.println("Found " + playerName + " on US " + usStatus.getServer());
notifyServer(playerName, shards, Region.US, usStatus.getServer());
}
if (euStatus != null)
{
System.out.println("Found " + playerName + " on EU " + euStatus.getServer());
notifyServer(playerName, shards, Region.EU, euStatus.getServer());
}
}
});
}
});
}
});
System.out.println();
System.out.println();
// 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);
// }
// 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, true);
}
private void notifyServer(String playerName, int shards, Region region, String targetServer)
{
JedisPool writePool = region == Region.EU ? _euWritePool : _usWritePool;
VotifierCommand command = new VotifierCommand(playerName, shards, targetServer);
publishCommand(command, writePool);
}
private void awardBonus(final String playerName, final UUID uuid, final Callback<Integer> onComplete)
{
DSLContext create = DSL.using(DBPool.getAccount(), SQLDialect.MYSQL);
Record1<Integer> idRecord = create.select(Tables.accounts.id).from(Tables.accounts).where(Tables.accounts.uuid.eq(uuid.toString())).fetchOne();
if (idRecord != null)
{
final int accountId = idRecord.value1();
final BonusRecord client = _bonusManager.getRepository().loadRecord(playerName, accountId);
final BonusAmount amount = _bonusManager.getVoteBonusAmount(client.getVoteStreak());
_bonusManager.getRepository().attemptVoteBonus(accountId, new Callback<Pair<Boolean, Date>>()
{
@Override
public void run(Pair<Boolean, Date> pair)
{
if (pair.getLeft())
{
// 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.getCoins() + " coins to " + playerName);
else
System.out.println("Failed to give " + amount.getCoins() + " coins to " + playerName);
}
}, "Votifier", playerName, accountId, amount.getTotalCoins());
}
// Check if we need to reset vote streak
_bonusManager.updateVoteStreak(client);
client.setVotetime(pair.getRight());
// Update Streak
_bonusManager.incrementVoteStreak(client);
client.store();
System.out.println("Awarded carl ticket to " + playerName);
onComplete.run(amount.getTotalCoins());
}
else
{
System.out.println(playerName + " attempted to vote, vote bonus returned false!");
}
}
});
}
}
private void publishCommand(final ServerCommand serverCommand, final JedisPool writePool)
{
new Thread(new Runnable()
{
public void run()
{
try (Jedis jedis = writePool.getResource())
{
String commandType = serverCommand.getClass().getSimpleName();
String serializedCommand = Utility.serialize(serverCommand);
jedis.publish("commands.server" + ":" + commandType, serializedCommand);
}
}
}).start();
}
}

View File

@ -34,7 +34,6 @@
<module>Mineplex.ServerData</module>
<module>Mineplex.ServerMonitor</module>
<module>Mineplex.StaffServer</module>
<module>Mineplex.Votifier</module>
<module>Nautilus.Game.Arcade</module>
<module>mavericks-review-hub</module>
@ -61,12 +60,6 @@
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.vexsoftware</groupId>
<artifactId>votifier</artifactId>
<version>1.9</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>