Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a2bf7c3dfc | ||
|
|
0543a91c5a | ||
|
|
d88868c4f7 | ||
|
|
86dc52f131 | ||
|
|
f7d88a26ef | ||
|
|
ab1468d03a | ||
|
|
3c65365b83 | ||
|
|
bfefbb59d6 | ||
|
|
9d74b5e428 | ||
|
|
f131ce948c | ||
|
|
1a78a23e7c | ||
|
|
16cdfec4d5 | ||
|
|
243300534c | ||
|
|
ea646b8e6f | ||
|
|
bd5532aa71 | ||
|
|
be033793c2 | ||
|
|
28ce76bc60 | ||
|
|
10732ee978 | ||
|
|
7deccf2e26 | ||
|
|
8873fc8263 | ||
|
|
aaaaf2c670 | ||
|
|
1e8421f83f | ||
|
|
a29a7bf5c3 | ||
|
|
fae67a49ce | ||
|
|
c48a0c1083 | ||
|
|
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
|
||||
|
||||
@@ -530,13 +530,11 @@ UseVoteStreaks: true
|
||||
# If false, storing best totals will be disabled
|
||||
UseHighestTotals: true
|
||||
|
||||
# Enable Geyser prefix support
|
||||
# May take time before geyser players can vote properly
|
||||
# If players vote with prefix, then this is probably not needed and
|
||||
# may work better disabled
|
||||
# Geyser support is currently hit or miss
|
||||
GeyserPrefixSupport: false
|
||||
GeyserPrefix: '*'
|
||||
# Geyser/Bedrock player support
|
||||
# Set prefix used for voting
|
||||
# Players should vote with prefix
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bedrock-Player-Support
|
||||
BedrockPlayerPrefix: '.'
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
@@ -576,13 +574,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
|
||||
###########################################
|
||||
|
||||
@@ -93,6 +93,10 @@ VoteParty:
|
||||
CountOfflineVotes: true
|
||||
# Broadcast when vote party reached
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# Send a broadcast at a certain number of votes left and send a vote reminder
|
||||
VoteReminderBroadcast: '%votesrequired% left to go, go vote!'
|
||||
# List of votes required amounts for when to send vote party reminders
|
||||
VoteReminderAtVotes: []
|
||||
# List of commands to execute, these only execute once.
|
||||
# %player% does not work here
|
||||
GlobalCommands: []
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -106,17 +106,22 @@ BungeeManageTotals: true
|
||||
# Set DisableBroadcast to true on spigot servers (BungeeSettings.yml) as well
|
||||
Broadcast: true
|
||||
|
||||
# Geyser settings
|
||||
# This may or may not work
|
||||
# Does not work on velocity currently
|
||||
GeyserSupport: false
|
||||
GeyserPrefix: '.'
|
||||
# Geyser/bedrock player settings
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bedrock-Player-Support
|
||||
BedrockPlayerPrefix: '.'
|
||||
|
||||
# Time votes will be cached on proxy
|
||||
# -1 means no time limit
|
||||
# Time in days
|
||||
VoteCacheTime: -1
|
||||
|
||||
# Maxium number of votes possible per day
|
||||
# Usually matches the amount of votesites
|
||||
# Will limit vote totals to match accordingly
|
||||
# Only applies for month total
|
||||
# Set to -1 to disable
|
||||
MaxAmountOfVotesPerDay: -1
|
||||
|
||||
VoteParty:
|
||||
# If enabled, will trigger vote party reward
|
||||
# in BungeeSettings.yml under BungeeVotePartyReward
|
||||
|
||||
@@ -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.2</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -88,7 +88,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
@@ -221,13 +221,13 @@
|
||||
<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>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.28</version>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -263,7 +263,7 @@
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.11.3</version>
|
||||
<version>2.11.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -415,7 +415,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.6.2</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.2</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;
|
||||
@@ -143,8 +142,9 @@ public class BungeeHandler implements Listener {
|
||||
long lastUpdated = Long.valueOf(data.get("LastUpdated").getString()).longValue();
|
||||
plugin.debug("LastUpdated: " + lastUpdated);
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastUpdated > 1000 * 60 * 60
|
||||
* 1) {
|
||||
plugin.getLogger().warning("Ignore bungee time change since it was more than 1 hour ago");
|
||||
* 2) {
|
||||
plugin.getLogger().warning("Ignoring bungee time change since it was more than 2 hours ago");
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -286,8 +286,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 +349,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 +384,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 +443,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 +459,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 +489,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 +507,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 +527,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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1285,7 +1284,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
voteTimer.shutdown();
|
||||
try {
|
||||
voteTimer.awaitTermination(10, TimeUnit.SECONDS);
|
||||
voteTimer.awaitTermination(1, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -324,11 +324,11 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("geyserprefixsupport", new Callable<String>() {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bedrockplayerprefix", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getOptions().isGeyserPrefixSupport();
|
||||
return "" + plugin.getOptions().getBedrockPlayerPrefix();
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.bungee;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class BungeeMessageData {
|
||||
|
||||
@@ -10,20 +11,28 @@ public class BungeeMessageData {
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int allTimeTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int dailyTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int milestoneCount = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int monthTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int points = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int weeklyTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int votePartyCurrent = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int votePartyRequired = 0;
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
|
||||
@@ -37,12 +37,8 @@ public class Config {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public boolean getGeyserSupport() {
|
||||
return getData().getBoolean("GeyserSupport", false);
|
||||
}
|
||||
|
||||
public String getGeyserPrefix() {
|
||||
return getData().getString("GeyserPrefix", ".");
|
||||
public String getBedrockPlayerPrefix() {
|
||||
return getData().getString("BedrockPlayerPrefix", ".");
|
||||
}
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
@@ -81,6 +77,10 @@ public class Config {
|
||||
return getData().getBoolean("MultiProxySupport", false);
|
||||
}
|
||||
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getData().getInt("MaxAmountOfVotesPerDay", -1);
|
||||
}
|
||||
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return getData().getInt("MultiProxySocketHost.Port", 1297);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class NonVotedPlayersCache {
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayer(String uuid, String playerName) {
|
||||
public void addPlayer(String uuid, String playerName) {
|
||||
getData().set("NonVotedPlayers." + playerName + ".UUID", uuid);
|
||||
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@@ -936,6 +936,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
getLogger().info("Multi-proxy status message received");
|
||||
} else if (data[0].equalsIgnoreCase("ClearVote")) {
|
||||
cachedOnlineVotes.remove(data[2]);
|
||||
} else if (data[0].equalsIgnoreCase("login")) {
|
||||
nonVotedPlayersCache.addPlayer(data[1], data[2]);
|
||||
}
|
||||
}
|
||||
if (data.length > 8) {
|
||||
@@ -952,9 +954,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
});
|
||||
|
||||
multiproxyClientHandles = new HashMap<String, ClientHandler>();
|
||||
for (
|
||||
|
||||
String s : config.getMultiProxyServers()) {
|
||||
for (String s : config.getMultiProxyServers()) {
|
||||
Configuration d = config.getMultiProxyServersConfiguration(s);
|
||||
multiproxyClientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1234),
|
||||
encryptionHandler, config.getDebug()));
|
||||
@@ -989,14 +989,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
public void login(ProxiedPlayer p) {
|
||||
if (p != null && p.getServer() != null && p.getServer().getInfo() != null) {
|
||||
final String server = p.getServer().getInfo().getName();
|
||||
final ProxiedPlayer proixedPlayer = p;
|
||||
final ProxiedPlayer proxiedPlayer = p;
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (isOnline(p)) {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(proixedPlayer, proixedPlayer.getUniqueId().toString(), server);
|
||||
checkOnlineVotes(proxiedPlayer, proxiedPlayer.getUniqueId().toString(), server);
|
||||
multiProxyLogin(proxiedPlayer);
|
||||
}
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
@@ -1004,6 +1005,18 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
}
|
||||
|
||||
public void multiProxyLogin(ProxiedPlayer p) {
|
||||
if (!config.getMultiProxySupport()) {
|
||||
return;
|
||||
}
|
||||
if (config.getPrimaryServer()) {
|
||||
return;
|
||||
}
|
||||
if (!config.getAllowUnJoined()) {
|
||||
sendMultiProxyServerMessage("Login", p.getUniqueId().toString(), p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent ev) {
|
||||
if (!ev.getTag().equals("vp:vp".toLowerCase())) {
|
||||
@@ -1211,15 +1224,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getGeyserSupport()) {
|
||||
if (!player.startsWith(config.getGeyserPrefix())) {
|
||||
uuid = getUUID(config.getGeyserPrefix() + player);
|
||||
player = config.getGeyserPrefix() + player;
|
||||
}
|
||||
if (player.startsWith(config.getBedrockPlayerPrefix())) {
|
||||
getLogger().info("Ignoring vote since unable to get UUID of bedrock player");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getAllowUnJoined()) {
|
||||
debug("Fetching UUID online, since allowunjoined is enabled");
|
||||
UUID u = null;
|
||||
@@ -1245,8 +1253,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
player = getProperName(uuid, player);
|
||||
|
||||
addVoteParty();
|
||||
if (getConfig().getPrimaryServer() || !getConfig().getMultiProxySupport()) {
|
||||
addVoteParty();
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
if (mysql == null) {
|
||||
@@ -1267,6 +1275,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
int dailyTotal = getValue(data, "DailyTotal", 1);
|
||||
int points = getValue(data, "Points", getConfig().getPointsOnVote());
|
||||
int milestoneCount = getValue(data, "MilestoneCount", 1);
|
||||
|
||||
int maxVotes = getConfig().getMaxAmountOfVotesPerDay();
|
||||
if (maxVotes > 0) {
|
||||
LocalDateTime cTime = getBungeeTimeChecker().getTime();
|
||||
int days = cTime.getDayOfMonth();
|
||||
if (monthTotal > days * maxVotes) {
|
||||
monthTotal = days * maxVotes;
|
||||
}
|
||||
}
|
||||
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
|
||||
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
|
||||
ArrayList<Column> update = new ArrayList<Column>();
|
||||
|
||||
@@ -60,11 +60,15 @@ public class Config extends VelocityYMLFile {
|
||||
public int getBungeePort() {
|
||||
return getInt(getNode("BungeeServer", "Port"), 1297);
|
||||
}
|
||||
|
||||
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getInt(getNode("MaxAmountOfVotesPerDay"), -1);
|
||||
}
|
||||
|
||||
public int getVoteCacheTime() {
|
||||
return getInt(getNode("VoteCacheTime"), -1);
|
||||
}
|
||||
|
||||
|
||||
public boolean getDebug() {
|
||||
return getBoolean(getNode("Debug"), false);
|
||||
}
|
||||
@@ -137,16 +141,12 @@ public class Config extends VelocityYMLFile {
|
||||
return getBoolean(getNode("MultiProxyOneGlobalReward"), false);
|
||||
}
|
||||
|
||||
public boolean getGeyserSupport() {
|
||||
return getBoolean(getNode("GeyserSupport"), false);
|
||||
}
|
||||
|
||||
public boolean getPrimaryServer() {
|
||||
return getBoolean(getNode("PrimaryServer"), false);
|
||||
}
|
||||
|
||||
public String getGeyserPrefix() {
|
||||
return getString(getNode("GeyserPrefix"), "*");
|
||||
public String getBedrockPlayerPrefix() {
|
||||
return getString(getNode("BedrockPlayerPrefix"), ".");
|
||||
}
|
||||
|
||||
public ConfigurationNode getMultiProxyServers(String s) {
|
||||
|
||||
+14
-10
@@ -1247,17 +1247,12 @@ public class VotingPluginVelocity {
|
||||
uuid = getUUID(player);
|
||||
}
|
||||
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getGeyserSupport()) {
|
||||
if (!player.startsWith(config.getGeyserPrefix())) {
|
||||
uuid = getUUID(config.getGeyserPrefix() + player);
|
||||
player = config.getGeyserPrefix() + player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getAllowUnJoined()) {
|
||||
if (player.startsWith(config.getBedrockPlayerPrefix())) {
|
||||
logger.info("Ignoring vote since unable to get UUID of bedrock player");
|
||||
return;
|
||||
}
|
||||
debug("Fetching UUID online, since allowunjoined is enabled");
|
||||
UUID u = null;
|
||||
try {
|
||||
@@ -1282,8 +1277,8 @@ public class VotingPluginVelocity {
|
||||
|
||||
player = getProperName(uuid, player);
|
||||
|
||||
addVoteParty();
|
||||
if (getConfig().getPrimaryServer() || !getConfig().getMultiProxySupport()) {
|
||||
addVoteParty();
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
if (mysql == null) {
|
||||
@@ -1303,6 +1298,15 @@ public class VotingPluginVelocity {
|
||||
int dailyTotal = getValue(data, "DailyTotal", 1);
|
||||
int points = getValue(data, "Points", getConfig().getPointsOnVote());
|
||||
int milestoneCount = getValue(data, "MilestoneCount", 1);
|
||||
|
||||
int maxVotes = getConfig().getMaxAmountOfVotesPerDay();
|
||||
if (maxVotes > 0) {
|
||||
LocalDateTime cTime = getBungeeTimeChecker().getTime();
|
||||
int days = cTime.getDayOfMonth();
|
||||
if (monthTotal > days * maxVotes) {
|
||||
monthTotal = days * maxVotes;
|
||||
}
|
||||
}
|
||||
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
|
||||
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
|
||||
ArrayList<Column> update = new ArrayList<Column>();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,6 +67,14 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
@ConfigDataString(path = "VoteParty.VoteReminderBroadcast")
|
||||
@Getter
|
||||
private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!";
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.VoteReminderAtVotes")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyVoteReminderAtVotes = new ArrayList<String>();
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<String>();
|
||||
|
||||
@@ -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,12 +12,12 @@ 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;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -209,6 +209,20 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
user.checkDayVoteStreak(event.isForceBungee());
|
||||
|
||||
if (plugin.getConfigFile().isLimitMonthlyVotes()) {
|
||||
int value = 0;
|
||||
if (event.isBungee()) {
|
||||
value = event.getBungeeTextTotals().getMonthTotal();
|
||||
} else {
|
||||
value = user.getTotal(TopVoter.Monthly);
|
||||
}
|
||||
LocalDateTime cTime = plugin.getTimeChecker().getTime();
|
||||
int days = cTime.getDayOfMonth();
|
||||
if (value >= days * plugin.getVoteSites().size()) {
|
||||
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSites().size());
|
||||
}
|
||||
}
|
||||
|
||||
// other rewards
|
||||
plugin.getSpecialRewards().checkAllSites(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkAlmostAllSites(user, event.isForceBungee());
|
||||
@@ -219,7 +233,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 +241,7 @@ public class PlayerVoteListener implements Listener {
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,6 +249,10 @@ public class PlayerVoteListener implements Listener {
|
||||
event.isForceBungee(), voteTime);
|
||||
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
|
||||
|
||||
if (user.isOnline()) {
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
}
|
||||
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -19,24 +19,12 @@ public class UserManager {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public UserManager() {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static UserManager instance = new UserManager();
|
||||
|
||||
@Deprecated
|
||||
public static UserManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void addCachingKeys() {
|
||||
UserDataManager manager = plugin.getUserManager().getDataManager();
|
||||
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 +48,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 +73,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();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@@ -276,21 +275,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 +448,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 +458,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 +466,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 +948,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);
|
||||
}
|
||||
|
||||
@@ -1094,7 +1091,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
case Monthly:
|
||||
if (plugin.getConfigFile().isLimitMonthlyVotes()) {
|
||||
LocalDateTime time = plugin.getTimeChecker().getTime();
|
||||
int days = YearMonth.of(time.getYear(), time.getMonth()).lengthOfMonth();
|
||||
int days = time.getDayOfMonth();
|
||||
if (value >= days * plugin.getVoteSites().size()) {
|
||||
value = days * plugin.getVoteSites().size();
|
||||
}
|
||||
@@ -1261,103 +1258,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 +1310,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() {
|
||||
@@ -345,6 +344,24 @@ public class VoteParty implements Listener {
|
||||
plugin.getServerData().saveData();
|
||||
}
|
||||
|
||||
public void checkVoteReminder(VotingPluginUser user) {
|
||||
int neededVotes = getNeededVotes();
|
||||
|
||||
for (String str : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) {
|
||||
if (StringParser.getInstance().isInt(str)) {
|
||||
int num = Integer.parseInt(str);
|
||||
if (neededVotes == num) {
|
||||
String broadcastMessage = plugin.getSpecialRewardsConfig().getVotePartyVoteReminderBroadcast();
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesrequired", "" + neededVotes);
|
||||
MiscUtils.getInstance()
|
||||
.broadcast(StringParser.getInstance().replacePlaceHolder(broadcastMessage, placeholders));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void vote(VotingPluginUser user, boolean realVote, boolean forceBungee) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyCountFakeVotes() || realVote) {
|
||||
@@ -352,6 +369,7 @@ public class VoteParty implements Listener {
|
||||
addTotal(user);
|
||||
addVotePlayer(user);
|
||||
check(user, forceBungee);
|
||||
checkVoteReminder(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user