mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 17:10:03 -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 | ||
|
|
3e862efff2 | ||
|
|
52ca5467f7 | ||
|
|
61657dc670 | ||
|
|
4bac98c015 | ||
|
|
1215d224b4 | ||
|
|
6dde613558 | ||
|
|
99e34b5cd4 | ||
|
|
e049329f41 | ||
|
|
8fe4661fe1 | ||
|
|
af8cfc94a9 | ||
|
|
d98a9a9152 | ||
|
|
749ef7fa45 | ||
|
|
3f2a2fa33a | ||
|
|
2cb48d655a | ||
|
|
573315dd18 | ||
|
|
63091ad815 | ||
|
|
9e88f57bfb | ||
|
|
86d38d6ac9 | ||
|
|
e752d111a0 | ||
|
|
0a09d13bb3 | ||
|
|
08a6d91996 | ||
|
|
1082c47297 | ||
|
|
531812d800 | ||
|
|
903a7232de | ||
|
|
ed1a0c0708 | ||
|
|
15f12220a3 | ||
|
|
c24871c34d | ||
|
|
65e180ccf8 | ||
|
|
4cc523429d | ||
|
|
01b5e5f8a1 | ||
|
|
944458d858 | ||
|
|
9beaa4e440 | ||
|
|
3c78db5fe6 | ||
|
|
9400a4fa08 | ||
|
|
b4519bc6e7 | ||
|
|
f698481b97 | ||
|
|
927641f005 | ||
|
|
d85ad022fb | ||
|
|
e39fcd78ca | ||
|
|
6800ccd4a7 | ||
|
|
3065e57b44 | ||
|
|
fdcf092c7f | ||
|
|
7b9e734ccd | ||
|
|
5718e3261a | ||
|
|
e391ba88e4 | ||
|
|
b7942e763c | ||
|
|
cb039e052c | ||
|
|
07a4350f10 | ||
|
|
44130f6a52 | ||
|
|
6caf9afc1d | ||
|
|
7428581b4c | ||
|
|
a2dc362456 | ||
|
|
8d8e904a5f | ||
|
|
4485006fbb | ||
|
|
6fc3cb9096 | ||
|
|
cdf14896f0 | ||
|
|
bdd73b2873 | ||
|
|
e8781a0abe | ||
|
|
0d26b59777 | ||
|
|
fa0535cf32 | ||
|
|
2353ec321c | ||
|
|
cb4646f67d | ||
|
|
7a500f9cca | ||
|
|
b583b71721 |
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
|
||||
###########################################
|
||||
@@ -598,12 +618,19 @@ DefaultRewardBlackListedWorlds: []
|
||||
# Preload skulls to improve performance for vote top
|
||||
# when using skulls as the item to display players
|
||||
# If false, skulls will be cached as they are used
|
||||
# assuming loadskulls is enabled
|
||||
PreloadSkulls: false
|
||||
PreloadSkulls: true
|
||||
|
||||
# Setting to false disables saving skulls in a cache to improve speeds
|
||||
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
|
||||
LoadSkulls: true
|
||||
# Number of miliseconds between skull caching
|
||||
# Default about 3 seconds is good for most servers
|
||||
# Used to avoid rate limit, increase if needed
|
||||
# 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
|
||||
@@ -716,7 +743,7 @@ ExtraBackgroundUpdate: false
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Sound: 'ui.button.click'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
@@ -746,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
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ VoteParty:
|
||||
# Number of votes required to give rewards
|
||||
VotesRequired: 20
|
||||
# Increase the amount of votes required on each vote party reached
|
||||
#IncreaseVotesRquired: 10
|
||||
#IncreaseVotesRequired: 10
|
||||
# If true, players who did not vote to reach the votes required will
|
||||
# recieve the reward
|
||||
# If false, only players who voted get rewards
|
||||
@@ -97,7 +97,7 @@ VoteParty:
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# Send a broadcast at a certain number of votes left and send a vote reminder
|
||||
VoteReminderBroadcast: '%votesrequired% left to go, go vote!'
|
||||
# List of votes required amounts for when to send vote party reminders
|
||||
# Send vote reminder at number of votes to go
|
||||
VoteReminderAtVotes: []
|
||||
# List of commands to execute, these only execute once.
|
||||
# %player% does not work here
|
||||
|
||||
@@ -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
|
||||
##########################################
|
||||
|
||||
+210
-171
@@ -3,14 +3,16 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>${version.art}</artifactId>
|
||||
<version>6.17.1</version>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.18</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
<build.number>NOTSET</build.number>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<build>
|
||||
<resources>
|
||||
@@ -58,21 +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>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
@@ -185,31 +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>
|
||||
@@ -247,19 +209,19 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<version>1.18.36</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.2</version>
|
||||
<version>1.20-R0.3-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -277,13 +239,13 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<version>3.1.2-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-velocity</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>3.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -292,76 +254,44 @@
|
||||
<version>2.11.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>3.7.12</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>normal</id>
|
||||
<id>default</id>
|
||||
<properties>
|
||||
<build.profile.id>default</build.profile.id>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<build.profile.id>normal</build.profile.id>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>normal-folia</id>
|
||||
<properties>
|
||||
<build.profile.id>normal</build.profile.id>
|
||||
<version.art>votingplugin-folia</version.art>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore-folia</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod2</id>
|
||||
<properties>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>prod2</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<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>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>deploy-snapshot</build.profile.id>
|
||||
<build.profile.id>dev-snapshot</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
@@ -370,23 +300,67 @@
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<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>
|
||||
<version>3.11.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>install</phase>
|
||||
<configuration>
|
||||
<sourcepath>
|
||||
${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>3.1.3</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
@@ -398,7 +372,7 @@
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
@@ -416,9 +390,6 @@
|
||||
<profile>
|
||||
<id>javadoc</id>
|
||||
<properties>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>javadoc</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
@@ -428,20 +399,25 @@
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<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>
|
||||
<version>3.8.0</version>
|
||||
<version>3.11.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -458,26 +434,83 @@
|
||||
</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>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<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>
|
||||
<properties>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>deploy</build.profile.id>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
@@ -490,10 +523,43 @@
|
||||
</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>
|
||||
<version>3.8.0</version>
|
||||
<version>3.11.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -511,7 +577,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>3.1.3</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
@@ -535,33 +601,6 @@
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!--<plugin>
|
||||
<groupId>com.github.github</groupId>
|
||||
<artifactId>site-maven-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc</id>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<message>Maven javadoc for ${project.version}</message>
|
||||
<noJekyll>true</noJekyll>
|
||||
<outputDirectory>${project.build.directory}/apidocs
|
||||
</outputDirectory>
|
||||
<branch>refs/heads/gh-pages</branch>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<repositoryName>VotingPlugin</repositoryName>
|
||||
<repositoryOwner>BenCodez</repositoryOwner>
|
||||
<server>github</server>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@Deprecated
|
||||
public class User {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public User(Player p) {
|
||||
user = VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
}
|
||||
|
||||
public void addPoints(int points) {
|
||||
user.addPoints(points);
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return user.getPoints();
|
||||
}
|
||||
|
||||
public boolean removePoints(int points) {
|
||||
return user.removePoints(points);
|
||||
}
|
||||
|
||||
public void setPoints(int points) {
|
||||
user.setPoints(points);
|
||||
}
|
||||
}
|
||||
@@ -167,6 +167,8 @@ public class BungeeHandler implements Listener {
|
||||
plugin.debug("Detected time change from bungee: " + type.toString());
|
||||
plugin.getTimeChecker().forceChanged(type, false, true, true);
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
getGlobalMessageHandler().sendMessage("TimeChangeFinished",
|
||||
"" + plugin.getBungeeSettings().getServer());
|
||||
}
|
||||
}
|
||||
return isProcessing;
|
||||
@@ -226,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(
|
||||
@@ -251,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;
|
||||
@@ -53,12 +54,12 @@ import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationS
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
|
||||
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInjectConfigurationSection;
|
||||
import com.bencodez.advancedcore.api.skull.SkullHandler;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.yml.YMLConfig;
|
||||
import com.bencodez.advancedcore.logger.Logger;
|
||||
import com.bencodez.simpleapi.file.YMLConfig;
|
||||
import com.bencodez.simpleapi.nms.NMSManager;
|
||||
import com.bencodez.simpleapi.skull.SkullCache;
|
||||
import com.bencodez.simpleapi.updater.Updater;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
import com.bencodez.votingplugin.commands.CommandLoader;
|
||||
@@ -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>>();
|
||||
@@ -1495,8 +1506,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
specialRewardsConfig.reloadData();
|
||||
|
||||
gui.reloadData();
|
||||
shopFile.reloadData();
|
||||
|
||||
bungeeSettings.reloadData();
|
||||
updateAdvancedCoreHook();
|
||||
|
||||
reloadAdvancedCore(userStorage);
|
||||
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
if (getBungeeHandler() == null) {
|
||||
@@ -1512,10 +1527,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
broadcastHandler.schedule(getConfigFile().getFormatAlternateBroadcastDelay());
|
||||
}
|
||||
|
||||
updateAdvancedCoreHook();
|
||||
plugin.loadVoteSites();
|
||||
|
||||
reloadAdvancedCore(userStorage);
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
@@ -1580,6 +1593,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
synchronized (plugin) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
getUserManager().getDataManager().clearCacheBasic();
|
||||
SkullCache.flushWeek();
|
||||
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
@@ -1723,7 +1737,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
Set<TopVoterPlayer> players = topVoter.get(top).keySet();
|
||||
for (TopVoterPlayer p : players) {
|
||||
if (num <= maxToLoad) {
|
||||
SkullHandler.getInstance().loadSkull(p.getPlayerName());
|
||||
getSkullCacheHandler().addToCache(p.getUuid(), p.getPlayerName());
|
||||
}
|
||||
num++;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -382,6 +389,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);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
@@ -409,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
|
||||
@@ -416,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;
|
||||
@@ -437,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);
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -477,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";
|
||||
@@ -620,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()) {
|
||||
@@ -737,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);
|
||||
@@ -876,6 +902,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
if (message[0].equalsIgnoreCase("statusokay")) {
|
||||
String server = message[1];
|
||||
getLogger().info("Status okay for " + server);
|
||||
} else if (message[0].equalsIgnoreCase("TimeChangeFinished")) {
|
||||
|
||||
} else if (message[0].equalsIgnoreCase("login")) {
|
||||
String player = message[1];
|
||||
String uuid = message[2];
|
||||
@@ -1145,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());
|
||||
@@ -1183,6 +1217,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
String server = in.readUTF();
|
||||
getLogger().info("Status okay for " + server);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("TimeChangeFinished")) {
|
||||
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
String player = in.readUTF();
|
||||
String uuid = in.readUTF();
|
||||
@@ -1346,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 {
|
||||
@@ -1353,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
|
||||
@@ -1423,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());
|
||||
@@ -1443,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)));
|
||||
@@ -1454,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);
|
||||
}
|
||||
|
||||
+76
-9
@@ -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);
|
||||
@@ -387,6 +393,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);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
@@ -414,6 +422,11 @@ public class VotingPluginVelocity {
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
logger.info(text);
|
||||
}
|
||||
}, servers) {
|
||||
|
||||
@Override
|
||||
@@ -421,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);
|
||||
@@ -439,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);
|
||||
}
|
||||
|
||||
};
|
||||
@@ -479,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
|
||||
@@ -497,7 +519,10 @@ public class VotingPluginVelocity {
|
||||
String server = in.readUTF();
|
||||
logger.info("Status okay for " + server);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("TimeChangeFinished")) {
|
||||
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
|
||||
String player = in.readUTF();
|
||||
String uuid = in.readUTF();
|
||||
String serverName = "";
|
||||
@@ -505,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();
|
||||
@@ -515,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);
|
||||
@@ -665,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()) {
|
||||
@@ -701,6 +736,7 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
}
|
||||
globalDataHandler.onTimeChange(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -825,6 +861,7 @@ public class VotingPluginVelocity {
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
|
||||
bungeeTimeChecker.loadTimer();
|
||||
|
||||
try {
|
||||
@@ -851,7 +888,9 @@ public class VotingPluginVelocity {
|
||||
data.getNode("Time").getLong(), data.getNode("Real").getBoolean(),
|
||||
data.getNode("Text").getString()));
|
||||
}
|
||||
cachedVotes.put(server.getServer(serverToCheck).get(), vote);
|
||||
if (server.getServer(serverToCheck).isPresent()) {
|
||||
cachedVotes.put(server.getServer(serverToCheck).get(), vote);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -959,6 +998,8 @@ public class VotingPluginVelocity {
|
||||
if (message[0].equalsIgnoreCase("statusokay")) {
|
||||
String server = message[1];
|
||||
getLogger().info("Status okay for " + server);
|
||||
} else if (message[0].equalsIgnoreCase("TimeChangeFinished")) {
|
||||
|
||||
} else if (message[0].equalsIgnoreCase("login")) {
|
||||
String player = message[1];
|
||||
String uuid = message[2];
|
||||
@@ -980,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(),
|
||||
@@ -1414,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 {
|
||||
@@ -1421,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
|
||||
@@ -1490,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());
|
||||
@@ -1509,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)));
|
||||
@@ -1520,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package com.bencodez.votingplugin.commands;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map.Entry;
|
||||
@@ -39,7 +37,6 @@ import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
import com.bencodez.advancedcore.api.yml.editor.ConfigEditor;
|
||||
import com.bencodez.advancedcore.api.yml.updater.ConfigUpdater;
|
||||
import com.bencodez.advancedcore.command.gui.UserGUI;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.command.TabCompleteHandle;
|
||||
@@ -69,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;
|
||||
@@ -726,6 +724,7 @@ public class CommandLoader {
|
||||
+ "Detected that server hasn't received any votes from votifier, please check votifier connection");
|
||||
}
|
||||
if (!plugin.getConfigFile().isDisableUpdateChecking()
|
||||
&& !plugin.getDescription().getVersion().endsWith("SNAPSHOT") && plugin.getUpdater() != null
|
||||
&& plugin.getUpdater().getResult().equals(Updater.UpdateResult.UPDATE_AVAILABLE)) {
|
||||
sendMessage(sender,
|
||||
"&3Plugin has update available! https://www.spigotmc.org/resources/votingplugin.15358/");
|
||||
@@ -753,6 +752,7 @@ public class CommandLoader {
|
||||
+ "Detected that server hasn't received any votes from votifier, please check votifier connection");
|
||||
}
|
||||
if (!plugin.getConfigFile().isDisableUpdateChecking()
|
||||
&& !plugin.getDescription().getVersion().endsWith("SNAPSHOT") && plugin.getUpdater() != null
|
||||
&& plugin.getUpdater().getResult().equals(Updater.UpdateResult.UPDATE_AVAILABLE)) {
|
||||
sendMessage(sender,
|
||||
"&3Plugin has update available! https://www.spigotmc.org/resources/votingplugin.15358/");
|
||||
@@ -793,7 +793,7 @@ public class CommandLoader {
|
||||
sendMessage(sender, "AdvancedCore Jenkins build number: " + plugin.getAdvancedCoreBuildNumber());
|
||||
}
|
||||
if (!plugin.getBuildNumber().equals("NOTSET")) {
|
||||
sendMessage(sender, "Using votingplugin jenkins build: " + plugin.getBuildNumber());
|
||||
sendMessage(sender, "Using VotingPlugin jenkins build: " + plugin.getBuildNumber());
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -868,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);
|
||||
}
|
||||
@@ -878,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") {
|
||||
|
||||
@@ -1090,7 +1114,8 @@ public class CommandLoader {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(),
|
||||
false);
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()
|
||||
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
sendMessage(sender,
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
@@ -1116,11 +1141,14 @@ public class CommandLoader {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1], args[2],
|
||||
false);
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()
|
||||
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
sendMessage(sender, "&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
}
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage() && !isPlayer(sender)) {
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
}
|
||||
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@@ -1147,9 +1175,12 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1],
|
||||
args[2], false);
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage() && !isPlayer(sender)) {
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
}
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()
|
||||
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
sendMessage(sender,
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
@@ -1199,7 +1230,8 @@ public class CommandLoader {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(),
|
||||
false);
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()
|
||||
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
sendMessage(sender,
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
@@ -1223,9 +1255,12 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[3], true), args[1],
|
||||
args[3], false);
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage() && !isPlayer(sender)) {
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
}
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()
|
||||
&& !plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
sendMessage(sender,
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
@@ -1288,24 +1323,6 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "Config", "Update" },
|
||||
"VotingPlugin.Commands.AdminVote.Config.Edit|" + adminPerm,
|
||||
"Force update Config.yml with new options") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
try {
|
||||
ConfigUpdater.update(plugin, "Config.yml", plugin.getConfigFile().getdFile(), Arrays
|
||||
.asList("VoteReminding", "MySQL", "CustomCommands", "CustomPlaceholderReturns"));
|
||||
plugin.getConfigFile().reloadData();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
sendMessage(sender, "&aUpdated config");
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "VoteSite", "(sitename)", "SetServiceSite", "(string)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Set VoteSite SerivceSite") {
|
||||
@@ -1667,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");
|
||||
}
|
||||
});
|
||||
@@ -1747,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,
|
||||
@@ -2445,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") {
|
||||
|
||||
|
||||
@@ -70,10 +70,17 @@ public class VoteShop extends GUIHandler {
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
String p = "";
|
||||
if (perm.startsWith("!")) {
|
||||
hasPerm = !player.hasPermission(perm.substring(1));
|
||||
p = PlaceholderUtils.replacePlaceHolders(player, perm.substring(1));
|
||||
hasPerm = !player.hasPermission(p);
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
p = PlaceholderUtils.replacePlaceHolders(player, perm);
|
||||
hasPerm = player.hasPermission(p);
|
||||
}
|
||||
if (!hasPerm) {
|
||||
plugin.extraDebug("VoteShop: " + player.getName() + "/" + player.getUniqueId()
|
||||
+ " does not have permission `" + p + "` for " + identifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +199,7 @@ public class VoteShop extends GUIHandler {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getShopFile().getData(),
|
||||
"CHEST.VoteShopExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
"ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -101,8 +101,8 @@ public class VoteToday extends GUIHandler {
|
||||
} else {
|
||||
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
|
||||
}
|
||||
item.setName(PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
|
||||
"player", user.getPlayerName()));
|
||||
item.setName(PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(), "player",
|
||||
user.getPlayerName()));
|
||||
item.setLore(msg);
|
||||
final UUID uuid = user.getUuid();
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
|
||||
@@ -116,24 +116,30 @@ public class VoteToday extends GUIHandler {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String guiPath = "VoteToday";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTodayBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
});}
|
||||
|
||||
if(plugin.getGui().isChestVoteTodayBackButton()){inv.addButton(plugin.getCommandLoader().getBackButton(user));}inv.openInventory(player);}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodToday().toUpperCase()));
|
||||
@@ -150,8 +156,8 @@ public class VoteToday extends GUIHandler {
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", voteSite.getKey());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
|
||||
// timeString);
|
||||
}
|
||||
@@ -179,8 +185,8 @@ public class VoteToday extends GUIHandler {
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", mostRecentSite.getKey());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
|
||||
+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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -157,8 +157,8 @@ public class VoteURL extends GUIHandler {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
if (site.getPermissionToView().isEmpty() || player.hasPermission(site.getPermissionToView())) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
|
||||
site.getDisplayName());
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout())
|
||||
.addPlaceholder("sitename", site.getDisplayName()).addPlaceholder("num", "" + i);
|
||||
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
|
||||
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
|
||||
if (user.canVoteSite(site)) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bencodez.votingplugin.config;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
|
||||
@@ -7,8 +7,8 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
@@ -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
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataConfigurationSection;
|
||||
|
||||
@@ -6,12 +6,13 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataDouble;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
@@ -66,7 +67,7 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesWeekly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesWeekly = false;
|
||||
@@ -75,9 +76,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!";
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.VoteReminderAtVotes")
|
||||
@ConfigDataListInt(path = "VoteParty.VoteReminderAtVotes")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyVoteReminderAtVotes = new ArrayList<String>();
|
||||
private ArrayList<Integer> votePartyVoteReminderAtVotes = new ArrayList<Integer>();
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
|
||||
@Getter
|
||||
@@ -232,10 +233,23 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private boolean votePartyGiveAllPlayers = false;
|
||||
|
||||
@Deprecated
|
||||
@ConfigDataInt(path = "VoteParty.IncreaseVotesRquired")
|
||||
@Getter
|
||||
private int votePartyIncreaseVotesRquired = 0;
|
||||
|
||||
@ConfigDataInt(path = "VoteParty.IncreaseVotesRequired")
|
||||
@Getter
|
||||
private int votePartyIncreaseVotesRequired = 0;
|
||||
|
||||
public int getVotePartyIncreaseVotesRequiredWithTypo() {
|
||||
int increase = getVotePartyIncreaseVotesRequired();
|
||||
if (increase > 0) {
|
||||
return increase;
|
||||
}
|
||||
return getVotePartyIncreaseVotesRquired();
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
|
||||
@Getter
|
||||
private boolean votePartyOnlyOncePerDay = false;
|
||||
|
||||
@@ -42,6 +42,8 @@ public class PlayerJoinEvent implements Listener {
|
||||
if (data) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
} else {
|
||||
plugin.debug("No data detected for " + player.getUniqueId().toString() + "/" + player.getName());
|
||||
}
|
||||
|
||||
user.loginRewards();
|
||||
|
||||
@@ -134,6 +134,9 @@ public class PlayerVoteListener implements Listener {
|
||||
|
||||
user.updateName(true);
|
||||
|
||||
// vote party
|
||||
plugin.getVoteParty().vote(user, event.isRealVote(), event.isForceBungee());
|
||||
|
||||
if (event.isBroadcast() && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
// broadcast vote if enabled in config
|
||||
if (plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
@@ -223,14 +226,14 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
LocalDateTime cTime = plugin.getTimeChecker().getTime();
|
||||
int days = cTime.getDayOfMonth();
|
||||
plugin.extraDebug("Current day of month: " + days + " Current total: " + value);
|
||||
if (value >= days * plugin.getVoteSitesEnabled().size()) {
|
||||
plugin.debug("Detected higher month total, changing. Current Total: " + value + " Days: " + days
|
||||
+ " New Total: " + days * plugin.getVoteSitesEnabled().size());
|
||||
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSitesEnabled().size());
|
||||
}
|
||||
}
|
||||
|
||||
// vote party
|
||||
plugin.getVoteParty().vote(user, event.isRealVote(), event.isForceBungee());
|
||||
|
||||
// other rewards
|
||||
plugin.getSpecialRewards().checkAllSites(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkAlmostAllSites(user, event.isForceBungee());
|
||||
|
||||
@@ -202,15 +202,16 @@ public class VoteSite {
|
||||
}
|
||||
|
||||
public void giveRewards(VotingPluginUser user, boolean online, boolean bungee) {
|
||||
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getEverySiteRewardPath())
|
||||
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
|
||||
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
|
||||
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
|
||||
|
||||
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getRewardsPath(key))
|
||||
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
|
||||
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
|
||||
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
|
||||
|
||||
new RewardBuilder(plugin.getConfigVoteSites().getData(), plugin.getConfigVoteSites().getEverySiteRewardPath())
|
||||
.setOnline(online).withPlaceHolder("ServiceSite", getServiceSite())
|
||||
.withPlaceHolder("SiteName", getDisplayName()).withPlaceHolder("VoteDelay", "" + getVoteDelay())
|
||||
.withPlaceHolder("VoteURL", getVoteURL()).setServer(bungee).send(user);
|
||||
}
|
||||
|
||||
public boolean hasRewards() {
|
||||
|
||||
@@ -115,7 +115,7 @@ public class PlaceHolders {
|
||||
identifier = PlaceholderUtils.replaceJavascript(p, identifier);
|
||||
}
|
||||
|
||||
if (!identifier.endsWith("Position")) {
|
||||
if (!identifier.toLowerCase().endsWith("position")) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
String str = placeholder.placeholderRequest(identifier);
|
||||
@@ -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) {
|
||||
@@ -573,6 +585,9 @@ public class PlaceHolders {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
if (!MessageAPI.isInt(identifier.split("_")[1])) {
|
||||
return "invalid";
|
||||
}
|
||||
int number = Integer.parseInt(identifier.split("_")[1]);
|
||||
if (user.getPoints() >= number) {
|
||||
return "true";
|
||||
@@ -602,7 +617,7 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!MessageAPI.isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
return "invalid";
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
@@ -653,7 +668,7 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!MessageAPI.isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
return "invalid";
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
@@ -690,7 +705,7 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!MessageAPI.isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
return "invalid";
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
@@ -741,7 +756,7 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!MessageAPI.isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
return "invalid";
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
@@ -792,7 +807,7 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!MessageAPI.isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
return "invalid";
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -61,7 +61,7 @@ public class VoteTester {
|
||||
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
StringBuilder salt = new StringBuilder();
|
||||
Random rnd = new Random();
|
||||
while (salt.length() < 18) { // length of the random string.
|
||||
while (salt.length() < 12) { // length of the random string.
|
||||
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
|
||||
salt.append(SALTCHARS.charAt(index));
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -13,6 +15,8 @@ import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -26,8 +30,8 @@ import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFileHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -83,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();
|
||||
@@ -98,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);
|
||||
}
|
||||
@@ -236,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()) {
|
||||
@@ -245,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());
|
||||
@@ -263,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();
|
||||
@@ -281,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++;
|
||||
@@ -344,6 +456,12 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPreDateChanged(PreDateChangedEvent event) {
|
||||
if (event.getTimeType().equals(TimeType.DAY)) {
|
||||
plugin.getBannedPlayers().clear();
|
||||
for (OfflinePlayer p : Bukkit.getBannedPlayers()) {
|
||||
plugin.getBannedPlayers().add(p.getUniqueId().toString());
|
||||
}
|
||||
}
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
}
|
||||
@@ -805,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) {
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.PlayerManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -30,7 +29,7 @@ public class TopVoterPlayer {
|
||||
}
|
||||
|
||||
public ItemStack getPlayerHead() {
|
||||
return PlayerManager.getInstance().getPlayerSkull(getPlayerName(), false);
|
||||
return VotingPluginMain.plugin.getSkullCacheHandler().getSkull(uuid, playerName);
|
||||
}
|
||||
|
||||
public VotingPluginUser getUser() {
|
||||
|
||||
@@ -22,7 +22,8 @@ public class CheckUpdate {
|
||||
* Check update.
|
||||
*/
|
||||
public void checkUpdate() {
|
||||
if (plugin.getConfigFile().isDisableUpdateChecking()) {
|
||||
if (plugin.getConfigFile().isDisableUpdateChecking()
|
||||
|| plugin.getDescription().getVersion().endsWith("SNAPSHOT")) {
|
||||
return;
|
||||
}
|
||||
plugin.setUpdater(new Updater(plugin, 15358, false));
|
||||
@@ -69,7 +70,8 @@ public class CheckUpdate {
|
||||
* Start up.
|
||||
*/
|
||||
public void startUp() {
|
||||
if (plugin.getConfigFile().isDisableUpdateChecking()) {
|
||||
if (plugin.getConfigFile().isDisableUpdateChecking()
|
||||
|| plugin.getDescription().getVersion().endsWith("SNAPSHOT")) {
|
||||
return;
|
||||
}
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -229,6 +229,7 @@ public class VoteParty implements Listener {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyGiveAllPlayers()) {
|
||||
plugin.debug("Trying to give all players vote party");
|
||||
|
||||
ArrayList<String> alreadyGotten = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser user;
|
||||
@@ -262,7 +263,9 @@ public class VoteParty implements Listener {
|
||||
} else {
|
||||
plugin.debug("Trying to give all voted players vote party");
|
||||
plugin.debug(ArrayUtils.makeStringList(getVotedUsers()));
|
||||
for (String uuid : getVotedUsers()) {
|
||||
for (String uuid :
|
||||
|
||||
getVotedUsers()) {
|
||||
VotingPluginUser user;
|
||||
if (orgUser != null && orgUser.getJavaUUID().toString().equals(uuid)) {
|
||||
user = orgUser;
|
||||
@@ -276,6 +279,7 @@ public class VoteParty implements Listener {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
reset(false);
|
||||
}
|
||||
|
||||
@@ -346,11 +350,11 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
|
||||
public void checkVoteReminder(VotingPluginUser user) {
|
||||
int neededVotes = getNeededVotes();
|
||||
if (!user.isVanished()) {
|
||||
int neededVotes = getNeededVotes();
|
||||
|
||||
for (String str : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) {
|
||||
if (MessageAPI.isInt(str)) {
|
||||
int num = Integer.parseInt(str);
|
||||
for (Integer num1 : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) {
|
||||
int num = num1.intValue();
|
||||
if (neededVotes == num) {
|
||||
String broadcastMessage = plugin.getSpecialRewardsConfig().getVotePartyVoteReminderBroadcast();
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
@@ -361,6 +365,7 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized void vote(VotingPluginUser user, boolean realVote, boolean forceBungee) {
|
||||
|
||||
Reference in new issue
Block a user