Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
6ef3215516
@ -8,107 +8,111 @@ import mineplex.database.tables.records.BonusRecord;
|
|||||||
|
|
||||||
public class BonusClientData
|
public class BonusClientData
|
||||||
{
|
{
|
||||||
private BonusRecord _record;
|
|
||||||
private Hologram _hologram;
|
private Hologram _hologram;
|
||||||
|
|
||||||
public BonusClientData(BonusRecord record)
|
private int _accountId;
|
||||||
{
|
private Timestamp _dailyTime;
|
||||||
_record = record;
|
private Date _rankTime;
|
||||||
}
|
private Date _voteTime;
|
||||||
|
private int _dailyStreak;
|
||||||
|
private int _maxDailyStreak;
|
||||||
|
private int _voteStreak;
|
||||||
|
private int _maxVoteStreak;
|
||||||
|
private int _tickets;
|
||||||
|
|
||||||
public BonusRecord getRecord()
|
public BonusClientData()
|
||||||
{
|
{
|
||||||
return _record;
|
_accountId = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAccountId(Integer value)
|
public void setAccountId(Integer value)
|
||||||
{
|
{
|
||||||
_record.setAccountId(value);
|
_accountId = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getAccountId()
|
public Integer getAccountId()
|
||||||
{
|
{
|
||||||
return _record.getAccountId();
|
return _accountId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDailyTime(Timestamp value)
|
public void setDailyTime(Timestamp value)
|
||||||
{
|
{
|
||||||
_record.setDailytime(value);
|
_dailyTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getDailyTime()
|
public Timestamp getDailyTime()
|
||||||
{
|
{
|
||||||
return _record.getDailytime();
|
return _dailyTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRankTime(Date value)
|
public void setRankTime(Date value)
|
||||||
{
|
{
|
||||||
_record.setRanktime(value);
|
_rankTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getRankTime()
|
public Date getRankTime()
|
||||||
{
|
{
|
||||||
return _record.getRanktime();
|
return _rankTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVoteTime(Date value)
|
public void setVoteTime(Date value)
|
||||||
{
|
{
|
||||||
_record.setVotetime(value);
|
_voteTime = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getVoteTime()
|
public Date getVoteTime()
|
||||||
{
|
{
|
||||||
return _record.getVotetime();
|
return _voteTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDailyStreak(Integer value)
|
public void setDailyStreak(Integer value)
|
||||||
{
|
{
|
||||||
_record.setDailyStreak(value);
|
_dailyStreak = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDailyStreak()
|
public Integer getDailyStreak()
|
||||||
{
|
{
|
||||||
return _record.getDailyStreak();
|
return _dailyStreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxDailyStreak(Integer value)
|
public void setMaxDailyStreak(Integer value)
|
||||||
{
|
{
|
||||||
_record.setMaxDailyStreak(value);
|
_maxDailyStreak = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxDailyStreak()
|
public Integer getMaxDailyStreak()
|
||||||
{
|
{
|
||||||
return _record.getMaxDailyStreak();
|
return _maxDailyStreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVoteStreak(Integer value)
|
public void setVoteStreak(Integer value)
|
||||||
{
|
{
|
||||||
_record.setVoteStreak(value);
|
_voteStreak = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getVoteStreak()
|
public Integer getVoteStreak()
|
||||||
{
|
{
|
||||||
return _record.getVoteStreak();
|
return _voteStreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxVoteStreak(Integer value)
|
public void setMaxVoteStreak(Integer value)
|
||||||
{
|
{
|
||||||
_record.setMaxVoteStreak(value);
|
_maxVoteStreak = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMaxVoteStreak()
|
public Integer getMaxVoteStreak()
|
||||||
{
|
{
|
||||||
return _record.getMaxVoteStreak();
|
return _maxVoteStreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTickets(Integer value)
|
public void setTickets(Integer value)
|
||||||
{
|
{
|
||||||
_record.setTickets(value);
|
_tickets = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getTickets()
|
public Integer getTickets()
|
||||||
{
|
{
|
||||||
return _record.getTickets();
|
return _tickets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hologram getHologram()
|
public Hologram getHologram()
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package mineplex.core.bonuses;
|
package mineplex.core.bonuses;
|
||||||
|
|
||||||
import java.sql.Date;
|
import java.sql.Date;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
@ -14,6 +16,7 @@ import java.util.TimeZone;
|
|||||||
import mineplex.core.MiniClientPlugin;
|
import mineplex.core.MiniClientPlugin;
|
||||||
import mineplex.core.account.CoreClient;
|
import mineplex.core.account.CoreClient;
|
||||||
import mineplex.core.account.CoreClientManager;
|
import mineplex.core.account.CoreClientManager;
|
||||||
|
import mineplex.core.account.ILoginProcessor;
|
||||||
import mineplex.core.account.IQuerylessLoginProcessor;
|
import mineplex.core.account.IQuerylessLoginProcessor;
|
||||||
import mineplex.core.account.event.ClientUnloadEvent;
|
import mineplex.core.account.event.ClientUnloadEvent;
|
||||||
import mineplex.core.bonuses.redis.VoteHandler;
|
import mineplex.core.bonuses.redis.VoteHandler;
|
||||||
@ -52,6 +55,7 @@ import mineplex.core.bonuses.gui.SpinGui;
|
|||||||
import mineplex.core.poll.PollManager;
|
import mineplex.core.poll.PollManager;
|
||||||
import mineplex.serverdata.commands.ServerCommandManager;
|
import mineplex.serverdata.commands.ServerCommandManager;
|
||||||
|
|
||||||
|
import org.jooq.DSLContext;
|
||||||
import org.jooq.SQLDialect;
|
import org.jooq.SQLDialect;
|
||||||
import org.jooq.impl.DSL;
|
import org.jooq.impl.DSL;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -69,7 +73,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
|||||||
import net.minecraft.server.v1_7_R4.DataWatcher;
|
import net.minecraft.server.v1_7_R4.DataWatcher;
|
||||||
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityMetadata;
|
||||||
|
|
||||||
public class BonusManager extends MiniClientPlugin<BonusClientData> implements IQuerylessLoginProcessor
|
public class BonusManager extends MiniClientPlugin<BonusClientData> implements ILoginProcessor
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
|
public static final TimeZone TIMEZONE = TimeZone.getTimeZone("UTC");
|
||||||
@ -276,17 +280,24 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
|
|
||||||
public void handleVote(final Player player, final int gemsRecieved)
|
public void handleVote(final Player player, final int gemsRecieved)
|
||||||
{
|
{
|
||||||
|
final int accountId = _clientManager.getAccountId(player);
|
||||||
|
|
||||||
runAsync(new Runnable()
|
runAsync(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
Get(player).getRecord().refresh();
|
_repository.getClientData(accountId, new Callback<BonusClientData>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run(final BonusClientData data)
|
||||||
|
{
|
||||||
runSync(new Runnable()
|
runSync(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
|
Set(player, data);
|
||||||
_statsManager.incrementStat(player, "Global.DailyVote", 1);
|
_statsManager.incrementStat(player, "Global.DailyVote", 1);
|
||||||
addPendingExplosion(player, player.getName());
|
addPendingExplosion(player, player.getName());
|
||||||
UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!"));
|
UtilPlayer.message(player, F.main("Carl", "Thanks for voting for Mineplex!"));
|
||||||
@ -295,6 +306,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -434,7 +447,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
// This calculates the the next daily bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
|
// This calculates the the next daily bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
|
||||||
public long nextDailyBonus(Player player)
|
public long nextDailyBonus(Player player)
|
||||||
{
|
{
|
||||||
Timestamp timestamp = Get(player).getRecord().getDailytime();
|
Timestamp timestamp = Get(player).getDailyTime();
|
||||||
|
|
||||||
if (timestamp == null)
|
if (timestamp == null)
|
||||||
return 0;
|
return 0;
|
||||||
@ -506,7 +519,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
// This calculates the the next rank bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
|
// This calculates the the next rank bonus, IT HAS TO MATCH THE MYSQL STORED FUNCTION.
|
||||||
public long nextRankBonus(Player player)
|
public long nextRankBonus(Player player)
|
||||||
{
|
{
|
||||||
Date date = Get(player).getRecord().getRanktime();
|
Date date = Get(player).getRankTime();
|
||||||
|
|
||||||
if (date == null)
|
if (date == null)
|
||||||
return 0;
|
return 0;
|
||||||
@ -532,16 +545,11 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateVoteStreak(Player player)
|
public void updateVoteStreak(BonusRecord client)
|
||||||
{
|
{
|
||||||
updateVoteStreak(Get(player));
|
if (client.getVoteStreak() > 0 && client.getVotetime() != null)
|
||||||
}
|
|
||||||
|
|
||||||
public void updateVoteStreak(BonusClientData client)
|
|
||||||
{
|
{
|
||||||
if (client.getVoteStreak() > 0 && client.getVoteTime() != null)
|
long lastBonus = getLocalTime(client.getVotetime().getTime());
|
||||||
{
|
|
||||||
long lastBonus = getLocalTime(client.getVoteTime().getTime());
|
|
||||||
long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME);
|
long timeLeft = getStreakTimeRemaining(lastBonus, BonusManager.VOTE_STREAK_RESET_TIME);
|
||||||
|
|
||||||
if (timeLeft < 0)
|
if (timeLeft < 0)
|
||||||
@ -561,7 +569,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
data.setMaxDailyStreak(data.getDailyStreak());
|
data.setMaxDailyStreak(data.getDailyStreak());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void incrementVoteStreak(BonusClientData client)
|
public void incrementVoteStreak(BonusRecord client)
|
||||||
{
|
{
|
||||||
client.setVoteStreak(client.getVoteStreak() + 1);
|
client.setVoteStreak(client.getVoteStreak() + 1);
|
||||||
|
|
||||||
@ -609,10 +617,8 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
return multiplyer;
|
return multiplyer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVoteMultiplyer(BonusClientData client)
|
public int getVoteMultiplyer(int streak)
|
||||||
{
|
{
|
||||||
int streak = client.getVoteStreak();
|
|
||||||
|
|
||||||
int multiplyer = Math.min(100, 5 * streak);
|
int multiplyer = Math.min(100, 5 * streak);
|
||||||
if (streak >= 20) multiplyer += (1 * (streak - 40));
|
if (streak >= 20) multiplyer += (1 * (streak - 40));
|
||||||
return multiplyer;
|
return multiplyer;
|
||||||
@ -639,12 +645,12 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
|
|
||||||
public BonusAmount getVoteBonusAmount(Player player)
|
public BonusAmount getVoteBonusAmount(Player player)
|
||||||
{
|
{
|
||||||
return getVoteBonusAmount(Get(player));
|
return getVoteBonusAmount(Get(player).getVoteStreak());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BonusAmount getVoteBonusAmount(BonusClientData client)
|
public BonusAmount getVoteBonusAmount(int voteStreak)
|
||||||
{
|
{
|
||||||
double mult = getVoteMultiplyer(client) / 100.0;
|
double mult = getVoteMultiplyer(voteStreak) / 100.0;
|
||||||
|
|
||||||
BonusAmount amount = new BonusAmount();
|
BonusAmount amount = new BonusAmount();
|
||||||
amount.setTickets(1);
|
amount.setTickets(1);
|
||||||
@ -949,9 +955,7 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
@Override
|
@Override
|
||||||
protected BonusClientData AddPlayer(String player)
|
protected BonusClientData AddPlayer(String player)
|
||||||
{
|
{
|
||||||
// Should never be called!
|
return new BonusClientData();
|
||||||
BonusRecord record = new BonusRecord();
|
|
||||||
return new BonusClientData(record);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BonusRepository getRepository()
|
public BonusRepository getRepository()
|
||||||
@ -978,6 +982,16 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
if (clientData.getHologram() != null)
|
if (clientData.getHologram() != null)
|
||||||
clientData.getHologram().stop();
|
clientData.getHologram().stop();
|
||||||
|
|
||||||
|
// Save streaks
|
||||||
|
runAsync(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
_repository.saveStreak(clientData.getAccountId(), clientData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// This shouldnt be necessary anymore
|
// This shouldnt be necessary anymore
|
||||||
// runAsync(new Runnable()
|
// runAsync(new Runnable()
|
||||||
// {
|
// {
|
||||||
@ -991,14 +1005,6 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
super.UnloadPlayer(event);
|
super.UnloadPlayer(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void processLogin(String playerName, int accountId)
|
|
||||||
{
|
|
||||||
BonusRecord record = _repository.loadRecord(playerName, accountId);
|
|
||||||
BonusClientData clientData = new BonusClientData(record);
|
|
||||||
Set(playerName, clientData);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addPendingExplosion(Player player, Object obj)
|
public void addPendingExplosion(Player player, Object obj)
|
||||||
{
|
{
|
||||||
_pendingExplosions.add(obj);
|
_pendingExplosions.add(obj);
|
||||||
@ -1131,4 +1137,16 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
Set(playerName, _repository.loadData(accountId, resultSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getQuery(int accountId, String uuid, String name)
|
||||||
|
{
|
||||||
|
return "SELECT * FROM bonus WHERE accountId = '" + accountId + "';";
|
||||||
|
}
|
||||||
}
|
}
|
@ -18,15 +18,18 @@ import mineplex.core.common.util.UtilPlayer;
|
|||||||
import mineplex.core.database.DBPool;
|
import mineplex.core.database.DBPool;
|
||||||
import mineplex.core.database.RepositoryBase;
|
import mineplex.core.database.RepositoryBase;
|
||||||
import mineplex.core.database.ResultSetCallable;
|
import mineplex.core.database.ResultSetCallable;
|
||||||
|
import mineplex.core.database.column.ColumnInt;
|
||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.recharge.Recharge;
|
import mineplex.core.recharge.Recharge;
|
||||||
import mineplex.database.Tables;
|
import mineplex.database.Tables;
|
||||||
import mineplex.database.tables.records.BonusRecord;
|
import mineplex.database.tables.records.BonusRecord;
|
||||||
|
import org.jooq.Configuration;
|
||||||
import org.jooq.DSLContext;
|
import org.jooq.DSLContext;
|
||||||
import org.jooq.Record2;
|
import org.jooq.Record2;
|
||||||
import org.jooq.SQLDialect;
|
import org.jooq.SQLDialect;
|
||||||
import org.jooq.TableField;
|
import org.jooq.TableField;
|
||||||
import org.jooq.impl.DSL;
|
import org.jooq.impl.DSL;
|
||||||
|
import org.jooq.impl.DefaultConfiguration;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -68,6 +71,40 @@ public class BonusRepository extends RepositoryBase
|
|||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BonusClientData loadData(final int accountId, ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
BonusClientData clientData = new BonusClientData();
|
||||||
|
clientData.setAccountId(accountId);
|
||||||
|
|
||||||
|
boolean foundClient = false;
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
foundClient = true;
|
||||||
|
clientData.setDailyTime(resultSet.getTimestamp(2));
|
||||||
|
clientData.setRankTime(resultSet.getDate(3));
|
||||||
|
clientData.setVoteTime(resultSet.getDate(4));
|
||||||
|
clientData.setDailyStreak(resultSet.getInt(5));
|
||||||
|
clientData.setMaxDailyStreak(resultSet.getInt(6));
|
||||||
|
clientData.setVoteStreak(resultSet.getInt(7));
|
||||||
|
clientData.setMaxVoteStreak(resultSet.getInt(8));
|
||||||
|
clientData.setTickets(resultSet.getInt(9));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundClient)
|
||||||
|
{
|
||||||
|
_manager.runAsync(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
executeInsert("INSERT IGNORE INTO bonus (accountId) VALUES (" + accountId + ")", null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientData;
|
||||||
|
}
|
||||||
|
|
||||||
public void getDailyStreakRecord(Callback<StreakRecord> callback)
|
public void getDailyStreakRecord(Callback<StreakRecord> callback)
|
||||||
{
|
{
|
||||||
getStreakRecord(Tables.bonus.maxDailyStreak, callback);
|
getStreakRecord(Tables.bonus.maxDailyStreak, callback);
|
||||||
@ -170,8 +207,6 @@ public class BonusRepository extends RepositoryBase
|
|||||||
|
|
||||||
final Timestamp timeStamp = callableStatement.getTimestamp(5);
|
final Timestamp timeStamp = callableStatement.getTimestamp(5);
|
||||||
|
|
||||||
_manager.Get(player).getRecord().update();
|
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(plug, new Runnable()
|
Bukkit.getScheduler().runTask(plug, new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -373,6 +408,30 @@ public class BonusRepository extends RepositoryBase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void getClientData(final int accountId, final Callback<BonusClientData> callback)
|
||||||
|
{
|
||||||
|
String query = "SELECT * FROM bonus WHERE accountId = '" + accountId + "';";
|
||||||
|
|
||||||
|
executeQuery(query, new ResultSetCallable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void processResultSet(ResultSet resultSet) throws SQLException
|
||||||
|
{
|
||||||
|
BonusClientData clientData = loadData(accountId, resultSet);
|
||||||
|
callback.run(clientData);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveStreak(int accountId, BonusClientData clientData)
|
||||||
|
{
|
||||||
|
jooq().update(Tables.bonus).set(Tables.bonus.dailyStreak, clientData.getDailyStreak())
|
||||||
|
.set(Tables.bonus.maxDailyStreak, clientData.getMaxDailyStreak())
|
||||||
|
.set(Tables.bonus.voteStreak, clientData.getVoteStreak())
|
||||||
|
.set(Tables.bonus.maxVoteStreak, clientData.getMaxVoteStreak())
|
||||||
|
.where(Tables.bonus.accountId.eq(accountId)).execute();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void initialize()
|
protected void initialize()
|
||||||
{
|
{
|
||||||
|
@ -130,7 +130,7 @@ public class VoteButton implements GuiItem, Listener {
|
|||||||
lore.add(" ");
|
lore.add(" ");
|
||||||
|
|
||||||
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak());
|
lore.add(C.cYellow + "Current Streak: " + C.cWhite + client.getVoteStreak());
|
||||||
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplyer(client) + "%");
|
lore.add(C.cYellow + "Streak Bonus: " + C.cWhite + "+" + _bonusManager.getVoteMultiplyer(client.getVoteStreak()) + "%");
|
||||||
if (client.getVoteTime() != null)
|
if (client.getVoteTime() != null)
|
||||||
{
|
{
|
||||||
long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime());
|
long lastBonus = _bonusManager.getLocalTime(client.getVoteTime().getTime());
|
||||||
|
@ -20,6 +20,7 @@ import mineplex.core.database.DBPool;
|
|||||||
import mineplex.core.donation.DonationManager;
|
import mineplex.core.donation.DonationManager;
|
||||||
import mineplex.core.bonuses.redis.VotifierCommand;
|
import mineplex.core.bonuses.redis.VotifierCommand;
|
||||||
import mineplex.database.Tables;
|
import mineplex.database.Tables;
|
||||||
|
import mineplex.database.tables.records.BonusRecord;
|
||||||
import mineplex.serverdata.Region;
|
import mineplex.serverdata.Region;
|
||||||
import mineplex.serverdata.Utility;
|
import mineplex.serverdata.Utility;
|
||||||
import mineplex.serverdata.commands.ServerCommand;
|
import mineplex.serverdata.commands.ServerCommand;
|
||||||
@ -184,9 +185,9 @@ public class VotifierManager extends MiniPlugin
|
|||||||
if (idRecord != null)
|
if (idRecord != null)
|
||||||
{
|
{
|
||||||
final int accountId = idRecord.value1();
|
final int accountId = idRecord.value1();
|
||||||
final BonusClientData client = new BonusClientData(_bonusManager.getRepository().loadRecord(playerName, accountId));
|
final BonusRecord client = _bonusManager.getRepository().loadRecord(playerName, accountId);
|
||||||
|
|
||||||
final BonusAmount amount = _bonusManager.getVoteBonusAmount(client);
|
final BonusAmount amount = _bonusManager.getVoteBonusAmount(client.getVoteStreak());
|
||||||
|
|
||||||
_bonusManager.getRepository().attemptVoteBonus(accountId, new Callback<Pair<Boolean, Date>>()
|
_bonusManager.getRepository().attemptVoteBonus(accountId, new Callback<Pair<Boolean, Date>>()
|
||||||
{
|
{
|
||||||
@ -231,12 +232,12 @@ public class VotifierManager extends MiniPlugin
|
|||||||
|
|
||||||
// Check if we need to reset vote streak
|
// Check if we need to reset vote streak
|
||||||
_bonusManager.updateVoteStreak(client);
|
_bonusManager.updateVoteStreak(client);
|
||||||
client.getRecord().setVotetime(pair.getRight());
|
client.setVotetime(pair.getRight());
|
||||||
|
|
||||||
// Update Streak
|
// Update Streak
|
||||||
_bonusManager.incrementVoteStreak(client);
|
_bonusManager.incrementVoteStreak(client);
|
||||||
|
|
||||||
client.getRecord().store();
|
client.store();
|
||||||
System.out.println("Awarded carl ticket to " + playerName);
|
System.out.println("Awarded carl ticket to " + playerName);
|
||||||
onComplete.run(amount.getTotalGems());
|
onComplete.run(amount.getTotalGems());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user