Compare commits

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

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-12-09 06:43:18 +00:00
BenCodez f9d7f5a136 Adjust default caching columns 2024-12-08 14:38:28 -06:00
BenCodez 338853a29f Fix issues with new month total date system 2024-12-08 14:34:54 -06:00
BenCodez 7d0722d5c4 Fix vote streak command not working for multiples 2024-12-08 12:37:52 -06:00
BenCodez 86e6bca31d Small adjustment to vote streaking handling 2024-12-08 12:21:12 -06:00
BenCodez 8488233be1 More work on new month date totals 2024-12-07 21:13:56 -06:00
BenCodez ba5f8dfa6d Implement month totals with dates on proxy servers 2024-12-07 17:56:50 -06:00
BenCodez dc865f1d20 First implementation of storing and using totals with month names 2024-12-07 16:03:19 -06:00
BenCodez 5dedb644b2 More adjustments to build numbers on jar files 2024-12-06 20:59:52 -06:00
BenCodez c041c7c33a Adjust maven profile 2024-12-06 20:55:55 -06:00
BenCodez bbc0c4a88e Implement first steps at including version number in jar name 2024-12-06 20:52:47 -06:00
BenCodez 4d200f6675 Change version number to 6.17.5-SNAPSHOT 2024-12-01 16:22:51 -06:00
BenCodez ad7970c99d Update version number to 6.17.4 2024-12-01 16:06:45 -06:00
BenCodez 2ab6ff5105 Added /av resettotal (topvoter) 2024-11-30 20:37:38 -06:00
BenCodez 0470993b81 Adjustments to wiping column data 2024-11-30 20:33:03 -06:00
BenCodez 7de3dff221 Adjustments to time change handling in certain cases on proxy 2024-11-30 20:07:13 -06:00
Ben c17f6facbb Delete .github/workflows/jekyll-gh-pages.yml 2024-11-29 11:00:31 -06:00
Ben d0e2a7987b Create jekyll-gh-pages.yml 2024-11-29 10:59:27 -06:00
BenCodez c9d3b1655d Fix nonvotedplayerscache not working on velocity as it should 2024-11-29 08:27:11 -06:00
BenCodez 348ad9d3d5 Added new config option SkullProfileAPIURL 2024-11-28 12:37:26 -06:00
BenCodez f90b87fa5a Add new options for purging, new purge with no data check 2024-11-25 20:43:05 -06:00
BenCodez 5b19d3397a Add new placeholder for number of votes since last milestone 2024-11-24 14:47:31 -06:00
BenCodez dad0f88865 Change version to 6.17.4-SNAPSHOT 2024-11-24 14:34:32 -06:00
BenCodez 3e862efff2 Fix javadoc issue 2024-11-24 14:24:01 -06:00
BenCodez 52ca5467f7 Update version number to 6.17.3 2024-11-24 14:06:58 -06:00
BenCodez 61657dc670 Disable update checking on dev builds 2024-11-24 11:24:03 -06:00
BenCodez 4bac98c015 Quick fix 2024-11-23 11:22:55 -06:00
BenCodez 1215d224b4 Changes to vote party remindatvotes is gotten from specialrewards.yml 2024-11-23 11:21:57 -06:00
BenCodez 6dde613558 Modify hiding triggering vote message in console 2024-11-21 19:33:52 -06:00
BenCodez 99e34b5cd4 Hide trigger vote message if noservicesitemessage is disabled 2024-11-21 16:23:34 -06:00
BenCodez e049329f41 Add ability to hide issue with service site message on /av vote 2024-11-21 16:16:26 -06:00
BenCodez 8fe4661fe1 Change default skull cache timing 2024-11-19 19:27:11 -06:00
BenCodez af8cfc94a9 Changes to default sound 2024-11-18 08:01:16 -06:00
Ben d98a9a9152 Merge pull request #1394 from BenCodez/dependabot/maven/VotingPlugin/org.projectlombok-lombok-1.18.36
Bump org.projectlombok:lombok from 1.18.34 to 1.18.36 in /VotingPlugin
2024-11-18 07:29:48 -06:00
dependabot[bot] 749ef7fa45 Bump org.projectlombok:lombok from 1.18.34 to 1.18.36 in /VotingPlugin
Bumps [org.projectlombok:lombok](https://github.com/projectlombok/lombok) from 1.18.34 to 1.18.36.
- [Changelog](https://github.com/projectlombok/lombok/blob/master/doc/changelog.markdown)
- [Commits](https://github.com/projectlombok/lombok/compare/v1.18.34...v1.18.36)

---
updated-dependencies:
- dependency-name: org.projectlombok:lombok
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-18 06:16:44 +00:00
BenCodez 3f2a2fa33a Change version system to snapshots 2024-11-17 14:53:33 -06:00
BenCodez 2cb48d655a Disable plugin update checking if using snapshot version 2024-11-17 14:48:32 -06:00
BenCodez 573315dd18 Use snapshot version 2024-11-17 14:45:47 -06:00
BenCodez 63091ad815 Add dev maven profile back 2024-11-17 13:54:30 -06:00
BenCodez 9e88f57bfb Cleanup pom.xml 2024-11-17 12:55:15 -06:00
BenCodez 86d38d6ac9 Set correct java version in pom.xml 2024-11-17 12:28:30 -06:00
BenCodez e752d111a0 Fix pom.xml 2024-11-16 22:04:59 -06:00
BenCodez 0a09d13bb3 Remove unneeded maven profiles 2024-11-16 17:30:04 -06:00
BenCodez 08a6d91996 Fix issue with reload order with GlobalData mysql connection 2024-11-07 08:47:12 -06:00
BenCodez 1082c47297 Flush skull cache not used for a week 2024-11-05 18:08:34 -06:00
BenCodez 531812d800 Check if sever still exists on velocity 2024-11-05 07:31:24 -06:00
BenCodez 903a7232de Use new api 2024-11-04 12:01:30 -06:00
Ben ed1a0c0708 Merge pull request #1392 from BenCodez/dependabot/maven/VotingPlugin/org.apache.maven.plugins-maven-javadoc-plugin-3.11.1
Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.10.1 to 3.11.1 in /VotingPlugin
2024-11-04 07:45:16 -06:00
dependabot[bot] 15f12220a3 Bump org.apache.maven.plugins:maven-javadoc-plugin in /VotingPlugin
Bumps [org.apache.maven.plugins:maven-javadoc-plugin](https://github.com/apache/maven-javadoc-plugin) from 3.10.1 to 3.11.1.
- [Release notes](https://github.com/apache/maven-javadoc-plugin/releases)
- [Commits](https://github.com/apache/maven-javadoc-plugin/compare/maven-javadoc-plugin-3.10.1...maven-javadoc-plugin-3.11.1)

---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-javadoc-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-04 06:55:01 +00:00
BenCodez c24871c34d Add new skull caching delay option 2024-11-03 13:58:25 -06:00
BenCodez 65e180ccf8 Remove all unused skull options 2024-11-03 13:48:02 -06:00
BenCodez 4cc523429d Changes to skull caching 2024-11-03 11:03:27 -06:00
BenCodez 01b5e5f8a1 Remove deprecated code 2024-11-02 16:45:50 -06:00
BenCodez 944458d858 Update to 1.21.3 2024-11-02 16:43:35 -06:00
BenCodez 9beaa4e440 Handle casing differences in position placeholder checking 2024-10-29 10:27:48 -06:00
32 changed files with 1080 additions and 336 deletions

No files matched your search

+44 -10
View File
@@ -591,6 +591,26 @@ DefaultRewardWorlds: []
# Default blackedlisted worlds set for all rewards
DefaultRewardBlackListedWorlds: []
###########################################
# Month Date Totals
# Experimental feature
###########################################
# Experimental
# Stores month votes with date formatting
# MonthTotal-MONTH-YEAR
# This setting only enables setting totals, not using them
# Enabling this is pretty safe and harmless with just this setting
# Essentially will just copy MonthTotal to MonthTotal-MONTH-YEAR
# Can use command /vote PreviousMonthsVoters after this is enabled
StoreMonthTotalsWithDate: false
# Experimental
# This setting uses month votes with date formatting
# If using this StoreMonthTotalsWithDate must be enabled
# This setting may be very buggy as it's in early stages
UseMonthDateTotalsAsPrimaryTotal: false
###########################################
# Skull settings
###########################################
@@ -598,16 +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
# If true, skulls will be loaded on GUI even if not cached
# May result in GUI taking longer to open until skulls are cached
ForceLoadSkulls: false
# 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
@@ -720,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
@@ -750,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
+1 -1
View File
@@ -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
+19
View File
@@ -158,6 +158,25 @@ OnlineMode: true
# If true plugin will atempt to lookup uuids if none exist
UUIDLookup: true
###########################################
# Month Date Totals
# Experimental feature
# Settings must match on backend servers
###########################################
# Experimental
# Stores month votes with date formatting
# MonthTotal-MONTH-YEAR
# This setting only enables setting totals, not using them
# Enabling this is pretty safe and harmless with just this setting
StoreMonthTotalsWithDate: false
# Experimental
# This setting uses month votes with date formatting
# If using this StoreMonthTotalsWithDate must be enabled
# This setting may be very buggy as it's in early stages
UseMonthDateTotalsAsPrimaryTotal: false
##########################################
# PLUGINMESSAGING Settings
##########################################
+207 -168
View File
@@ -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.2</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.1-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,7 +239,7 @@
<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>
@@ -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,19 +300,63 @@
</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>
@@ -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.10.1</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.10.1</version>
<version>3.11.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
@@ -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);
}
}
@@ -228,6 +228,11 @@ public class BungeeHandler implements Listener {
public void debug(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
});
} else {
globalDataHandler = new GlobalDataHandler(
@@ -253,6 +258,11 @@ public class BungeeHandler implements Listener {
public void debug(String text) {
plugin.debug(text);
}
@Override
public void info(String text) {
plugin.getLogger().info(text);
}
});
}
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
@@ -7,6 +7,7 @@ import java.net.URL;
import java.security.CodeSource;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.YearMonth;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -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>>();
@@ -1498,6 +1509,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
shopFile.reloadData();
bungeeSettings.reloadData();
updateAdvancedCoreHook();
reloadAdvancedCore(userStorage);
if (bungeeSettings.isUseBungeecoord()) {
if (getBungeeHandler() == null) {
@@ -1513,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();
@@ -1581,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());
@@ -1724,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;
@@ -411,6 +418,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
getLogger().info(text);
}
}, servers) {
@Override
@@ -418,7 +431,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (type.equals(TimeType.MONTH)) {
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
if (!config.getGlobalDataEnabled()) {
return;
@@ -439,6 +452,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getGlobalDataHandler().setBoolean(server, type.toString(), false);
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
getGlobalDataHandler().setBoolean(server, "Processing", false);
}
};
}
@@ -479,6 +494,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
if (config.getStoreMonthTotalsWithDate()) {
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
"INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
"INT DEFAULT '0'");
}
}
private String buildNumber = "NOTSET";
@@ -622,6 +644,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
getLogger().warning("Global data not enabled, ignoring time change event");
return;
}
for (String s : getAvailableAllServers()) {
@@ -739,6 +762,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
voteCacheFile = new VoteCache(this);
voteCacheFile.load();
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
bungeeTimeChecker.loadTimer();
nonVotedPlayersCache = new NonVotedPlayersCache(this);
@@ -1149,6 +1173,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
@Override
public void run() {
if (isOnline(p)) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
checkCachedVotes(server);
checkOnlineVotes(proxiedPlayer, proxiedPlayer.getUniqueId().toString(), server);
multiProxyHandler.login(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
@@ -1352,6 +1382,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
public String getMonthTotalsWithDatePath() {
LocalDateTime cTime = bungeeTimeChecker.getTime();
return getMonthTotalsWithDatePath(cTime);
}
public String getMonthTotalsWithDatePath(LocalDateTime cTime) {
return "MonthTotal-" + cTime.getMonth().toString() + "-" + cTime.getYear();
}
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
BungeeMessageData text, String uuid) {
try {
@@ -1359,10 +1398,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
getLogger().info("No name from vote on " + service);
return;
}
if (timeQueue) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
if (timeQueue && getGlobalDataHandler().isTimeChangedHappened()) {
timeChangeQueue.add(new VoteTimeQueue(player, service,
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
getLogger().info("Cachcing vote from " + player + "/" + service
@@ -1429,6 +1468,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
int monthTotal = getValue(data, "MonthTotal", 1);
int dateMonthTotal = -1;
if (config.getStoreMonthTotalsWithDate()) {
if (config.getUseMonthDateTotalsAsPrimaryTotal()) {
dateMonthTotal = getValue(data, getMonthTotalsWithDatePath(), 1);
} else {
dateMonthTotal = monthTotal;
}
}
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
@@ -1449,10 +1496,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
milestoneCount, votePartyVotes, currentVotePartyVotesRequired, dateMonthTotal);
ArrayList<Column> update = new ArrayList<Column>();
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
if (config.getStoreMonthTotalsWithDate()) {
update.add(new Column(getMonthTotalsWithDatePath(), new DataValueInt(dateMonthTotal)));
}
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
update.add(new Column("Points", new DataValueInt(points)));
@@ -1460,7 +1510,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
debug("Setting totals " + text.toString());
mysql.update(uuid, update);
} else {
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired, 0);
}
}
@@ -37,6 +37,18 @@ public class Config extends VelocityYMLFile {
return getBoolean(getNode("OnlineMode"), true);
}
public boolean getTimeChangeFailSafeBypass() {
return getBoolean(getNode("TimeChangeFailSafeBypass"), false);
}
public boolean getStoreMonthTotalsWithDate() {
return getBoolean(getNode("StoreMonthTotalsWithDate"), false);
}
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
return getBoolean(getNode("UseMonthDateTotalsAsPrimaryTotal"), false);
}
public boolean getUUIDLookup() {
return getBoolean(getNode("UUIDLookup"), true);
}
@@ -49,6 +49,7 @@ import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
import com.bencodez.advancedcore.api.user.userstorage.Column;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigVelocity;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
@@ -363,6 +364,11 @@ public class VotingPluginVelocity {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
logger.info(text);
}
}, servers) {
@Override
@@ -370,7 +376,7 @@ public class VotingPluginVelocity {
if (type.equals(TimeType.MONTH)) {
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
for (RegisteredServer s : getAvailableAllServers()) {
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
@@ -416,6 +422,11 @@ public class VotingPluginVelocity {
public void debug(String text) {
debug2(text);
}
@Override
public void info(String text) {
logger.info(text);
}
}, servers) {
@Override
@@ -423,7 +434,7 @@ public class VotingPluginVelocity {
if (type.equals(TimeType.MONTH)) {
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
}
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
getMysql().wipeColumnData(TopVoter.of(type).getColumnName(), DataType.INTEGER);
for (RegisteredServer s : getAvailableAllServers()) {
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
@@ -441,6 +452,8 @@ public class VotingPluginVelocity {
@Override
public void onTimeChangedFailed(String server, TimeType type) {
getGlobalDataHandler().setBoolean(server, type.toString(), false);
getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
getGlobalDataHandler().setBoolean(server, "Processing", false);
}
};
@@ -481,6 +494,13 @@ public class VotingPluginVelocity {
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
if (config.getStoreMonthTotalsWithDate()) {
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
"INT DEFAULT '0'");
getMysql().alterColumnType(getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
"INT DEFAULT '0'");
}
}
@Subscribe
@@ -510,6 +530,9 @@ public class VotingPluginVelocity {
serverName = in.readUTF();
}
debug("Login: " + player + "/" + uuid + " " + serverName);
if (nonVotedPlayersCache != null) {
nonVotedPlayersCache.addPlayerCheck(uuid, player);
}
if (server.getPlayer(player).isPresent()
&& (getGlobalDataHandler() == null || !getGlobalDataHandler().isTimeChangedHappened())) {
Player p = server.getPlayer(player).get();
@@ -520,6 +543,12 @@ public class VotingPluginVelocity {
@Override
public void run() {
if (getConfig().getGlobalDataEnabled()) {
if (getGlobalDataHandler().isTimeChangedHappened()) {
getGlobalDataHandler().checkForFinishedTimeChanges();
}
}
debug("Checking offline votes for " + p.getUsername() + "/"
+ p.getUniqueId().toString());
checkCachedVotes(server);
@@ -670,6 +699,7 @@ public class VotingPluginVelocity {
checkVoteCacheTime();
}
if (!config.getGlobalDataEnabled()) {
getLogger().warn("Global data not enabled, ignoring time change event");
return;
}
for (RegisteredServer s : getAvailableAllServers()) {
@@ -831,6 +861,7 @@ public class VotingPluginVelocity {
voteCacheFile.save();
}
bungeeTimeChecker.setTimeChangeFailSafeBypass(config.getTimeChangeFailSafeBypass());
bungeeTimeChecker.loadTimer();
try {
@@ -857,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();
@@ -988,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(),
@@ -1422,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 {
@@ -1429,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
@@ -1498,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());
@@ -1517,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)));
@@ -1528,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") {
@@ -97,12 +97,12 @@ public class VoteToday extends GUIHandler {
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
ItemBuilder item = null;
if (plugin.getGui().isChestVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
item = new ItemBuilder(user.getPlayerHead(plugin.getConfigFile().isForceLoadSkulls()));
item = new ItemBuilder(user.getPlayerHead());
} 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);
@@ -104,8 +104,7 @@ public class VoteTopVoter extends GUIHandler {
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(
entry.getKey().getPlayerHead(plugin.getConfigFile().isForceLoadSkulls()));
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
} else {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
@@ -60,7 +60,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
ItemBuilder playerItem;
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead(plugin.getConfigFile().isForceLoadSkulls()));
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
} else {
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
}
@@ -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);
}
}
@@ -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;
@@ -47,10 +47,6 @@ public class Config extends YMLFile {
@Getter
private boolean perSiteCoolDownEvents = false;
@ConfigDataBoolean(path = "ForceLoadSkulls")
@Getter
private boolean forceLoadSkulls = false;
@ConfigDataInt(path = "LimitVotePoints")
@Getter
private int limitVotePoints = -1;
@@ -667,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;
@@ -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
@@ -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) {
@@ -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;
@@ -28,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;
@@ -85,11 +87,106 @@ public class TopVoterHandler implements Listener {
return place;
}
public void loadPreviousMonthTopVoters() {
if (plugin.getConfigFile().isStoreMonthTotalsWithDate()) {
LocalDateTime now = plugin.getTimeChecker().getTime();
for (String column : plugin.getUserManager().getAllColumns()) {
if (column.startsWith("MonthTotal-")) {
String[] data = column.split("-");
if (data.length > 2) {
String year = data[2];
String month = data[1];
if (MessageAPI.isInt(year)) {
YearMonth yearMonth = YearMonth.of(Integer.parseInt(year), Month.valueOf(month));
if (yearMonth.atDay(now.getDayOfMonth()).atTime(23, 59).isBefore(now)) {
plugin.debug("Loading previous month top voters of " + yearMonth.toString());
plugin.getPreviousMonthsTopVoters().put(yearMonth,
new LinkedHashMap<TopVoterPlayer, Integer>());
}
}
}
}
}
if (plugin.getPreviousMonthsTopVoters().size() > 0) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
for (YearMonth month : plugin.getPreviousMonthsTopVoters().keySet()) {
LocalDateTime atTime = month.atDay(15).atTime(0, 0);
int total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
plugin.getPreviousMonthsTopVoters().get(month).put(user.getTopVoterPlayer(), total);
}
}
cols.put(playerData.getKey(), null);
user.clearTempCache();
}
}
cols.clear();
cols = null;
}
for (YearMonth month : plugin.getPreviousMonthsTopVoters().keySet()) {
plugin.getPreviousMonthsTopVoters().put(month,
sortByValues(plugin.getPreviousMonthsTopVoters().get(month), false));
}
plugin.extraDebug("Previous Months: " + plugin.getPreviousMonthsTopVoters().keySet().toString());
for (Entry<YearMonth, LinkedHashMap<TopVoterPlayer, Integer>> entry : plugin.getPreviousMonthsTopVoters()
.entrySet()) {
for (Entry<TopVoterPlayer, Integer> entry2 : entry.getValue().entrySet()) {
plugin.extraDebug(entry.getKey().toString() + ": " + entry2.getKey().getUser().getPlayerName() + ":"
+ entry2.getValue().intValue());
}
}
}
}
public LinkedHashMap<TopVoterPlayer, Integer> getTopVotersOfMonth(YearMonth month,
HashMap<UUID, ArrayList<Column>> cols) {
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
LocalDateTime atTime = month.atDay(15).atTime(0, 0);
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
int total = 0;
total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
totals.put(user.getTopVoterPlayer(), total);
}
user.clearTempCache();
}
}
return sortByValues(totals, false);
}
public void loadLastMonth() {
if (plugin.getGui().isLastMonthGUI()) {
plugin.getLastMonthTopVoter().clear();
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
LocalDateTime lastMonthTime = plugin.getTimeChecker().getTime().minusMonths(1);
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
@@ -100,7 +197,12 @@ public class TopVoterHandler implements Listener {
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
int total = user.getLastMonthTotal();
int total = 0;
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
total = user.getTotal(TopVoter.Monthly, lastMonthTime);
} else {
total = user.getLastMonthTotal();
}
if (total > 0) {
totals.put(user.getTopVoterPlayer(), total);
}
@@ -238,6 +340,7 @@ public class TopVoterHandler implements Listener {
plugin.getUserManager().copyColumnData(TopVoter.Monthly.getColumnName(),
TopVoter.Monthly.getLastColumnName());
}
LocalDateTime lastMonthTime = plugin.getTimeChecker().getTime().minusMonths(1);
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
@@ -247,13 +350,13 @@ public class TopVoterHandler implements Listener {
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
if (plugin.getConfigFile().isUseVoteStreaks()) {
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
if (user.getTotal(TopVoter.Monthly, lastMonthTime) == 0 && user.getMonthVoteStreak() != 0) {
user.setMonthVoteStreak(0);
} else {
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|| user.hasPercentageTotal(TopVoter.Monthly,
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
LocalDateTime.now().minusDays(1))) {
lastMonthTime)) {
user.addMonthVoteStreak();
plugin.getSpecialRewards().checkVoteStreak(user, "Month",
plugin.getBungeeSettings().isUseBungeecoord());
@@ -265,8 +368,8 @@ public class TopVoterHandler implements Listener {
// user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
if (plugin.getConfigFile().isUseHighestTotals()) {
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly, lastMonthTime)) {
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly, lastMonthTime));
}
}
user.clearTempCache();
@@ -283,10 +386,17 @@ public class TopVoterHandler implements Listener {
int i = 0;
int lastTotal = -1;
@SuppressWarnings("unchecked")
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
LinkedHashMap<TopVoterPlayer, Integer> topVoters = null;
if (plugin.getConfigFile().isUseMonthDateTotalsAsPrimaryTotal()) {
topVoters = getMonthlyTopVotersAtTime(lastMonthTime);
} else {
@SuppressWarnings("unchecked")
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
.getTopVoter(TopVoter.Monthly).clone();
topVoters = clone;
}
for (Entry<TopVoterPlayer, Integer> entry : topVoters.entrySet()) {
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
if (entry.getValue().intValue() != lastTotal) {
i++;
@@ -813,6 +923,37 @@ public class TopVoterHandler implements Listener {
return ArrayUtils.convert(msg);
}
public LinkedHashMap<TopVoterPlayer, Integer> getMonthlyTopVotersAtTime(LocalDateTime atTime) {
// int limitSize = plugin.getConfigFile().getMaxiumNumberOfTopVotersToLoad();
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
LinkedHashMap<TopVoterPlayer, Integer> topVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
String uuid = playerData.getKey().toString();
if (plugin != null && plugin.isEnabled()) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.updateTempCacheWithColumns(playerData.getValue());
cols.put(playerData.getKey(), null);
int total = user.getTotal(TopVoter.Monthly, atTime);
if (total > 0) {
topVoter.put(user.getTopVoterPlayer(), total);
}
}
}
}
return sortByValues(topVoter, false);
}
public synchronized void updateTopVoters(
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter) {
@@ -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;
@@ -29,8 +28,8 @@ public class TopVoterPlayer {
this.lastVoteTime = lastVoteTime;
}
public ItemStack getPlayerHead(boolean force) {
return PlayerManager.getInstance().getPlayerSkull(getPlayerName(), force);
public ItemStack getPlayerHead() {
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);
}
@@ -349,20 +353,19 @@ public class VoteParty implements Listener {
if (!user.isVanished()) {
int neededVotes = getNeededVotes();
for (String str : plugin.getSpecialRewardsConfig().getVotePartyVoteReminderAtVotes()) {
if (MessageAPI.isInt(str)) {
int num = Integer.parseInt(str);
if (neededVotes == num) {
String broadcastMessage = plugin.getSpecialRewardsConfig().getVotePartyVoteReminderBroadcast();
HashMap<String, String> placeholders = new HashMap<String, String>();
placeholders.put("player", user.getPlayerName());
placeholders.put("votesrequired", "" + neededVotes);
MiscUtils.getInstance()
.broadcast(PlaceholderUtils.replacePlaceHolder(broadcastMessage, placeholders));
}
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>();
placeholders.put("player", user.getPlayerName());
placeholders.put("votesrequired", "" + neededVotes);
MiscUtils.getInstance()
.broadcast(PlaceholderUtils.replacePlaceHolder(broadcastMessage, placeholders));
}
}
}
}
public synchronized void vote(VotingPluginUser user, boolean realVote, boolean forceBungee) {