mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 17:10:03 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37e29b8643 | ||
|
|
f683cc66c1 | ||
|
|
2059832df8 | ||
|
|
bda5e61898 | ||
|
|
dcb5f67ba8 | ||
|
|
e6065f85cc | ||
|
|
e0d3d36349 | ||
|
|
ab4d2069eb | ||
|
|
84f8f9073d | ||
|
|
1e9828f594 | ||
|
|
a01050125b | ||
|
|
60957be6fe | ||
|
|
a2b094f7d8 | ||
|
|
56e9705a6e | ||
|
|
ad62da3221 | ||
|
|
c1421d6324 | ||
|
|
068c2b704e | ||
|
|
89d21044d2 | ||
|
|
98246613ca | ||
|
|
ee884ee06a | ||
|
|
355ca2cdf0 | ||
|
|
abc37be619 | ||
|
|
20d9c08630 | ||
|
|
523c9e4ef9 | ||
|
|
76b19f7fb3 | ||
|
|
d776d0d798 | ||
|
|
b63da09fe8 | ||
|
|
d626210804 | ||
|
|
777c198471 | ||
|
|
dbd52a9114 | ||
|
|
3208b865e6 |
No files matched your search
@@ -52,6 +52,13 @@ PerServerPoints: false
|
||||
# Should allow some compability with other plugins
|
||||
TriggerVotifierEvent: false
|
||||
|
||||
# If enabled plugin will give extra allsites reward if deterimned that it should
|
||||
# E.g. user votes offline for 7 days, they will only get 1 allsites reward by default
|
||||
# When enabled, they should get 7
|
||||
# Only applies to PLUGINMESSAGING
|
||||
# Recommend enabling ExtraAllSitesCheck in config.yml as well
|
||||
GiveExtraAllSitesRewards: false
|
||||
|
||||
# What server this is in bungee (must match)
|
||||
# Also can be applied to rewards
|
||||
Server: PleaseSet
|
||||
|
||||
@@ -576,13 +576,6 @@ DefaultRewardWorlds: []
|
||||
# Default blackedlisted worlds set for all rewards
|
||||
DefaultRewardBlackListedWorlds: []
|
||||
|
||||
# If enabled Config.yml will add new options as they are added to default file
|
||||
# Expiremental at this time, make backups
|
||||
# Still a WIP, DO NOT USE IN LIVE SERVERS
|
||||
# Use /av config update to do manual update if you so desire
|
||||
# Config backup will be made
|
||||
AutoConfigUpdating: false
|
||||
|
||||
###########################################
|
||||
# Skull settings
|
||||
###########################################
|
||||
|
||||
@@ -48,8 +48,11 @@ VoteSites:
|
||||
# Recommend: false
|
||||
VoteDelayDaily: false
|
||||
|
||||
#Offset time for /vote next caculations
|
||||
#TimeOffSet: 0
|
||||
# Replaces offset, set the exact hour based on server time
|
||||
# Include server time offset when setting this
|
||||
# 2 = 2 am server time
|
||||
# Use 1-24
|
||||
#VoteDelayDailyHour: 14
|
||||
|
||||
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
|
||||
# Setting this to true will execute the reward offline while the player is offline
|
||||
|
||||
@@ -16,6 +16,7 @@ softdepend:
|
||||
- AuthMe
|
||||
- SuperVanish
|
||||
- PremiumVanish
|
||||
- LuckPerms
|
||||
loadbefore:
|
||||
- MCPerks
|
||||
api-version: 1.13
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>${version.art}</artifactId>
|
||||
<version>6.14</version>
|
||||
<version>6.14.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -221,7 +221,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -415,7 +415,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -465,7 +465,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
|
||||
@@ -28,7 +28,6 @@ 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.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
@@ -286,8 +285,8 @@ public class BungeeHandler implements Listener {
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
@@ -349,6 +348,8 @@ public class BungeeHandler implements Listener {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
@@ -382,8 +383,8 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
plugin.debug(
|
||||
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
@@ -441,6 +442,8 @@ public class BungeeHandler implements Listener {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
@@ -455,7 +458,8 @@ public class BungeeHandler implements Listener {
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(player));
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(player));
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
@@ -484,8 +488,8 @@ public class BungeeHandler implements Listener {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
args.get(1));
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
@@ -502,8 +506,8 @@ public class BungeeHandler implements Listener {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String votes = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
args.get(1));
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
@@ -522,7 +526,7 @@ public class BungeeHandler implements Listener {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -57,7 +57,6 @@ import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.yml.YMLConfig;
|
||||
import com.bencodez.advancedcore.logger.Logger;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
import com.bencodez.votingplugin.commands.CommandLoader;
|
||||
import com.bencodez.votingplugin.commands.executers.CommandAdminVote;
|
||||
@@ -263,13 +262,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
if (ymlError) {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load a file, check startup log");
|
||||
}
|
||||
}, 10);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -936,7 +935,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -961,7 +960,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}, 1000, 1000 * 30, TimeUnit.MILLISECONDS);
|
||||
|
||||
}
|
||||
}, 40L);
|
||||
}, 2);
|
||||
|
||||
}
|
||||
|
||||
@@ -1064,7 +1063,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
coolDownCheck.checkEnabled();
|
||||
coolDownCheck.load();
|
||||
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1074,7 +1073,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
topVoterHandler = new TopVoterHandler(this);
|
||||
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1097,7 +1096,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
topVoterHandler.register();
|
||||
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1223,14 +1222,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
if (!issues) {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().warning(
|
||||
"Detected an issue with voting sites, check the server startup log for more details: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
|
||||
}
|
||||
}, 30l);
|
||||
}, 5);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1413,6 +1412,18 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
placeholders.reload();
|
||||
getCoolDownCheck().getTimer().schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (site.isVoteDelayDaily()) {
|
||||
getCoolDownCheck().checkAllVoteSite(site);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
|
||||
}
|
||||
|
||||
voteReminding.loadRemindChecking();
|
||||
@@ -1426,16 +1437,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
configFile = new Config(this);
|
||||
configFile.setup();
|
||||
|
||||
if (configFile.isAutoConfigUpdating()) {
|
||||
/*try {
|
||||
ConfigUpdater.update(plugin, "Config.yml", configFile.getdFile(),
|
||||
Arrays.asList("VoteReminding", "MySQL", "CustomCommands", "CustomPlaceholderReturns"));
|
||||
configFile.reloadData();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
}
|
||||
|
||||
configVoteSites = new ConfigVoteSites(this);
|
||||
configVoteSites.setup();
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -42,7 +43,6 @@ import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
import com.bencodez.advancedcore.api.yml.editor.ConfigEditor;
|
||||
import com.bencodez.advancedcore.api.yml.updater.ConfigUpdater;
|
||||
import com.bencodez.advancedcore.command.gui.UserGUI;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.executers.CommandAliases;
|
||||
import com.bencodez.votingplugin.commands.gui.AdminGUI;
|
||||
@@ -696,7 +696,7 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -705,7 +705,7 @@ public class CommandLoader {
|
||||
});
|
||||
|
||||
} else {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1259,6 +1259,29 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "CheckVoteCoolDownRewards" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.CheckVoteCoolDownRewards|" + adminPerm,
|
||||
"Force check all vote cooldown rewards") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
plugin.getCoolDownCheck().getTimer().schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (site.isVoteDelayDaily()) {
|
||||
plugin.getCoolDownCheck().checkAllVoteSite(site);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
sender.sendMessage(
|
||||
StringParser.getInstance().colorize("&cForce checking on vote cooldown rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "VoteSite", "(sitename)", "SetVoteURL", "(string)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite VoteURL") {
|
||||
@@ -1309,7 +1332,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1804,7 +1827,7 @@ public class CommandLoader {
|
||||
public void loadCommands() {
|
||||
loadAdminVoteCommand();
|
||||
loadVoteCommand();
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -2599,7 +2622,7 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, section.getString("Message", ""));
|
||||
for (String str : (ArrayList<String>) section.getList("Commands", new ArrayList<String>())) {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -369,6 +369,17 @@ public class AdminGUI {
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelayDailyHour", voteSite.getVoteDelayDailyHour()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -146,7 +146,14 @@ public class VoteShop extends GUIHandler {
|
||||
plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
} else {
|
||||
new VoteShopConfirm(plugin, player, user, identifier).open(GUIMethod.CHEST);
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new VoteShopConfirm(plugin, player, user, identifier).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -46,6 +46,11 @@ public class BungeeSettings extends YMLFile {
|
||||
@ConfigDataBoolean(path = "PerServerMilestones")
|
||||
@Getter
|
||||
private boolean perServerMilestones = false;
|
||||
|
||||
@ConfigDataBoolean(path = "GiveExtraAllSitesRewards")
|
||||
@Getter
|
||||
private boolean giveExtraAllSitesRewards = false;
|
||||
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerRewards")
|
||||
@Getter
|
||||
|
||||
@@ -695,10 +695,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean voteRemindingRemindOnlyOnce = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoConfigUpdating")
|
||||
@Getter
|
||||
private boolean autoConfigUpdating = false;
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
|
||||
@@ -168,8 +168,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
public int getTimeOffSet(String siteName) {
|
||||
return getData(siteName).getInt("TimeOffSet", 0);
|
||||
public int getVoteDelayDailyHour(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayDailyHour", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.bencodez.votingplugin.cooldown;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
@@ -14,12 +16,15 @@ import org.bukkit.event.Listener;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
@@ -33,6 +38,7 @@ public class CoolDownCheck implements Listener {
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
private boolean cooldownCheckEnabled = false;
|
||||
@@ -65,7 +71,7 @@ public class CoolDownCheck implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void check(VotingPluginUser user) {
|
||||
public synchronized void check(VotingPluginUser user) {
|
||||
boolean coolDownCheck = user.getCoolDownCheck();
|
||||
if (user.canVoteAll() && coolDownCheck) {
|
||||
user.setCoolDownCheck(false);
|
||||
@@ -79,13 +85,14 @@ public class CoolDownCheck implements Listener {
|
||||
|
||||
public synchronized void checkPerSite(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
boolean changed = false;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (user.canVoteSite(site)) {
|
||||
if (!coolDownChecks.containsKey(site) || !coolDownChecks.get(site).booleanValue()) {
|
||||
coolDownChecks.put(site, Boolean.TRUE);
|
||||
if (!coolDownChecks.containsKey(site.getKey()) || !coolDownChecks.get(site.getKey()).booleanValue()) {
|
||||
if (user.canVoteSite(site)) {
|
||||
coolDownChecks.put(site.getKey(), Boolean.TRUE);
|
||||
changed = true;
|
||||
plugin.extraDebug("Triggering votesitecooldownend event for " + user.getUUID());
|
||||
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
@@ -103,12 +110,12 @@ public class CoolDownCheck implements Listener {
|
||||
public void schedulePerSite(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeFirstSiteAvailable();
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time);
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time + " seconds");
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -126,19 +133,21 @@ public class CoolDownCheck implements Listener {
|
||||
public void schedule(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
check(uuid);
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
check(uuid);
|
||||
}
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
}, time+2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
}
|
||||
|
||||
@@ -169,6 +178,32 @@ public class CoolDownCheck implements Listener {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void checkAllVoteSite(VoteSite site) {
|
||||
plugin.getLogger().info("Checking vote cooldown rewards for all players: " + site.getKey());
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
checkPerSite(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
|
||||
@@ -39,7 +38,7 @@ public class BlockBreak implements Listener {
|
||||
if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign s = (Sign) event.getBlock().getState();
|
||||
final Location loc = s.getLocation();
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
@@ -9,7 +8,7 @@ import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
public class BungeeVotifierEvent {
|
||||
public void send(VotingPluginMain plugin, PlayerVoteEvent event) {
|
||||
plugin.debug("Triggering vote event");
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
|
||||
@@ -219,7 +218,7 @@ public class PlayerVoteListener implements Listener {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
|
||||
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -227,7 +226,7 @@ public class PlayerVoteListener implements Listener {
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -47,7 +46,7 @@ public class SignChange implements Listener {
|
||||
plugin.getServerData().addSign(event.getBlock().getLocation(), event.getLine(2),
|
||||
Integer.parseInt(event.getLine(1)));
|
||||
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&aAdded sign!"));
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -64,7 +64,7 @@ public class VoteSite {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private double timeOffSet;
|
||||
private int voteDelayDailyHour;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -230,7 +230,7 @@ public class VoteSite {
|
||||
voteDelayDaily = plugin.getConfigVoteSites().getVoteSiteResetVoteDelayDaily(key);
|
||||
giveOffline = plugin.getConfigVoteSites().getVoteSiteGiveOffline(key);
|
||||
waitUntilVoteDelay = plugin.getConfigVoteSites().getWaitUntilVoteDelay(key);
|
||||
timeOffSet = plugin.getConfigVoteSites().getTimeOffSet(key);
|
||||
voteDelayDailyHour = plugin.getConfigVoteSites().getVoteDelayDailyHour(key);
|
||||
hidden = plugin.getConfigVoteSites().getVoteSiteHidden(key);
|
||||
ignoreCanVote = plugin.getConfigVoteSites().getVoteSiteIgnoreCanVote(key);
|
||||
}
|
||||
@@ -247,7 +247,7 @@ public class VoteSite {
|
||||
str += ", VoteDelayDaily: " + isVoteDelayDaily();
|
||||
str += ", IsWaitUntilVoteDelay: " + isWaitUntilVoteDelay();
|
||||
str += ", ServiceSite: " + getServiceSite();
|
||||
str += ", TimeOffSet:" + getTimeOffSet();
|
||||
str += ", VoteDelayDailyHour:" + getVoteDelayDailyHour();
|
||||
str += ", Url: " + getVoteURL();
|
||||
str += ", IgnoreCanVote: " + isIgnoreCanVote();
|
||||
str += ", Hidden: " + isHidden();
|
||||
|
||||
@@ -607,6 +607,43 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_LastMonth_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getLastMonthTopVoter().entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at position in last month top voter"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_LastMonthVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getLastMonthTopVoter().entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getValue().intValue();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in last month top voter"));
|
||||
}
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Month_") {
|
||||
|
||||
@Override
|
||||
@@ -1075,6 +1112,9 @@ public class PlaceHolders {
|
||||
|
||||
public void onUpdate() {
|
||||
checkNonCachedPlaceholders();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(p), true);
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { for (String ident :
|
||||
|
||||
@@ -13,7 +13,6 @@ import org.bukkit.block.data.Directional;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -111,7 +110,7 @@ public class SignHandler {
|
||||
* Check valid sign.
|
||||
*/
|
||||
public void checkValidSign() {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -240,7 +239,7 @@ public class SignHandler {
|
||||
* @param delay the delay
|
||||
*/
|
||||
public void updateSign(int delay) {
|
||||
BukkitScheduler.runTaskLater(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
||||
@@ -77,7 +77,7 @@ public class Signs {
|
||||
} else {
|
||||
getSigns().get(i).updateLines();
|
||||
getSigns().get(i).updateSign(time);
|
||||
time += 5;
|
||||
time += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,23 @@ public class SpecialRewards {
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public void bungeeAllSitesCheck(VotingPluginUser user, int numberOfVotes, int num) {
|
||||
if (plugin.getBungeeSettings().isGiveExtraAllSitesRewards()) {
|
||||
int numberOfSites = plugin.getVoteSites().size();
|
||||
if (numberOfVotes >= numberOfSites * 2) {
|
||||
if (num > numberOfSites) {
|
||||
if (num % numberOfSites == 0) {
|
||||
// should give extra allsites?
|
||||
if (user.checkAllVotes()) {
|
||||
plugin.debug("Giving extra allsites reward from bungee");
|
||||
giveAllSitesRewards(user, user.isOnline(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkAlmostAllSites(VotingPluginUser user, boolean forceBungee) {
|
||||
boolean checkAllVotes = user.checkAlmostAllVotes();
|
||||
if (checkAllVotes) {
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.util.UUID;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
@@ -134,7 +133,7 @@ public class VoteTester {
|
||||
|
||||
public void testSpam(int amount, String name, String site) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -205,7 +205,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets() && plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
@@ -322,7 +322,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (!bungeeHandleResets()) {
|
||||
if (!bungeeHandleResets() && plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
@@ -432,7 +432,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets() && plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -73,7 +72,7 @@ public class CheckUpdate {
|
||||
if (plugin.getConfigFile().isDisableUpdateChecking()) {
|
||||
return;
|
||||
}
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -87,7 +86,7 @@ public class CheckUpdate {
|
||||
}, 1000 * 60 * 1200, 1000 * 60 * 1200);
|
||||
|
||||
}
|
||||
}, 10l);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class UserManager {
|
||||
manager.addKey(new UserDataKeyBoolean("TopVoterIgnore"));
|
||||
manager.addKey(new UserDataKeyInt("VotePartyVotes"));
|
||||
manager.addKey(new UserDataKeyString("LastVotes"));
|
||||
manager.addKey(new UserDataKeyBoolean("CoolDownCheck"));
|
||||
manager.addKey(new UserDataKeyBoolean(getCoolDownCheckPath()));
|
||||
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyInt("MilestoneCount"));
|
||||
manager.addKey(new UserDataKeyInt("MonthTotal"));
|
||||
@@ -60,6 +60,7 @@ public class UserManager {
|
||||
manager.addKey(new UserDataKeyInt("LastWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastDailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("BestMonthVoteStreak"));
|
||||
manager.addKey(new UserDataKeyString(getCoolDownCheckSitePath()).setColumnType("LONGTEXT"));
|
||||
if (plugin.getOptions().isPerServerRewards()) {
|
||||
manager.addKey(new UserDataKeyString("OfflineRewards" + plugin.getOptions().getServer())
|
||||
.setColumnType("MEDIUMTEXT"));
|
||||
@@ -84,6 +85,22 @@ public class UserManager {
|
||||
return "AlmostAllSitesLast";
|
||||
}
|
||||
|
||||
public String getCoolDownCheckSitePath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage() + "_Sites";
|
||||
} else {
|
||||
return "CoolDownCheck" + "_Sites";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCoolDownCheckPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
} else {
|
||||
return "CoolDownCheck";
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllUUIDs() {
|
||||
return plugin.getUserManager().getAllUUIDs();
|
||||
}
|
||||
|
||||
@@ -276,21 +276,19 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
|
||||
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime resetTime = plugin.getTimeChecker().getTime().withHour(voteSite.getVoteDelayDailyHour())
|
||||
.withMinute(0).withSecond(0);
|
||||
LocalDateTime resetTimeTomorrow = resetTime.plusHours(24);
|
||||
|
||||
if (!now.isBefore(offsetoclocktoday)) {
|
||||
if (!lastVote.isBefore(offsetoclocktoday)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
if (lastVote.isBefore(resetTimeTomorrow)) {
|
||||
if (lastVote.isBefore(resetTime)) {
|
||||
if (now.isAfter(resetTime)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!lastVote.isBefore(offsetoclockyesterday)) {
|
||||
return false;
|
||||
} else {
|
||||
if (now.isAfter(resetTimeTomorrow)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -451,8 +449,8 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return getData().getInt("LastMonthTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Boolean> getCoolDownCheckSiteList() {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = new HashMap<VoteSite, Boolean>();
|
||||
public HashMap<String, Boolean> getCoolDownCheckSiteList() {
|
||||
HashMap<String, Boolean> coolDownChecks = new HashMap<String, Boolean>();
|
||||
ArrayList<String> coolDownCheck = getData().getStringList(getCoolDownCheckSitePath(), isCacheData(),
|
||||
isWaitForCache());
|
||||
for (String str : coolDownCheck) {
|
||||
@@ -461,7 +459,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
VoteSite site = plugin.getVoteSite(data[0], true);
|
||||
if (site != null) {
|
||||
Boolean b = Boolean.valueOf(data[1]);
|
||||
coolDownChecks.put(site, b);
|
||||
coolDownChecks.put(site.getKey(), b);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -469,9 +467,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public boolean getCoolDownCheckSite(VoteSite site) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
if (coolDownChecks.containsKey(site)) {
|
||||
return coolDownChecks.get(site).booleanValue();
|
||||
HashMap<String, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
if (coolDownChecks.containsKey(site.getKey())) {
|
||||
return coolDownChecks.get(site.getKey()).booleanValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -951,18 +949,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
getUserData().setStringList("LastVotes", data);
|
||||
}
|
||||
|
||||
public void setCoolDownCheckSite(HashMap<VoteSite, Boolean> coolDownChecks) {
|
||||
public void setCoolDownCheckSite(HashMap<String, Boolean> coolDownChecks) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<VoteSite, Boolean> entry : coolDownChecks.entrySet()) {
|
||||
String str = entry.getKey().getKey() + "//" + entry.getValue().toString();
|
||||
for (Entry<String, Boolean> entry : coolDownChecks.entrySet()) {
|
||||
String str = entry.getKey() + "//" + entry.getValue().toString();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList(getCoolDownCheckSitePath(), data);
|
||||
}
|
||||
|
||||
public void setCoolDownCheckSite(VoteSite site, boolean value) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
coolDownChecks.put(site, Boolean.valueOf(value));
|
||||
HashMap<String, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
coolDownChecks.put(site.getKey(), Boolean.valueOf(value));
|
||||
setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
|
||||
@@ -1261,103 +1259,37 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
public String voteCommandNextInfo(VoteSite voteSite, long time) {
|
||||
String info = new String();
|
||||
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
|
||||
.plusHours(plugin.getOptions().getTimeHourOffSet());
|
||||
|
||||
if (!voteSite.isVoteDelayDaily()) {
|
||||
double votedelay = voteSite.getVoteDelay();
|
||||
if (votedelay == 0 && voteSite.getVoteDelayMin() == 0) {
|
||||
String errorMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoError();
|
||||
info = errorMsg;
|
||||
} else {
|
||||
|
||||
LocalDateTime nextvote = lastVote.plusHours((long) votedelay)
|
||||
.plusMinutes((long) voteSite.getVoteDelayMin());
|
||||
|
||||
if (time == 0 || now.isAfter(nextvote)) {
|
||||
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
|
||||
} else {
|
||||
Duration dur = Duration.between(now, nextvote);
|
||||
|
||||
long diffHours = dur.getSeconds() / (60 * 60);
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
|
||||
|
||||
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoTime();
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%",
|
||||
Long.toString(diffHours));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
info = timeMsg;
|
||||
|
||||
}
|
||||
}
|
||||
long nextTime = voteNextDurationTime(voteSite, time);
|
||||
if (nextTime == 0) {
|
||||
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
|
||||
} else {
|
||||
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
|
||||
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
int diffHours = (int) (nextTime / (60 * 60));
|
||||
long diffMinutes = nextTime / 60 - diffHours * 60;
|
||||
|
||||
if (!now.isBefore(offsetoclocktoday)) {
|
||||
if (!lastVote.isBefore(offsetoclocktoday)) {
|
||||
Duration dur = Duration.between(now, offsetoclocktomorrow);
|
||||
int diffHours = (int) (dur.getSeconds() / (60 * 60));
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
|
||||
|
||||
if (diffHours < 0) {
|
||||
diffHours = diffHours * -1;
|
||||
}
|
||||
if (diffHours >= 24) {
|
||||
diffHours = diffHours - 24;
|
||||
}
|
||||
if (diffMinutes < 0) {
|
||||
diffMinutes = diffMinutes * -1;
|
||||
}
|
||||
|
||||
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoVoteDelayDaily();
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%",
|
||||
Integer.toString(diffHours));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
info = timeMsg;
|
||||
} else {
|
||||
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
|
||||
}
|
||||
} else {
|
||||
if (!lastVote.isBefore(offsetoclockyesterday)) {
|
||||
Duration dur = Duration.between(now, offsetoclocktoday);
|
||||
int diffHours = (int) (dur.getSeconds() / (60 * 60));
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
|
||||
|
||||
if (diffHours < 0) {
|
||||
diffHours = diffHours * -1;
|
||||
}
|
||||
if (diffHours >= 24) {
|
||||
diffHours = diffHours - 24;
|
||||
}
|
||||
if (diffMinutes < 0) {
|
||||
diffMinutes = diffMinutes * -1;
|
||||
}
|
||||
|
||||
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoVoteDelayDaily();
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%",
|
||||
Integer.toString(diffHours));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
info = timeMsg;
|
||||
} else {
|
||||
info = plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
|
||||
}
|
||||
if (diffHours < 0) {
|
||||
diffHours = diffHours * -1;
|
||||
}
|
||||
if (diffHours >= 24) {
|
||||
diffHours = diffHours - 24;
|
||||
}
|
||||
if (diffMinutes < 0) {
|
||||
diffMinutes = diffMinutes * -1;
|
||||
}
|
||||
|
||||
String timeMsg = plugin.getConfigFile().getFormatCommandsVoteNextInfoVoteDelayDaily();
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%", Long.toString(diffMinutes));
|
||||
info = timeMsg;
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
public long voteNextDurationTime(VoteSite voteSite) {
|
||||
long time = getTime(voteSite);
|
||||
return voteNextDurationTime(voteSite, getTime(voteSite));
|
||||
}
|
||||
|
||||
public long voteNextDurationTime(VoteSite voteSite, long time) {
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
|
||||
@@ -1379,28 +1311,22 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
|
||||
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
|
||||
if (!now.isBefore(offsetoclocktoday)) {
|
||||
if (!lastVote.isBefore(offsetoclocktoday)) {
|
||||
Duration dur = Duration.between(now, offsetoclocktomorrow);
|
||||
LocalDateTime resetTime = plugin.getTimeChecker().getTime().withHour(voteSite.getVoteDelayDailyHour())
|
||||
.withMinute(0).withSecond(0);
|
||||
LocalDateTime resetTimeTomorrow = resetTime.plusHours(24);
|
||||
if (lastVote.isBefore(resetTime)) {
|
||||
if (now.isBefore(resetTime)) {
|
||||
Duration dur = Duration.between(now, resetTime);
|
||||
return dur.getSeconds();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
if (!lastVote.isBefore(offsetoclockyesterday)) {
|
||||
Duration dur = Duration.between(now, offsetoclocktoday);
|
||||
} else if (lastVote.isBefore(resetTimeTomorrow)) {
|
||||
if (now.isBefore(resetTimeTomorrow)) {
|
||||
Duration dur = Duration.between(now, resetTimeTomorrow);
|
||||
return dur.getSeconds();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ 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.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.VotePartyEvent;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -205,7 +204,7 @@ public class VoteParty implements Listener {
|
||||
|
||||
String player = getRandomPlayerName();
|
||||
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -218,7 +217,7 @@ public class VoteParty implements Listener {
|
||||
|
||||
final ArrayList<String> list = plugin.getSpecialRewardsConfig().getVotePartyGlobalRandomCommand();
|
||||
if (list.size() > 0) {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in new issue
Block a user