mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 09:02:00 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2fe26aaea | ||
|
|
2aa84c90e8 | ||
|
|
c8cace388e | ||
|
|
1da028476f | ||
|
|
c28bddd0ba | ||
|
|
1afd8253a5 | ||
|
|
a3a1b4604f | ||
|
|
3bd41af200 | ||
|
|
0042045d9b | ||
|
|
76d7579c7d | ||
|
|
f591b863f1 | ||
|
|
b43c4b89a8 | ||
|
|
f9d7f5a136 | ||
|
|
338853a29f | ||
|
|
7d0722d5c4 | ||
|
|
86e6bca31d | ||
|
|
8488233be1 | ||
|
|
ba5f8dfa6d | ||
|
|
dc865f1d20 | ||
|
|
5dedb644b2 | ||
|
|
c041c7c33a | ||
|
|
bbc0c4a88e | ||
|
|
4d200f6675 | ||
|
|
ad7970c99d | ||
|
|
2ab6ff5105 | ||
|
|
0470993b81 | ||
|
|
7de3dff221 | ||
|
|
c17f6facbb | ||
|
|
d0e2a7987b | ||
|
|
c9d3b1655d | ||
|
|
348ad9d3d5 | ||
|
|
f90b87fa5a | ||
|
|
5b19d3397a | ||
|
|
dad0f88865 |
No files matched your search
@@ -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
|
||||
###########################################
|
||||
@@ -606,6 +626,12 @@ PreloadSkulls: true
|
||||
# If rate limit is hit caching will pause for 15 minutes
|
||||
SkullLoadDelay: 3000
|
||||
|
||||
# Set a skull profile URL
|
||||
# This is what gets used to cache skulls
|
||||
# Default: https://sessionserver.mojang.com/session/minecraft/profile/
|
||||
# Other examples: https://crafthead.net/profile/
|
||||
SkullProfileAPIURL: ''
|
||||
|
||||
###########################################
|
||||
# Extra checks on vote
|
||||
###########################################
|
||||
@@ -747,9 +773,20 @@ CloseGUIOnShiftClick: false
|
||||
# Purge settings
|
||||
###########################################
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
# Recommend leaving this disabled
|
||||
# When disabled it also disables the commands to manually purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Enable auto purging data on startup
|
||||
# Do not enable unless you know what you are doing
|
||||
# Purges players with vote totals
|
||||
# Requires PurgeOldData to be enabled
|
||||
PurgeDataOnStartup: false
|
||||
|
||||
# Same as above, but checks players have no vote total before purging
|
||||
# Requires PurgeOldData to be enabled
|
||||
PurgeNoDataOnStartup: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
|
||||
@@ -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
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.17.3</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.10-SNAPSHOT</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;
|
||||
|
||||
@@ -1064,6 +1069,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
loadVersionFile();
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
|
||||
// only purges if enabled in config
|
||||
getVotingPluginUserManager().purgeOldPlayersNoData();
|
||||
|
||||
voteTester = new VoteTester(plugin);
|
||||
|
||||
loadVoteTimer();
|
||||
@@ -1108,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>>();
|
||||
@@ -1511,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);
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigBungee;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
@@ -354,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
|
||||
@@ -361,7 +368,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
@@ -411,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
|
||||
@@ -418,7 +431,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
@@ -439,6 +452,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getGlobalDataHandler().setBoolean(server, type.toString(), false);
|
||||
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
|
||||
getGlobalDataHandler().setBoolean(server, "Processing", false);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -479,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";
|
||||
@@ -622,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()) {
|
||||
@@ -739,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);
|
||||
@@ -1149,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());
|
||||
@@ -1352,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 {
|
||||
@@ -1359,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
|
||||
@@ -1429,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());
|
||||
@@ -1449,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)));
|
||||
@@ -1460,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);
|
||||
}
|
||||
|
||||
+65
-8
@@ -49,6 +49,7 @@ import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigVelocity;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
@@ -363,6 +364,11 @@ public class VotingPluginVelocity {
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
logger.info(text);
|
||||
}
|
||||
}, servers) {
|
||||
|
||||
@Override
|
||||
@@ -370,7 +376,7 @@ public class VotingPluginVelocity {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
|
||||
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
|
||||
@@ -416,6 +422,11 @@ public class VotingPluginVelocity {
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
logger.info(text);
|
||||
}
|
||||
}, servers) {
|
||||
|
||||
@Override
|
||||
@@ -423,7 +434,7 @@ public class VotingPluginVelocity {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
|
||||
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
|
||||
@@ -441,6 +452,8 @@ public class VotingPluginVelocity {
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getGlobalDataHandler().setBoolean(server, type.toString(), false);
|
||||
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
|
||||
getGlobalDataHandler().setBoolean(server, "Processing", false);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -481,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
|
||||
@@ -510,6 +530,9 @@ public class VotingPluginVelocity {
|
||||
serverName = in.readUTF();
|
||||
}
|
||||
debug("Login: " + player + "/" + uuid + " " + serverName);
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayerCheck(uuid, player);
|
||||
}
|
||||
if (server.getPlayer(player).isPresent()
|
||||
&& (getGlobalDataHandler() == null || !getGlobalDataHandler().isTimeChangedHappened())) {
|
||||
Player p = server.getPlayer(player).get();
|
||||
@@ -520,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);
|
||||
@@ -670,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()) {
|
||||
@@ -831,6 +861,7 @@ public class VotingPluginVelocity {
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
|
||||
bungeeTimeChecker.loadTimer();
|
||||
|
||||
try {
|
||||
@@ -990,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(),
|
||||
@@ -1424,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 {
|
||||
@@ -1431,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
|
||||
@@ -1500,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());
|
||||
@@ -1519,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)));
|
||||
@@ -1530,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;
|
||||
@@ -867,7 +868,6 @@ public class CommandLoader {
|
||||
sender.sendMessage(MessageAPI.colorize("&cThis command can not be done from ingame"));
|
||||
return;
|
||||
}
|
||||
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
plugin.getUserManager().removeAllKeyValues(top.getColumnName(), DataType.INTEGER);
|
||||
}
|
||||
@@ -877,6 +877,31 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "ResetTotal", "(TopVoter)" },
|
||||
"VotingPlugin.Commands.AdminVote.ResetTotal.All|" + adminPerm,
|
||||
"Reset specific totals for all players (DAY/WEEK/MONTH)") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(MessageAPI.colorize("&cThis command can not be done from ingame"));
|
||||
return;
|
||||
}
|
||||
|
||||
TopVoter top = TopVoter.getTopVoter(args[1]);
|
||||
if (top.equals(TopVoter.AllTime)) {
|
||||
sendMessage(sender, "&cCan't reset all time total or invalid argument: " + args[1]);
|
||||
return;
|
||||
}
|
||||
plugin.getUserManager().removeAllKeyValues(top.getColumnName(), DataType.INTEGER);
|
||||
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
plugin.setUpdate(true);
|
||||
sender.sendMessage(MessageAPI.colorize("&cCleared totals of " + top.getColumnName()));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "ClearOfflineVoteRewards" },
|
||||
"VotingPlugin.Commands.AdminVote.ClearOfflineVoteRewards|" + adminPerm, "Reset offline votes/rewards") {
|
||||
|
||||
@@ -1659,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");
|
||||
}
|
||||
});
|
||||
@@ -1739,6 +1768,17 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "PurgeNoData" },
|
||||
"VotingPlugin.PurgeNoData",
|
||||
"Purge players from database with no data and haven't been online for a number of days (Set in Config.yml)") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
plugin.getVotingPluginUserManager().purgeOldPlayersNowNoData();
|
||||
sendMessage(sender, "&cPurged players with no data");
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "RemoveOfflineUUIDs" },
|
||||
"VotingPlugin.Commands.AdminVote.RemoveOfflineUUIDs|" + adminPerm,
|
||||
@@ -2437,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") {
|
||||
|
||||
|
||||
+150
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -663,13 +663,17 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private int pointsOnVote = 1;
|
||||
|
||||
@ConfigDataInt(path = "PurgeMin")
|
||||
@ConfigDataBoolean(path = "PurgeNoDataOnStartup")
|
||||
@Getter
|
||||
private int purgeMin = 90;
|
||||
private boolean purgeNoDataOnStartup = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PurgeOldData")
|
||||
@ConfigDataBoolean(path = "StoreMonthTotalsWithDate")
|
||||
@Getter
|
||||
private boolean purgeOldData = false;
|
||||
private boolean storeMonthTotalsWithDate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseMonthDateTotalsAsPrimaryTotal")
|
||||
@Getter
|
||||
private boolean useMonthDateTotalsAsPrimaryTotal = false;
|
||||
|
||||
@ConfigDataString(path = "RequestAPI.DefaultMethod")
|
||||
@Getter
|
||||
|
||||
@@ -352,6 +352,18 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get number of votes until next available milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("lastmilestone_votes_since") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int toGo = user.getMilestoneCount() - user.getLastGottenMilestone();
|
||||
if (toGo >= 0) {
|
||||
return "" + toGo;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
}.withDescription("Get number of votes since last milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
|
||||
if (plugin.getShopFile().getShopIdentifierLimit(identifier) > 0) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
|
||||
|
||||
@@ -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,16 +1,23 @@
|
||||
package com.bencodez.votingplugin.user;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.advancedcore.api.user.usercache.UserDataManager;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
public class UserManager {
|
||||
private VotingPluginMain plugin;
|
||||
@@ -28,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"));
|
||||
@@ -89,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();
|
||||
}
|
||||
@@ -124,4 +148,81 @@ public class UserManager {
|
||||
public VotingPluginUser getVotingPluginUser(UUID uuid, boolean loadName) {
|
||||
return new VotingPluginUser(plugin, uuid, loadName);
|
||||
}
|
||||
|
||||
public void purgeOldPlayersNoData() {
|
||||
if (plugin.getOptions().isPurgeOldData() && plugin.getConfigFile().isPurgeNoDataOnStartup()) {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
plugin.debug("Finished no data purging");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser acUser) {
|
||||
VotingPluginUser user = getVotingPluginUser(acUser);
|
||||
user.dontCache();
|
||||
int daysOld = plugin.getOptions().getPurgeMinimumDays();
|
||||
int days = user.getNumberOfDaysSinceLogin();
|
||||
if (days == -1) {
|
||||
// fix ones with no last online
|
||||
user.setLastOnline(System.currentTimeMillis());
|
||||
} else if (days > daysOld) {
|
||||
if (user.getTotal(TopVoter.AllTime) == 0 && user.getMilestoneCount() == 0
|
||||
&& user.getTotal(TopVoter.Monthly) == 0 && user.getTotal(TopVoter.Weekly) == 0
|
||||
&& user.getTotal(TopVoter.Daily) == 0) {
|
||||
plugin.debug("Removing " + user.getUUID() + " because of no data purge");
|
||||
user.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
}
|
||||
|
||||
public void purgeOldPlayersNowNoData() {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin.isEnabled()) {
|
||||
if (uuid != null) {
|
||||
VotingPluginUser user = getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
if (user != null) {
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
int daysOld = plugin.getOptions().getPurgeMinimumDays();
|
||||
int days = user.getNumberOfDaysSinceLogin();
|
||||
if (days == -1) {
|
||||
// fix ones with no last online
|
||||
user.setLastOnline(System.currentTimeMillis());
|
||||
} else if (days > daysOld) {
|
||||
if (user.getTotal(TopVoter.AllTime) == 0 && user.getMilestoneCount() == 0
|
||||
&& user.getTotal(TopVoter.Monthly) == 0 && user.getTotal(TopVoter.Weekly) == 0
|
||||
&& user.getTotal(TopVoter.Daily) == 0)
|
||||
plugin.debug("Removing " + user.getUUID() + " because of no data purge");
|
||||
user.remove();
|
||||
}
|
||||
|
||||
user.clearTempCache();
|
||||
cols.put(playerData.getKey(), null);
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -1074,6 +1098,32 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
}
|
||||
|
||||
public int getLastGottenMilestone() {
|
||||
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
int mileStoneCount = getMilestoneCount();
|
||||
for (String vote : mVotes) {
|
||||
if (MessageAPI.isInt(vote)) {
|
||||
final int num = Integer.parseInt(vote);
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
|
||||
nums.add(Integer.valueOf(num));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int highestNum = -1;
|
||||
|
||||
for (Integer num : nums) {
|
||||
if (mileStoneCount > num.intValue()) {
|
||||
if (highestNum == -1 || num.intValue() > highestNum) {
|
||||
highestNum = num.intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return highestNum;
|
||||
}
|
||||
|
||||
public void setReminded(boolean reminded) {
|
||||
getUserData().setString("Reminded", "" + reminded);
|
||||
}
|
||||
@@ -1109,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);
|
||||
|
||||
Reference in new issue
Block a user