Compare commits

...
23 Commits
Author SHA1 Message Date
BenCodez c2fe26aaea Update version number to 6.18 2024-12-16 20:21:37 -06:00
BenCodez 2aa84c90e8 Adjustments to how previous months top voters are loaded 2024-12-16 17:34:47 -06:00
BenCodez c8cace388e Change command from previousmonthsvoters to previousmonthstotals 2024-12-16 16:29:38 -06:00
BenCodez 1da028476f Don't load command if month date isn't enabled 2024-12-14 16:50:05 -06:00
BenCodez c28bddd0ba Add previous month top voters GUI, uses Month totals with date 2024-12-13 12:43:15 -06:00
BenCodez 1afd8253a5 Add extra time change checks on login 2024-12-13 09:58:29 -06:00
BenCodez a3a1b4604f Add extra check for time queues on proxy 2024-12-13 09:46:28 -06:00
BenCodez 3bd41af200 Add extra checks on proxy time changes 2024-12-13 09:43:04 -06:00
BenCodez 0042045d9b Add bypass fail safe options for bungee time checking 2024-12-13 09:10:04 -06:00
BenCodez 76d7579c7d Update to 1.21.4 2024-12-09 21:24:43 -06:00
Ben f591b863f1 Merge pull request #1405 from BenCodez/dependabot/maven/VotingPlugin/com.coderplus.maven.plugins-copy-rename-maven-plugin-1.0.1
Bump com.coderplus.maven.plugins:copy-rename-maven-plugin from 1.0 to 1.0.1 in /VotingPlugin
2024-12-09 07:43:31 -06:00
dependabot[bot] b43c4b89a8 Bump com.coderplus.maven.plugins:copy-rename-maven-plugin
Bumps [com.coderplus.maven.plugins:copy-rename-maven-plugin](https://github.com/coderplus/copy-rename-maven-plugin) from 1.0 to 1.0.1.
- [Commits](https://github.com/coderplus/copy-rename-maven-plugin/commits)

---
updated-dependencies:
- dependency-name: com.coderplus.maven.plugins:copy-rename-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-09 06:43:18 +00:00
BenCodez f9d7f5a136 Adjust default caching columns 2024-12-08 14:38:28 -06:00
BenCodez 338853a29f Fix issues with new month total date system 2024-12-08 14:34:54 -06:00
BenCodez 7d0722d5c4 Fix vote streak command not working for multiples 2024-12-08 12:37:52 -06:00
BenCodez 86e6bca31d Small adjustment to vote streaking handling 2024-12-08 12:21:12 -06:00
BenCodez 8488233be1 More work on new month date totals 2024-12-07 21:13:56 -06:00
BenCodez ba5f8dfa6d Implement month totals with dates on proxy servers 2024-12-07 17:56:50 -06:00
BenCodez dc865f1d20 First implementation of storing and using totals with month names 2024-12-07 16:03:19 -06:00
BenCodez 5dedb644b2 More adjustments to build numbers on jar files 2024-12-06 20:59:52 -06:00
BenCodez c041c7c33a Adjust maven profile 2024-12-06 20:55:55 -06:00
BenCodez bbc0c4a88e Implement first steps at including version number in jar name 2024-12-06 20:52:47 -06:00
BenCodez 4d200f6675 Change version number to 6.17.5-SNAPSHOT 2024-12-01 16:22:51 -06:00
17 changed files with 759 additions and 74 deletions

No files matched your search

+20
View File
@@ -591,6 +591,26 @@ DefaultRewardWorlds: []
# Default blackedlisted worlds set for all rewards
DefaultRewardBlackListedWorlds: []
###########################################
# Month Date Totals
# Experimental feature
###########################################
# Experimental
# Stores month votes with date formatting
# MonthTotal-MONTH-YEAR
# This setting only enables setting totals, not using them
# Enabling this is pretty safe and harmless with just this setting
# Essentially will just copy MonthTotal to MonthTotal-MONTH-YEAR
# Can use command /vote PreviousMonthsVoters after this is enabled
StoreMonthTotalsWithDate: false
# Experimental
# This setting uses month votes with date formatting
# If using this StoreMonthTotalsWithDate must be enabled
# This setting may be very buggy as it's in early stages
UseMonthDateTotalsAsPrimaryTotal: false
###########################################
# Skull settings
###########################################
+19
View File
@@ -158,6 +158,25 @@ OnlineMode: true
# If true plugin will atempt to lookup uuids if none exist
UUIDLookup: true
###########################################
# Month Date Totals
# Experimental feature
# Settings must match on backend servers
###########################################
# Experimental
# Stores month votes with date formatting
# MonthTotal-MONTH-YEAR
# This setting only enables setting totals, not using them
# Enabling this is pretty safe and harmless with just this setting
StoreMonthTotalsWithDate: false
# Experimental
# This setting uses month votes with date formatting
# If using this StoreMonthTotalsWithDate must be enabled
# This setting may be very buggy as it's in early stages
UseMonthDateTotalsAsPrimaryTotal: false
##########################################
# PLUGINMESSAGING Settings
##########################################
+172 -42
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.17.4</version>
<version>6.18</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -60,19 +60,6 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
@@ -185,32 +172,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${user.home}/Documents/Test_Server/plugins</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target</directory>
<includes>
<include>VotingPlugin.jar</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
@@ -248,7 +209,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.21.3-R0.1-SNAPSHOT</version>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -296,11 +257,37 @@
<dependency>
<groupId>com.bencodez</groupId>
<artifactId>advancedcore</artifactId>
<version>3.7.11</version>
<version>3.7.12</version>
<scope>compile</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>default</id>
<properties>
<build.profile.id>default</build.profile.id>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploy-snapshot</id>
<properties>
@@ -318,6 +305,40 @@
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>
${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>install</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.basedir}/target/${project.name}.jar</sourceFile>
<destinationFile>
${project.basedir}/target/${project.name}-${build.number}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
@@ -380,6 +401,19 @@
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
@@ -400,6 +434,26 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>deploy</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.basedir}/target/${project.name}.jar</sourceFile>
<destinationFile>
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
@@ -408,6 +462,49 @@
<properties>
<build.profile.id>dev</build.profile.id>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${user.home}/Documents/Test_Server/plugins</outputDirectory>
<resources>
<resource>
<directory>${basedir}/target</directory>
<includes>
<include>VotingPlugin.jar</include>
</includes>
</resource>
</resources>
<overwrite>true</overwrite>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>deploy</id>
@@ -426,6 +523,39 @@
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestEntries>
<paperweight-mappings-namespace>mojang</paperweight-mappings-namespace>
</manifestEntries>
</archive>
<finalName>${project.name}</finalName>
</configuration>
</plugin>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>copy-file</id>
<phase>deploy</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>
${project.basedir}/target/${project.name}.jar</sourceFile>
<destinationFile>
${project.basedir}/target/${project.name}-${project.version}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
@@ -228,6 +228,11 @@ public class BungeeHandler implements Listener {
public void debug(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
});
} else {
globalDataHandler = new GlobalDataHandler(
@@ -253,6 +258,11 @@ public class BungeeHandler implements Listener {
public void debug(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
});
}
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
@@ -7,6 +7,7 @@ import java.net.URL;
import java.security.CodeSource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -151,6 +152,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private LinkedHashMap<TopVoterPlayer, Integer> lastMonthTopVoter;
@Getter
@Setter
private LinkedHashMap<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>> previousMonthsTopVoters;
@Getter
private MVdWPlaceholders mvdwPlaceholders;
@@ -1063,7 +1068,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
loadVersionFile();
getOptions().setServer(bungeeSettings.getServer());
// only purges if enabled in config
getVotingPluginUserManager().purgeOldPlayersNoData();
@@ -1111,12 +1116,15 @@ public class VotingPluginMain extends AdvancedCorePlugin {
topVoterHandler = new TopVoterHandler(this);
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
previousMonthsTopVoters = new LinkedHashMap<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>>();
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
topVoterHandler.loadLastMonth();
debug("Loaded last month top voters");
topVoterHandler.loadPreviousMonthTopVoters();
}
});
topVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
@@ -1514,7 +1522,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
}
checkYMLError();
if (broadcastHandler != null) {
broadcastHandler.schedule(getConfigFile().getFormatAlternateBroadcastDelay());
}
@@ -8,7 +8,7 @@ import lombok.Setter;
public class BungeeMessageData {
// Message string
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired//datemonthtotal
@Getter
@Setter
@@ -24,6 +24,9 @@ public class BungeeMessageData {
private int monthTotal = 0;
@Getter
@Setter
private int dateMonthTotal = 0;
@Getter
@Setter
private int points = 0;
@Getter
@Setter
@@ -36,7 +39,7 @@ public class BungeeMessageData {
private int votePartyRequired = 0;
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
int milestoneCount, int votePartyCurrent, int votePartyRequired) {
int milestoneCount, int votePartyCurrent, int votePartyRequired, int dateMonthTotal) {
this.allTimeTotal = allTimeTotal;
this.monthTotal = monthTotal;
this.weeklyTotal = weeklyTotal;
@@ -45,6 +48,7 @@ public class BungeeMessageData {
this.milestoneCount = milestoneCount;
this.votePartyCurrent = votePartyCurrent;
this.votePartyRequired = votePartyRequired;
this.dateMonthTotal = dateMonthTotal;
}
public BungeeMessageData(String str) {
@@ -61,6 +65,9 @@ public class BungeeMessageData {
votePartyCurrent = Integer.parseInt(data[6]);
votePartyRequired = Integer.parseInt(data[7]);
}
if (data.length >= 9) {
dateMonthTotal = Integer.parseInt(data[8]);
}
}
@Override
@@ -57,6 +57,14 @@ public class Config {
return getData().getBoolean("Broadcast", false);
}
public boolean getStoreMonthTotalsWithDate() {
return getData().getBoolean("StoreMonthTotalsWithDate", false);
}
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
return getData().getBoolean("UseMonthDateTotalsAsPrimaryTotal", false);
}
public String getBedrockPlayerPrefix() {
return getData().getString("BedrockPlayerPrefix", ".");
}
@@ -64,6 +72,10 @@ public class Config {
public boolean getOnlineMode() {
return getData().getBoolean("OnlineMode", true);
}
public boolean getTimeChangeFailSafeBypass() {
return getData().getBoolean("TimeChangeFailSafeBypass", false);
}
public boolean getUUIDLookup() {
return getData().getBoolean("UUIDLookup", true);
@@ -355,6 +355,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
getLogger().info(text);
}
}, servers) {
@Override
@@ -412,6 +418,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
getLogger().info(text);
}
}, servers) {
@Override
@@ -482,6 +494,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
if (config.getStoreMonthTotalsWithDate()) {
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
"INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
"INT DEFAULT '0'");
}
}
private String buildNumber = "NOTSET";
@@ -625,6 +644,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
getLogger().warning("Global data not enabled, ignoring time change event");
return;
}
for (String s : getAvailableAllServers()) {
@@ -742,6 +762,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
voteCacheFile = new VoteCache(this);
voteCacheFile.load();
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
bungeeTimeChecker.loadTimer();
nonVotedPlayersCache = new NonVotedPlayersCache(this);
@@ -1152,6 +1173,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Override
public void run() {
if (isOnline(p)) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
checkCachedVotes(server);
checkOnlineVotes(proxiedPlayer, proxiedPlayer.getUniqueId().toString(), server);
multiProxyHandler.login(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
@@ -1355,6 +1382,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
public String getMonthTotalsWithDatePath() {
LocalDateTime cTime = bungeeTimeChecker.getTime();
return getMonthTotalsWithDatePath(cTime);
}
public String getMonthTotalsWithDatePath(LocalDateTime cTime) {
return "MonthTotal-" + cTime.getMonth().toString() + "-" + cTime.getYear();
}
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
BungeeMessageData text, String uuid) {
try {
@@ -1362,10 +1398,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
getLogger().info("No name from vote on " + service);
return;
}
if (timeQueue) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
if (timeQueue && getGlobalDataHandler().isTimeChangedHappened()) {
timeChangeQueue.add(new VoteTimeQueue(player, service,
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
getLogger().info("Cachcing vote from " + player + "/" + service
@@ -1432,6 +1468,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
int monthTotal = getValue(data, "MonthTotal", 1);
int dateMonthTotal = -1;
if (config.getStoreMonthTotalsWithDate()) {
if (config.getUseMonthDateTotalsAsPrimaryTotal()) {
dateMonthTotal = getValue(data, getMonthTotalsWithDatePath(), 1);
} else {
dateMonthTotal = monthTotal;
}
}
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
@@ -1452,10 +1496,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
milestoneCount, votePartyVotes, currentVotePartyVotesRequired, dateMonthTotal);
ArrayList<Column> update = new ArrayList<Column>();
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
if (config.getStoreMonthTotalsWithDate()) {
update.add(new Column(getMonthTotalsWithDatePath(), new DataValueInt(dateMonthTotal)));
}
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
update.add(new Column("Points", new DataValueInt(points)));
@@ -1463,7 +1510,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
debug("Setting totals " + text.toString());
mysql.update(uuid, update);
} else {
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired, 0);
}
}
@@ -37,6 +37,18 @@ public class Config extends VelocityYMLFile {
return getBoolean(getNode("OnlineMode"), true);
}
public boolean getTimeChangeFailSafeBypass() {
return getBoolean(getNode("TimeChangeFailSafeBypass"), false);
}
public boolean getStoreMonthTotalsWithDate() {
return getBoolean(getNode("StoreMonthTotalsWithDate"), false);
}
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
return getBoolean(getNode("UseMonthDateTotalsAsPrimaryTotal"), false);
}
public boolean getUUIDLookup() {
return getBoolean(getNode("UUIDLookup"), true);
}
@@ -364,6 +364,11 @@ public class VotingPluginVelocity {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
logger.info(text);
}
}, servers) {
@Override
@@ -417,6 +422,11 @@ public class VotingPluginVelocity {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
logger.info(text);
}
}, servers) {
@Override
@@ -484,6 +494,13 @@ public class VotingPluginVelocity {
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
if (config.getStoreMonthTotalsWithDate()) {
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
"INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
"INT DEFAULT '0'");
}
}
@Subscribe
@@ -526,6 +543,12 @@ public class VotingPluginVelocity {
@Override
public void run() {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
debug("Checking offline votes for " + p.getUsername() + "/"
+ p.getUniqueId().toString());
checkCachedVotes(server);
@@ -676,6 +699,7 @@ public class VotingPluginVelocity {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
getLogger().warn("Global data not enabled, ignoring time change event");
return;
}
for (RegisteredServer s : getAvailableAllServers()) {
@@ -837,6 +861,7 @@ public class VotingPluginVelocity {
voteCacheFile.save();
}
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
bungeeTimeChecker.loadTimer();
try {
@@ -996,6 +1021,12 @@ public class VotingPluginVelocity {
@Override
public void run() {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
checkCachedVotes(server);
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
getMultiProxyHandler().login(p1.getUniqueId().toString(),
@@ -1430,6 +1461,15 @@ public class VotingPluginVelocity {
}
}
public String getMonthTotalsWithDatePath() {
LocalDateTime cTime = bungeeTimeChecker.getTime();
return getMonthTotalsWithDatePath(cTime);
}
public String getMonthTotalsWithDatePath(LocalDateTime cTime) {
return "MonthTotal-" + cTime.getMonth().toString() + "-" + cTime.getYear();
}
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queuedTime,
BungeeMessageData text, String uuid) {
try {
@@ -1437,10 +1477,10 @@ public class VotingPluginVelocity {
logger.info("No name from vote on " + service);
return;
}
if (timeQueue) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
if (timeQueue && getGlobalDataHandler().isTimeChangedHappened()) {
timeChangeQueue.add(new VoteTimeQueue(player, service,
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
getLogger().info("Cachcing vote from " + player + "/" + service
@@ -1506,6 +1546,14 @@ public class VotingPluginVelocity {
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
int monthTotal = getValue(data, "MonthTotal", 1);
int dateMonthTotal = -1;
if (config.getStoreMonthTotalsWithDate()) {
if (config.getUseMonthDateTotalsAsPrimaryTotal()) {
dateMonthTotal = getValue(data, getMonthTotalsWithDatePath(), 1);
} else {
dateMonthTotal = monthTotal;
}
}
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
@@ -1525,10 +1573,13 @@ public class VotingPluginVelocity {
}
}
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
milestoneCount, votePartyVotes, currentVotePartyVotesRequired, dateMonthTotal);
ArrayList<Column> update = new ArrayList<Column>();
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
if (config.getStoreMonthTotalsWithDate()) {
update.add(new Column(getMonthTotalsWithDatePath(), new DataValueInt(dateMonthTotal)));
}
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
update.add(new Column("Points", new DataValueInt(points)));
@@ -1536,7 +1587,7 @@ public class VotingPluginVelocity {
debug("Setting totals " + text.toString());
mysql.update(uuid, update);
} else {
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired, 0);
}
}
@@ -66,6 +66,7 @@ import com.bencodez.votingplugin.commands.gui.player.VoteStreak;
import com.bencodez.votingplugin.commands.gui.player.VoteToday;
import com.bencodez.votingplugin.commands.gui.player.VoteTopVoter;
import com.bencodez.votingplugin.commands.gui.player.VoteTopVoterLastMonth;
import com.bencodez.votingplugin.commands.gui.player.VoteTopVoterPreviousMonths;
import com.bencodez.votingplugin.commands.gui.player.VoteTotal;
import com.bencodez.votingplugin.commands.gui.player.VoteURL;
import com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite;
@@ -1683,15 +1684,19 @@ public class CommandLoader {
plugin.getAdminVoteCommand()
.add(new CommandHandler(plugin,
new String[] { "User", "(player)", "ForceVoteStreak", str, "(Number)" },
new String[] { "User", "(player)", "ForceVoteStreak", str, "(Text)" },
"VotingPlugin.Commands.AdminVote.ForceVoteStreak|" + adminPerm,
"Force a votestreak reward for " + str) {
@Override
public void execute(CommandSender sender, String[] args) {
String num = args[4];
if (num.contains("-")) {
num = num.replaceAll("-", "");
}
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
plugin.getSpecialRewards().giveVoteStreakReward(user, user.isOnline(), str, args[4],
parseInt(args[4]), plugin.getBungeeSettings().isUseBungeecoord());
parseInt(num), plugin.getBungeeSettings().isUseBungeecoord());
sendMessage(sender, "&cVoteStreak " + str + " " + args[4] + " forced");
}
});
@@ -2472,6 +2477,21 @@ public class CommandLoader {
});
}
if (plugin.getConfigFile().isStoreMonthTotalsWithDate()
|| plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
plugin.getVoteCommand()
.add(new CommandHandler(plugin, new String[] { "PreviousMonthsTotals" },
"VotingPlugin.Commands.Vote.PreviousMonthsTotals",
"Open list of Top Voters from all known previous months") {
@Override
public void execute(CommandSender sender, String[] args) {
new VoteTopVoterPreviousMonths(plugin, sender,
plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender), 0).open();
}
});
}
plugin.getVoteCommand().add(new CommandHandler(plugin, new String[] { "Top" },
"VotingPlugin.Commands.Vote.Top|" + playerPerm, "Open list of Top Voters") {
@@ -0,0 +1,150 @@
package com.bencodez.votingplugin.commands.gui.player;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Collectors;
import org.bukkit.Material;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.inventory.BInventory;
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
import com.bencodez.votingplugin.user.VotingPluginUser;
import net.md_5.bungee.api.ChatColor;
public class VoteTopVoterPreviousMonths extends GUIHandler {
private VotingPluginMain plugin;
private VotingPluginUser user;
private int index = -1;
public VoteTopVoterPreviousMonths(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int index) {
super(plugin, player);
this.plugin = plugin;
this.user = user;
this.index = index;
}
@Override
public ArrayList<String> getChat(CommandSender arg0) {
return null;
}
@Override
public void onBook(Player player) {
// TODO
}
@Override
public void onChat(CommandSender sender) {
}
public void next(int index) {
}
@Override
public void onChest(Player player) {
Set<YearMonth> months = plugin.getPreviousMonthsTopVoters().keySet();
List<YearMonth> yearMonthList = months.stream().sorted(Collections.reverseOrder()).collect(Collectors.toList());
YearMonth yearMonth = null;
if (index < 0) {
if (!yearMonthList.isEmpty()) {
yearMonth = yearMonthList.get(0);
}
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
return;
} else {
if (yearMonthList.size() > index) {
yearMonth = yearMonthList.get(index);
} else {
player.sendMessage(ChatColor.RED + "Can't open previous months, no data for requested index");
return;
}
}
Set<Entry<TopVoterPlayer, Integer>> users = null;
if (plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
} else {
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
return;
}
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
inv.addPlaceholder("topvoter", yearMonth.toString());
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
inv.dontClose();
}
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem;
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
} else {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
playerItem.setLore(new ArrayList<String>());
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
.addPlaceholder("player", entry.getKey().getPlayerName())
.addPlaceholder("votes", "" + entry.getValue())) {
@Override
public void onClick(ClickEvent clickEvent) {
TopVoterPlayer user = (TopVoterPlayer) getData("User");
new VoteGUI(plugin, player, user.getUser())
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
}
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
pos++;
}
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem())
.addPlaceholder("Top", yearMonth.toString())) {
@Override
public void onClick(ClickEvent clickEvent) {
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
new VoteTopVoterPreviousMonths(plugin, player, user, index + 1).open(GUIMethod.CHEST);
} else {
new VoteTopVoterPreviousMonths(plugin, player, user, index - 1).open(GUIMethod.CHEST);
}
}
});
if (plugin.getGui().isChestVoteTopBackButton()) {
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
}
inv.setPages(true);
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
inv.openInventory(player);
}
@Override
public void open() {
open(GUIMethod.CHEST);
}
}
@@ -667,6 +667,14 @@ public class Config extends YMLFile {
@Getter
private boolean purgeNoDataOnStartup = false;
@ConfigDataBoolean(path = "StoreMonthTotalsWithDate")
@Getter
private boolean storeMonthTotalsWithDate = false;
@ConfigDataBoolean(path = "UseMonthDateTotalsAsPrimaryTotal")
@Getter
private boolean useMonthDateTotalsAsPrimaryTotal = false;
@ConfigDataString(path = "RequestAPI.DefaultMethod")
@Getter
private String requestAPIDefaultMethod = "ANVIL";
@@ -110,7 +110,11 @@ public class SpecialRewards {
total = bungeeMessageData.getDailyTotal();
break;
case Monthly:
total = bungeeMessageData.getMonthTotal();
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
total = bungeeMessageData.getDateMonthTotal();
} else {
total = bungeeMessageData.getMonthTotal();
}
break;
case Weekly:
total = bungeeMessageData.getWeeklyTotal();
@@ -164,6 +168,7 @@ public class SpecialRewards {
}
}
return gotCumulativeAny;
}
public boolean checkFirstVote(VotingPluginUser user, boolean forceBungee) {
@@ -258,13 +263,14 @@ public class SpecialRewards {
Set<String> streaks = plugin.getSpecialRewardsConfig().getVoteStreakVotes(type);
for (String streak : streaks) {
String s = streak.replaceAll("-", "");
boolean multiple = false;
if (streak.contains("-")) {
// multiple
multiple = true;
}
String s = streak.replaceAll("-", "");
plugin.debug("Streak: " + streak + " multiple: " + multiple);
if (MessageAPI.isInt(s)) {
int streakRequired = Integer.parseInt(s);
@@ -2,6 +2,8 @@ package com.bencodez.votingplugin.topvoter;
import java.io.File;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.YearMonth;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -85,11 +87,106 @@ public class TopVoterHandler implements Listener {
return place;
}
public void loadPreviousMonthTopVoters() {
if (plugin.getConfigFile().isStoreMonthTotalsWithDate()) {
LocalDateTime now = plugin.getTimeChecker().getTime();
for (String column : plugin.getUserManager().getAllColumns()) {
if (column.startsWith("MonthTotal-")) {
String[] data = column.split("-");
if (data.length > 2) {
String year = data[2];
String month = data[1];
if (MessageAPI.isInt(year)) {
YearMonth yearMonth = YearMonth.of(Integer.parseInt(year), Month.valueOf(month));
if (yearMonth.atDay(now.getDayOfMonth()).atTime(23, 59).isBefore(now)) {
plugin.debug("Loading previous month top voters of " + yearMonth.toString());
plugin.getPreviousMonthsTopVoters().put(yearMonth,
new LinkedHashMap<TopVoterPlayer, Integer>());
}
}
}
}
}
if (plugin.getPreviousMonthsTopVoters().size() > 0) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
for (YearMonth month : plugin.getPreviousMonthsTopVoters().keySet()) {
LocalDateTime atTime = month.atDay(15).atTime(0, 0);
int total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
plugin.getPreviousMonthsTopVoters().get(month).put(user.getTopVoterPlayer(), total);
}
}
cols.put(playerData.getKey(), null);
user.clearTempCache();
}
}
cols.clear();
cols = null;
}
for (YearMonth month : plugin.getPreviousMonthsTopVoters().keySet()) {
plugin.getPreviousMonthsTopVoters().put(month,
sortByValues(plugin.getPreviousMonthsTopVoters().get(month), false));
}
plugin.extraDebug("Previous Months: " + plugin.getPreviousMonthsTopVoters().keySet().toString());
for (Entry<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>> entry : plugin.getPreviousMonthsTopVoters()
.entrySet()) {
for (Entry<TopVoterPlayer, Integer> entry2 : entry.getValue().entrySet()) {
plugin.extraDebug(entry.getKey().toString() + ": " + entry2.getKey().getUser().getPlayerName() + ":"
+ entry2.getValue().intValue());
}
}
}
}
public LinkedHashMap<TopVoterPlayer, Integer> getTopVotersOfMonth(YearMonth month,
HashMap<UUID, ArrayList<Column>> cols) {
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
LocalDateTime atTime = month.atDay(15).atTime(0, 0);
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
int total = 0;
total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
totals.put(user.getTopVoterPlayer(), total);
}
user.clearTempCache();
}
}
return sortByValues(totals, false);
}
public void loadLastMonth() {
if (plugin.getGui().isLastMonthGUI()) {
plugin.getLastMonthTopVoter().clear();
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
LocalDateTime lastMonthTime = plugin.getTimeChecker().getTime().minusMonths(1);
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
@@ -100,7 +197,12 @@ public class TopVoterHandler implements Listener {
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
int total = user.getLastMonthTotal();
int total = 0;
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
total = user.getTotal(TopVoter.Monthly, lastMonthTime);
} else {
total = user.getLastMonthTotal();
}
if (total > 0) {
totals.put(user.getTopVoterPlayer(), total);
}
@@ -238,6 +340,7 @@ public class TopVoterHandler implements Listener {
plugin.getUserManager().copyColumnData(TopVoter.Monthly.getColumnName(),
TopVoter.Monthly.getLastColumnName());
}
LocalDateTime lastMonthTime = plugin.getTimeChecker().getTime().minusMonths(1);
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
@@ -247,13 +350,13 @@ public class TopVoterHandler implements Listener {
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
if (plugin.getConfigFile().isUseVoteStreaks()) {
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
if (user.getTotal(TopVoter.Monthly, lastMonthTime) == 0 && user.getMonthVoteStreak() != 0) {
user.setMonthVoteStreak(0);
} else {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|| user.hasPercentageTotal(TopVoter.Monthly,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
LocalDateTime.now().minusDays(1))) {
lastMonthTime)) {
user.addMonthVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(user, "Month",
plugin.getBungeeSettings().isUseBungeecoord());
@@ -265,8 +368,8 @@ public class TopVoterHandler implements Listener {
// user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
if (plugin.getConfigFile().isUseHighestTotals()) {
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly, lastMonthTime)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly, lastMonthTime));
}
}
user.clearTempCache();
@@ -283,10 +386,17 @@ public class TopVoterHandler implements Listener {
int i = 0;
int lastTotal = -1;
@SuppressWarnings("unchecked")
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
LinkedHashMap<TopVoterPlayer, Integer> topVoters = null;
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
topVoters = getMonthlyTopVotersAtTime(lastMonthTime);
} else {
@SuppressWarnings("unchecked")
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
topVoters = clone;
}
for (Entry<TopVoterPlayer, Integer> entry : topVoters.entrySet()) {
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
if (entry.getValue().intValue() != lastTotal) {
i++;
@@ -813,6 +923,37 @@ public class TopVoterHandler implements Listener {
return ArrayUtils.convert(msg);
}
public LinkedHashMap<TopVoterPlayer, Integer> getMonthlyTopVotersAtTime(LocalDateTime atTime) {
// int limitSize = plugin.getConfigFile().getMaxiumNumberOfTopVotersToLoad();
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
LinkedHashMap<TopVoterPlayer, Integer> topVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
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);
int total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
topVoter.put(user.getTopVoterPlayer(), total);
}
}
}
}
return sortByValues(topVoter, false);
}
public synchronized void updateTopVoters(
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter) {
@@ -1,5 +1,6 @@
package com.bencodez.votingplugin.user;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
@@ -34,6 +35,14 @@ public class UserManager {
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
manager.addKey(new UserDataKeyInt("MilestoneCount"));
manager.addKey(new UserDataKeyInt("MonthTotal"));
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now().minusMonths(1))));
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now())));
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1))));
manager.addKey(new UserDataKeyInt(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2))));
}
manager.addKey(new UserDataKeyInt("AllTimeTotal"));
manager.addKey(new UserDataKeyInt("DailyTotal"));
manager.addKey(new UserDataKeyInt("WeeklyTotal"));
@@ -95,6 +104,15 @@ public class UserManager {
}
}
public String getMonthTotalsWithDatePath() {
LocalDateTime cTime = plugin.getTimeChecker().getTime();
return getMonthTotalsWithDatePath(cTime);
}
public String getMonthTotalsWithDatePath(LocalDateTime cTime) {
return "MonthTotal-" + cTime.getMonth().toString() + "-" + cTime.getYear();
}
public ArrayList<String> getAllUUIDs() {
return plugin.getUserManager().getAllUUIDs();
}
@@ -539,7 +539,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
@Deprecated
public int getMonthTotal() {
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
return getTotal(TopVoter.Monthly);
}
public int getMonthVoteStreak() {
@@ -606,6 +606,30 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
case Daily:
return getUserData().getInt("DailyTotal", isCacheData(), isWaitForCache());
case Monthly:
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
return getData().getInt(plugin.getVotingPluginUserManager().getMonthTotalsWithDatePath(), isCacheData(),
isWaitForCache());
}
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
case Weekly:
return getUserData().getInt("WeeklyTotal", isCacheData(), isWaitForCache());
default:
break;
}
return 0;
}
public int getTotal(TopVoter top, LocalDateTime atTime) {
switch (top) {
case AllTime:
return getUserData().getInt("AllTimeTotal", isCacheData(), isWaitForCache());
case Daily:
return getUserData().getInt("DailyTotal", isCacheData(), isWaitForCache());
case Monthly:
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
return getData().getInt(plugin.getVotingPluginUserManager().getMonthTotalsWithDatePath(atTime),
isCacheData(), isWaitForCache());
}
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
case Weekly:
return getUserData().getInt("WeeklyTotal", isCacheData(), isWaitForCache());
@@ -689,7 +713,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
public boolean hasPercentageTotal(TopVoter top, double percentage, LocalDateTime time) {
int total = getTotal(top);
int total = getTotal(top, time);
switch (top) {
case Daily:
return (double) total / (double) plugin.getVoteSitesEnabled().size() * 100 > percentage;
@@ -1098,7 +1122,6 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
return highestNum;
}
public void setReminded(boolean reminded) {
@@ -1136,6 +1159,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
}
}
getData().setInt("MonthTotal", value);
if (plugin.getConfigFile().isStoreMonthTotalsWithDate()) {
getData().setInt(plugin.getVotingPluginUserManager().getMonthTotalsWithDatePath(), value);
}
break;
case Weekly:
getUserData().setInt("WeeklyTotal", value);