Compare commits

...
12 Commits
18 changed files with 234 additions and 84 deletions

No files matched your search

+2 -4
View File
@@ -28,10 +28,6 @@ BungeeDebug: false
# If false you need to enable
BungeeBroadcast: false
# If true & AllowUnJoined is false (Config.yml) it will remove any invalid players
# Not fully tested, could cause some trouble in some cases
RemoveInvalidUsers: false
# What server this is in bungee (must match)
# Also can be applied to rewards
Server: PleaseSet
@@ -41,11 +37,13 @@ Server: PleaseSet
# -----------------------------
# Bungee communication, add bungee host/port here
# For socket method
BungeeServer:
Host: '127.0.0.1'
Port: 1297
# Bungee communication, add this to bungee server
# For socket method
SpigotServer:
Host: '127.0.0.1'
Port: 1298
+3
View File
@@ -394,6 +394,9 @@ PreventRepeatMilestones: false
# Mainly to be used for alts and such
UsePrimaryAccountForPlaceholders: false
# If true, permissions will be handled differently
MultiplePermissionsCheck: false
AddCustomCommands: false
# Injects custom command to /vote
@@ -49,8 +49,12 @@ VoteParty:
GiveAllPlayers: false
# If true, the vote count will reset each day
ResetEachDay: false
# If true, the vote count will reset each week
ResetWeekly: false
# Reset at the end of the month
ResetMonthly: false
# If true, will give voteparty only once per day
OnlyOncePerDay: false
# Reset extra votes
ResetExtraVotesMonthly: false
# Count votes from /av vote?
+3
View File
@@ -47,14 +47,17 @@ AllowUnJoined: false
# ----------------------------
# Tell servers to broadcast
# For socket method
Broadcast: true
# Bungee communication, Add this to each spigot server
# For socket method
BungeeServer:
Host: '127.0.0.1'
Port: 1297
# Bungee communication, add each spigot server here
# For socket method
SpigotServers:
lobby:
Host: '127.0.0.1'
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>VotingPlugin</artifactId>
<version>6.1</version>
<version>6.1.1</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -9,6 +9,7 @@ import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.UserManager;
@@ -59,11 +60,12 @@ public class BungeeHandler {
String service = args.get(2);
long time = Long.parseLong(args.get(3));
plugin.debug("pluginmessaging vote received from " + player + " on " + service);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
player);
boolean wasOnline = Boolean.valueOf(args.get(4));
String text = args.get(6);
BungeeMessageData text = new BungeeMessageData(args.get(6));
user.clearCache();
@@ -94,9 +96,10 @@ public class BungeeHandler {
String uuid = args.get(1);
String service = args.get(2);
long time = Long.parseLong(args.get(3));
String text = args.get(6);
BungeeMessageData text = new BungeeMessageData(args.get(6));
plugin.debug("pluginmessaging voteonline received from " + player + " on " + service);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
player);
user.clearCache();
user.bungeeVotePluginMessaging(service, time, text);
@@ -146,6 +149,15 @@ public class BungeeHandler {
}
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
String server = args.get(0);
plugin.getPluginMessaging().sendPluginMessage("statusokay", server);
}
});
} else if (method.equals(BungeeMethod.SOCKETS)) {
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
@@ -634,9 +634,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
// vote party
voteParty = new VoteParty(this);
if (specialRewardsConfig.getVotePartyEnabled()) {
voteParty.check();
}
voteParty.register();
topVoterHandler.register();
@@ -773,7 +770,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
if (!contains) {
issues = false;
plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite()
+ ", may be an invalid service site. Vote on the site and look in console for a service site, if you get nothing then there is an issue with votifier");
+ ", may be an invalid service site. Please read: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
}
}
@@ -898,9 +895,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
pm.registerEvents(new BlockBreak(this), this);
pm.registerEvents(new PlayerInteract(this), this);
pm.registerEvents(new VotingPluginUpdateEvent(this), this);
/*if (!NMSManager.getInstance().isVersion("1.12")) {
pm.registerEvents(new PlayerCommandSendListener(this), this);
}*/
/*
* if (!NMSManager.getInstance().isVersion("1.12")) { pm.registerEvents(new
* PlayerCommandSendListener(this), this); }
*/
coolDownCheck = new CoolDownCheck(this);
pm.registerEvents(coolDownCheck, this);
@@ -0,0 +1,53 @@
package com.bencodez.votingplugin.bungee;
import java.util.regex.Pattern;
import lombok.Getter;
public class BungeeMessageData {
// Message string
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount
@Getter
private int allTimeTotal = 0;
@Getter
private int monthTotal = 0;
@Getter
private int weeklyTotal = 0;
@Getter
private int dailyTotal = 0;
@Getter
private int points = 0;
@Getter
private int milestoneCount = 0;
public BungeeMessageData(String str) {
String[] data = str.split(Pattern.quote("//"));
if (data.length >= 6) {
allTimeTotal = Integer.parseInt(data[0]);
monthTotal = Integer.parseInt(data[1]);
weeklyTotal = Integer.parseInt(data[2]);
dailyTotal = Integer.parseInt(data[3]);
points = Integer.parseInt(data[4]);
milestoneCount = Integer.parseInt(data[5]);
}
}
@Override
public String toString() {
return allTimeTotal + "//" + monthTotal + "//" + weeklyTotal + "//" + dailyTotal + "//" + points + "//"
+ milestoneCount;
}
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
int milestoneCount) {
this.allTimeTotal = allTimeTotal;
this.monthTotal = monthTotal;
this.weeklyTotal = weeklyTotal;
this.dailyTotal = dailyTotal;
this.points = points;
this.milestoneCount = milestoneCount;
}
}
@@ -245,9 +245,14 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
method = BungeeMethod.getByName(config.getBungeeMethod());
if (method == null) {
method = BungeeMethod.PLUGINMESSAGING;
}
this.getProxy().registerChannel("vp:vp");
if (method.equals(BungeeMethod.MYSQL)) {
this.getProxy().registerChannel("vp:vp");
// this.getProxy().registerChannel("vp:vp");
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
voteCacheFile = new VoteCache(this);
@@ -312,8 +317,6 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
}
}, 1l, 60l, TimeUnit.MINUTES);
this.getProxy().registerChannel("vp:vp");
} else if (method.equals(BungeeMethod.SOCKETS)) {
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
@@ -383,14 +386,23 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
DataOutputStream out = new DataOutputStream(outstream);
String subchannel = in.readUTF();
int size = in.readInt();
out.writeUTF(subchannel);
out.writeInt(size);
for (int i = 0; i < size; i++) {
out.writeUTF(in.readUTF());
}
for (String send : getProxy().getServers().keySet()) {
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(), outstream.toByteArray());
// check for status message returns
if (subchannel.equalsIgnoreCase("statusokay")) {
String server = in.readUTF();
getLogger().info("Status okay for " + server);
return;
} else {
// reforward message
out.writeUTF(subchannel);
out.writeInt(size);
for (int i = 0; i < size; i++) {
out.writeUTF(in.readUTF());
}
for (String send : getProxy().getServers().keySet()) {
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(), outstream.toByteArray());
}
}
}
} catch (Exception e) {
@@ -516,7 +528,22 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
}
public void status(CommandSender sender) {
sendServerMessage("status");
if (method.equals(BungeeMethod.SOCKETS)) {
sendServerMessage("status");
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
for (String s : getProxy().getServers().keySet()) {
if (!config.getBlockedServers().contains(s)) {
ServerInfo info = getProxy().getServerInfo(s);
if (info.getPlayers().isEmpty()) {
getLogger().info("No players on server " + s + " to send test status message");
} else {
// send
getLogger().info("Sending request for status message on " + s);
sendPluginMessageServer(s, "Status", s);
}
}
}
}
}
public void vote(String player, String service, boolean realVote) {
@@ -557,9 +584,18 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", uuid, DataType.STRING));
String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" + mysqlUpdate(data, uuid, "MonthTotal", 1)
+ "//" + mysqlUpdate(data, uuid, "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1)
+ "//" + mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid, "MilestoneCount", 1);
BungeeMessageData text = new BungeeMessageData(mysqlUpdate(data, uuid, "AllTimeTotal", 1),
mysqlUpdate(data, uuid, "MonthTotal", 1), mysqlUpdate(data, uuid, "WeeklyTotal", 1),
mysqlUpdate(data, uuid, "DailyTotal", 1), mysqlUpdate(data, uuid, "Points", 1),
mysqlUpdate(data, uuid, "MilestoneCount", 1));
/*
* String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" +
* mysqlUpdate(data, uuid, "MonthTotal", 1) + "//" + mysqlUpdate(data, uuid,
* "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1) + "//" +
* mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid,
* "MilestoneCount", 1);
*/
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
@@ -573,7 +609,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
cachedVotes.put(s, new ArrayList<OfflineBungeeVote>());
}
ArrayList<OfflineBungeeVote> list = cachedVotes.get(s);
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text));
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
cachedVotes.put(s, list);
debug("Caching vote for " + player + " on " + service + " for " + s);
@@ -581,7 +617,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
} else {
// send
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
Boolean.TRUE.toString(), "" + realVote, text);
Boolean.TRUE.toString(), "" + realVote, text.toString());
}
}
}
@@ -590,7 +626,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
if (p != null && p.isConnected()
&& !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
"" + time, Boolean.TRUE.toString(), "" + realVote, text);
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString());
} else {
if (!cachedOnlineVotes.containsKey(uuid)) {
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
@@ -599,7 +635,7 @@ public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.pl
if (list == null) {
list = new ArrayList<OfflineBungeeVote>();
}
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text));
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
cachedOnlineVotes.put(uuid, list);
debug("Caching online vote for " + player + " on " + service);
}
@@ -31,10 +31,14 @@ public class VotingPluginBungeeCommand extends Command {
if (args[0].equalsIgnoreCase("status")) {
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
sender.sendMessage(new TextComponent(
"Checking status, waiting for response, check console, only for socket method"));
"Checking status, waiting for response, check console, method: sockets"));
bungee.status(sender);
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)){
sender.sendMessage(new TextComponent(
"Checking status, waiting for response, check console, method: plugin messaging"));
bungee.status(sender);
} else {
sender.sendMessage(new TextComponent("Not using socket method, command unavailable"));
sender.sendMessage(new TextComponent("Not using socket/pluginmessage method, command unavailable"));
}
}
if (args[0].equalsIgnoreCase("help")) {
@@ -450,15 +450,16 @@ public class CommandLoader {
});
if (plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "PermsDebug" },
"VotingPlugin.Commands.AdminVote.PermsDebug", "Dev permission list, generate this list, requires dev debug") {
plugin.getAdminVoteCommand()
.add(new CommandHandler(new String[] { "PermsDebug" }, "VotingPlugin.Commands.AdminVote.PermsDebug",
"Dev permission list, generate this list, requires dev debug") {
@Override
public void execute(CommandSender sender, String[] args) {
sendMessage(sender, ArrayUtils.getInstance()
.convert(new AdminVotePerms(plugin, sender, 0).listPermsDev(sender)));
}
});
@Override
public void execute(CommandSender sender, String[] args) {
sendMessage(sender, ArrayUtils.getInstance()
.convert(new AdminVotePerms(plugin, sender, 0).listPermsDev(sender)));
}
});
}
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Reload" },
@@ -1247,7 +1248,7 @@ public class CommandLoader {
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.devDebug("Failed to set permission for /vote" + arg);
plugin.debug("Failed to set permission for /vote" + arg);
}
try {
@@ -1278,7 +1279,7 @@ public class CommandLoader {
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.devDebug("Failed to set permission for /vote");
plugin.debug("Failed to set permission for /vote");
}
}
}
@@ -1299,7 +1300,7 @@ public class CommandLoader {
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.devDebug("Failed to set permission for /adminvote" + arg);
plugin.debug("Failed to set permission for /adminvote" + arg);
}
try {
plugin.getCommand("adminvote" + arg).setExecutor(new CommandAliases(cmdHandle, true));
@@ -1332,7 +1333,7 @@ public class CommandLoader {
p.recalculatePermissibles();
}
} catch (Exception e) {
plugin.devDebug("Failed to set permission for /vote");
plugin.debug("Failed to set permission for /vote");
}
}
}
@@ -43,6 +43,10 @@ public class SpecialRewardsConfig extends YMLFile {
@Getter
private boolean votePartyResetExtraVotesMonthly = false;
@ConfigDataBoolean(path = "VoteParty.ResetCount")
@Getter
private boolean votePartyResetCount = true;
@Getter
private String votePartyRewardsPath = "VoteParty.Rewards";
@@ -229,9 +233,17 @@ public class SpecialRewardsConfig extends YMLFile {
return getData().getBoolean("VoteParty.ResetEachDay");
}
public boolean getVotePartyOnlyOncePerDay() {
return getData().getBoolean("VoteParty.OnlyOncePerDay");
}
public boolean getVotePartyResetMontly() {
return getData().getBoolean("VoteParty.ResetMonthly");
}
public boolean getVotePartyResetWeekly() {
return getData().getBoolean("VoteParty.ResetWeekly");
}
public int getVotePartyUserVotesRequired() {
return getData().getInt("VoteParty.UserVotesRequired");
@@ -239,4 +239,17 @@ public class ServerData {
public void updateValues() {
setVersion();
}
public boolean isLastVotePartySameDay() {
int num = getData().getInt("LastVoteParty", 0);
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
return true;
}
return false;
}
public void updateLastVoteParty() {
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
saveData();
}
}
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -37,7 +38,7 @@ public class PlayerVoteEvent extends Event {
@Getter
@Setter
private String bungeeTextTotals;
private BungeeMessageData bungeeTextTotals;
@Getter
@Setter
@@ -66,7 +67,7 @@ public class PlayerVoteEvent extends Event {
@Getter
@Setter
private VoteSite voteSite;
@Getter
@Setter
private VotingPluginUser votingPluginUser;
@@ -147,9 +147,9 @@ public class VoteSite {
*/
public ItemBuilder getItem() {
if (item == null) {
plugin.getLogger().warning("Invalid item section in site: " + key);
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid item for site: " + key)
.setLore("&cInvalid item for site: " + key);
plugin.getLogger().warning("Invalid display item section in site: " + key);
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid display item for site: " + key)
.setLore("&cInvalid display item for site: " + key);
} else {
return new ItemBuilder(item);
}
@@ -10,6 +10,7 @@ import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.events.PlayerSpecialRewardEvent;
import com.bencodez.votingplugin.events.SpecialRewardType;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -41,7 +42,7 @@ public class SpecialRewards {
return checkAllVotes;
}
public boolean checkCumualativeVotes(VotingPluginUser user, String bungeeTextTotals) {
public boolean checkCumualativeVotes(VotingPluginUser user, BungeeMessageData bungeeMessageData) {
boolean gotCumulativeAny = false;
Set<String> votes = plugin.getSpecialRewardsConfig().getCumulativeVotes();
for (String vote : votes) {
@@ -53,35 +54,30 @@ public class SpecialRewards {
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(votesRequired))) {
boolean gotCumulative = false;
int total = 0;
boolean useBungeeTotalNum = false;
String[] data = new String[] { "0", "0", "0", "0" };
if (bungeeTextTotals != null) {
data = bungeeTextTotals.split("//");
useBungeeTotalNum = true;
}
boolean useBungeeTotalNum = bungeeMessageData != null;
if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameDay(votesRequired)) {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.Daily);
} else {
total = Integer.parseInt(data[3]);
total = bungeeMessageData.getDailyTotal();
}
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameWeek(votesRequired)) {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.Weekly);
} else {
total = Integer.parseInt(data[2]);
total = bungeeMessageData.getWeeklyTotal();
}
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameMonth(votesRequired)) {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.Monthly);
} else {
total = Integer.parseInt(data[1]);
total = bungeeMessageData.getMonthTotal();
}
} else {
if (!useBungeeTotalNum) {
total = user.getTotal(TopVoter.AllTime);
} else {
total = Integer.parseInt(data[0]);
total = bungeeMessageData.getAllTimeTotal();
}
}
@@ -125,17 +121,14 @@ public class SpecialRewards {
return false;
}
public boolean checkMilestone(VotingPluginUser user, String bungeeTextTotals) {
public boolean checkMilestone(VotingPluginUser user, BungeeMessageData bungeeMessageData) {
int milestoneCount = user.getMilestoneCount();
if (bungeeTextTotals != null) {
String[] data = bungeeTextTotals.split("//");
if (data.length > 4) {
try {
milestoneCount = Integer.parseInt(data[5]);
} catch (Exception e) {
e.printStackTrace();
milestoneCount = user.getMilestoneCount();
}
if (bungeeMessageData != null) {
try {
milestoneCount = bungeeMessageData.getMilestoneCount();
} catch (Exception e) {
e.printStackTrace();
milestoneCount = user.getMilestoneCount();
}
}
if (plugin.getConfigFile().isPreventRepeatMilestones()) {
@@ -25,6 +25,7 @@ import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.user.UUID;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
import com.bencodez.votingplugin.bungee.BungeeMethod;
import com.bencodez.votingplugin.events.PlayerReceivePointsEvent;
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
@@ -192,7 +193,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
public void bungeeVotePluginMessaging(String service, long time, String bungeeTextTotals) {
public void bungeeVotePluginMessaging(String service, long time, BungeeMessageData text) {
if (plugin.getBungeeSettings().isUseBungeecoord()) {
VotingPluginMain.plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
@@ -203,7 +204,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
voteEvent.setForceBungee(true);
voteEvent.setTime(time);
voteEvent.setAddTotals(false);
voteEvent.setBungeeTextTotals(bungeeTextTotals);
voteEvent.setBungeeTextTotals(text);
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
@@ -15,6 +15,7 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
import com.bencodez.advancedcore.api.user.UUID;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.VotePartyEvent;
@@ -59,8 +60,12 @@ public class VoteParty implements Listener {
* Check.
*/
public void check() {
if (getTotalVotes() >= getVotesRequired()) {
setTotalVotes(getTotalVotes() - getVotesRequired());
if (getTotalVotes() >= getVotesRequired() && ((plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
&& plugin.getServerData().isLastVotePartySameDay())
|| !plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay())) {
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
setTotalVotes(getTotalVotes() - getVotesRequired());
}
VotePartyEvent event = new VotePartyEvent();
Bukkit.getPluginManager().callEvent(event);
@@ -74,6 +79,10 @@ public class VoteParty implements Listener {
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
plugin.getServerData().updateLastVoteParty();
}
}
}
@@ -190,20 +199,27 @@ public class VoteParty implements Listener {
giveReward(user);
}
}
reset();
reset(false);
}
@EventHandler
public void onDayChange(DayChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
reset();
reset(true);
}
}
@EventHandler
public void onWeekChange(WeekChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {
reset(true);
}
}
@EventHandler
public void onMonthChange(MonthChangeEvent event) {
if (plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {
reset();
reset(true);
}
if (plugin.getSpecialRewardsConfig().isVotePartyResetExtraVotesMonthly()) {
@@ -215,9 +231,11 @@ public class VoteParty implements Listener {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public void reset() {
public void reset(boolean override) {
if (override) {
setTotalVotes(0);
}
setVotedUsers(new ArrayList<String>());
setTotalVotes(0);
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
if (user.getVotePartyVotes() != 0) {