mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 17:10:03 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8060f594c3 | ||
|
|
39aa7062a5 | ||
|
|
7ff7fbb7cb | ||
|
|
231817314b | ||
|
|
a20f10d978 | ||
|
|
997beaae28 | ||
|
|
9acc5861b7 | ||
|
|
f299847d46 | ||
|
|
87ff48366c | ||
|
|
3dde76dcde | ||
|
|
237713a799 | ||
|
|
23141d4ec1 | ||
|
|
2cfbaf4de8 | ||
|
|
c31b83fcd3 | ||
|
|
4cfd887c33 | ||
|
|
f04930e437 | ||
|
|
c45e8356bb | ||
|
|
2f78b7784a | ||
|
|
911642f57f | ||
|
|
5e63c04f6c | ||
|
|
e368f30dd9 | ||
|
|
5d5e8b0d55 | ||
|
|
16e52a4fd7 | ||
|
|
331c8fedf5 | ||
|
|
c085d6823e | ||
|
|
47680b2646 | ||
|
|
60ed0ce73d | ||
|
|
e5ae3184e0 | ||
|
|
dca9c6fe18 | ||
|
|
083e90706f | ||
|
|
fed96bcda1 | ||
|
|
5bad8c8f98 | ||
|
|
e31326395c | ||
|
|
f5b2d27b9e | ||
|
|
42626e3789 | ||
|
|
b35ff9454d | ||
|
|
9ee1547691 | ||
|
|
cb1599fe56 | ||
|
|
59a206617c | ||
|
|
699d74ca3f | ||
|
|
ad6d411e64 | ||
|
|
1b430dc4b8 | ||
|
|
526dcc830e | ||
|
|
75aaae7016 | ||
|
|
89d3372701 | ||
|
|
209f1dbc25 | ||
|
|
bb67de8d0e | ||
|
|
b4d57c7eae | ||
|
|
2ac6609d8e | ||
|
|
9eec6525c0 | ||
|
|
858b8b7b3c | ||
|
|
0aaef50a82 | ||
|
|
365f06d2ed | ||
|
|
a1b7370da0 | ||
|
|
2f52576bc4 | ||
|
|
bac19aecb9 | ||
|
|
3ad6ce247d | ||
|
|
bb78792e27 | ||
|
|
726b116c20 | ||
|
|
f731f82b01 | ||
|
|
939c431bcf | ||
|
|
87ed9dfe39 | ||
|
|
eceacf607f | ||
|
|
8d6db5b94f | ||
|
|
700300a293 | ||
|
|
5e5e208de0 | ||
|
|
b48662acfe | ||
|
|
0aed3068db | ||
|
|
25a3ff904d | ||
|
|
bb7adc409a | ||
|
|
1b28966798 | ||
|
|
f5d34ad84a | ||
|
|
abd86834a6 | ||
|
|
c6647d7cc3 | ||
|
|
a3851f9bf2 | ||
|
|
a951aae0de | ||
|
|
826fc95131 | ||
|
|
dea13f6ff1 | ||
|
|
bab55de93b | ||
|
|
1c112688b1 | ||
|
|
bc0e82f68f | ||
|
|
a82397a67f | ||
|
|
b1ffce516c | ||
|
|
f48a008040 | ||
|
|
90c8255894 | ||
|
|
4001e865f5 | ||
|
|
77b7659cb6 | ||
|
|
bc073857f6 | ||
|
|
9c2a41c9b5 | ||
|
|
972f5350a1 | ||
|
|
66df9d85da | ||
|
|
4046dd9d7f | ||
|
|
d89aa6ccb2 | ||
|
|
813ffed723 | ||
|
|
c0bc1b2730 | ||
|
|
1217e63583 | ||
|
|
cd6ed92e4f | ||
|
|
07c9eda769 | ||
|
|
ef0f73ba32 | ||
|
|
10b0fd3b11 | ||
|
|
a4aa209aa7 | ||
|
|
70af742083 | ||
|
|
0463700037 | ||
|
|
69d9c09b06 | ||
|
|
4455cc96b9 | ||
|
|
0ee7c1f2e8 | ||
|
|
4b3cc8c8e0 | ||
|
|
c2fe26aaea | ||
|
|
2aa84c90e8 | ||
|
|
c8cace388e | ||
|
|
1da028476f | ||
|
|
c28bddd0ba | ||
|
|
1afd8253a5 | ||
|
|
a3a1b4604f | ||
|
|
3bd41af200 | ||
|
|
0042045d9b | ||
|
|
76d7579c7d | ||
|
|
f591b863f1 | ||
|
|
b43c4b89a8 | ||
|
|
bc49aae401 | ||
|
|
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 | ||
|
|
c2fa7c4f90 | ||
|
|
2b82b8db82 | ||
|
|
c130004201 | ||
|
|
4829c772cb | ||
|
|
e8bf487d74 | ||
|
|
f5e9a450f9 | ||
|
|
ebb44330fd |
No files matched your search
@@ -2,10 +2,6 @@
|
||||
Plugin on SpigotMC
|
||||
https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/BenCodez/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
|
||||
### Maven:
|
||||
|
||||
<repository>
|
||||
|
||||
@@ -6,3 +6,4 @@
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.factorypath
|
||||
/.apt_generated_tests/
|
||||
+240
-174
@@ -3,19 +3,22 @@
|
||||
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</version>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.18.5</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>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
</properties>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>Resources</directory>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
@@ -24,11 +27,12 @@
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>Resources</directory>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
<testSourceDirectory>src/test/java</testSourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
@@ -58,21 +62,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>
|
||||
@@ -87,7 +76,7 @@
|
||||
<configuration>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -106,8 +95,21 @@
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.tcoded.folialib</pattern>
|
||||
<shadedPattern>
|
||||
${project.groupId}.votingplugin.simpleapi.folialib</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.bencodez.simpleapi</pattern>
|
||||
<shadedPattern>
|
||||
@@ -180,31 +182,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>
|
||||
@@ -242,19 +219,19 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21-R0.1-SNAPSHOT</version>
|
||||
<version>1.21.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.34</version>
|
||||
<version>1.18.38</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.2</version>
|
||||
<version>1.21-R0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -272,13 +249,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>
|
||||
@@ -287,76 +264,56 @@
|
||||
<version>2.11.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>3.7.16</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>5.12.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>5.15.2</version>
|
||||
<scope>test</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>
|
||||
@@ -365,23 +322,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.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</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.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
@@ -411,9 +412,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>
|
||||
@@ -423,20 +421,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.7.0</version>
|
||||
<version>3.11.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -453,26 +456,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>
|
||||
@@ -485,10 +545,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.7.0</version>
|
||||
<version>3.11.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -506,7 +599,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<version>3.1.4</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
@@ -530,33 +623,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);
|
||||
}
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class NonVotedPlayersCache {
|
||||
private VotingPluginBungee bungee;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
|
||||
public NonVotedPlayersCache(VotingPluginBungee bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public void addPlayer(ProxiedPlayer proxiedPlayer) {
|
||||
if (!bungee.getMysql().containsKeyQuery(proxiedPlayer.getUniqueId().toString())) {
|
||||
addPlayer(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayer(String uuid, String playerName) {
|
||||
getData().set("NonVotedPlayers." + playerName + ".UUID", uuid);
|
||||
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
|
||||
save();
|
||||
}
|
||||
|
||||
public void addPlayerCheck(String uuid, String playerName) {
|
||||
if (!bungee.getMysql().containsKeyQuery(uuid)) {
|
||||
addPlayer(uuid, playerName);
|
||||
}
|
||||
}
|
||||
|
||||
public void check() {
|
||||
for (String player : getData().getSection("NonVotedPlayers").getKeys()) {
|
||||
long time = getData().getLong("NonVotedPlayers." + player + ".LastTime", 0);
|
||||
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
|
||||
remove(player);
|
||||
} else {
|
||||
String uuid = getData().getString("NonVotedPlayers." + player + ".UUID", "");
|
||||
if (!uuid.isEmpty()) {
|
||||
if (bungee.getMysql().containsKeyQuery(uuid)) {
|
||||
remove(player);
|
||||
}
|
||||
} else {
|
||||
remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File yamlFile = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String playerExists(String playerName) {
|
||||
if (getData().getSection("NonVotedPlayers").getKeys().contains(playerName)) {
|
||||
return getData().getString("NonVotedPlayers." + playerName + ".UUID", "");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void remove(String player) {
|
||||
bungee.debug("Removing nonvotedplayer: " + player);
|
||||
getData().set("NonVotedPlayers." + player, null);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class VoteCache {
|
||||
private VotingPluginBungee bungee;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
|
||||
public VoteCache(VotingPluginBungee bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getData().getInt("VoteParty.CurrentVotes", 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotes", 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
getData().set("VoteParty.CurrentVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
getData().set("VoteParty.IncreaseVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
getData().set("VoteParty.Cache." + server, amount);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getData().getInt("VoteParty.Cache." + server, 0);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
Configuration section = getData().getSection("VoteCache." + server + "." + num);
|
||||
section.set("Name", voteData.getPlayerName());
|
||||
section.set("Service", voteData.getService());
|
||||
section.set("UUID", voteData.getUuid());
|
||||
section.set("Time", voteData.getTime());
|
||||
section.set("Real", voteData.isRealVote());
|
||||
section.set("Text", voteData.getText());
|
||||
}
|
||||
|
||||
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
|
||||
Configuration section = getData().getSection("TimedVoteCache." + num);
|
||||
section.set("Name", voteTimedQueue.getName());
|
||||
section.set("Service", voteTimedQueue.getService());
|
||||
section.set("Time", voteTimedQueue.getTime());
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
Configuration section = getData().getSection("OnlineCache." + player + "." + num);
|
||||
section.set("Name", voteData.getPlayerName());
|
||||
section.set("Service", voteData.getService());
|
||||
section.set("UUID", voteData.getUuid());
|
||||
section.set("Time", voteData.getTime());
|
||||
section.set("Real", voteData.isRealVote());
|
||||
section.set("Text", voteData.getText());
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
getData().set("VoteCache", null);
|
||||
getData().set("OnlineCache", null);
|
||||
save();
|
||||
}
|
||||
|
||||
public Collection<String> getOnlineVotes(String name) {
|
||||
return getData().getSection("OnlineCache." + name).getKeys();
|
||||
}
|
||||
|
||||
public Configuration getOnlineVotes(String name, String num) {
|
||||
return getData().getSection("OnlineCache." + name + "." + num);
|
||||
}
|
||||
|
||||
public Collection<String> getPlayers() {
|
||||
return getData().getSection("OnlineCache").getKeys();
|
||||
}
|
||||
|
||||
public Collection<String> getServers() {
|
||||
return getData().getSection("VoteCache").getKeys();
|
||||
}
|
||||
|
||||
public Configuration getTimedVoteCache(String key) {
|
||||
return getData().getSection("TimedVoteCache." + key);
|
||||
}
|
||||
|
||||
public Collection<String> getTimedVoteCache() {
|
||||
return getData().getSection("TimedVoteCache").getKeys();
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getData().getSection("VoteCache." + server).getKeys();
|
||||
}
|
||||
|
||||
public Configuration getServerVotes(String server, String num) {
|
||||
return getData().getSection("VoteCache." + server + "." + num);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File yamlFile = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,115 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class VotingPluginBungeeCommand extends Command {
|
||||
private VotingPluginBungee bungee;
|
||||
|
||||
public VotingPluginBungeeCommand(VotingPluginBungee bungee) {
|
||||
super("votingpluginbungee", "votingplugin.admin");
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender.hasPermission("votingplugin.admin")) {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
bungee.reload(false);
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
bungee.reload(true);
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee with MySQL"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
bungee.vote(user, site, false, true, 0, null, null);
|
||||
sender.sendMessage(new TextComponent("Sending vote"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("forcetimechange")) {
|
||||
if (args.length >= 2) {
|
||||
bungee.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
|
||||
sender.sendMessage(new TextComponent("Triggering time change: " + args[1]));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"&aChecking status, waiting for response, check console, method: sockets"));
|
||||
bungee.status(sender);
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"&aChecking status, waiting for response, check console, method: plugin messaging"));
|
||||
bungee.status(sender);
|
||||
bungee.sendServerNameMessage();
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.REDIS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"&aChecking status, waiting for response, check console, method: redis"));
|
||||
bungee.status(sender);
|
||||
bungee.sendServerNameMessage();
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
new TextComponent("&aNot using socket/pluginmessage/redis method, command unavailable"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("multiproxystatus")) {
|
||||
bungee.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
|
||||
sender.sendMessage(new TextComponent("Sending status message"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
TextComponent[] msg = new TextComponent[7];
|
||||
msg[0] = new TextComponent("&avotingpluginbungee reload - Reload plugin");
|
||||
msg[1] = new TextComponent("&avotingpluginbungee reloadmysql - Reload plugin including mysql");
|
||||
msg[2] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
|
||||
msg[3] = new TextComponent("&avotingpluginbungee status - Check socket connection status");
|
||||
msg[4] = new TextComponent("&avotingpluginbungee forcetimechange (timetype) - Force a time change");
|
||||
msg[5] = new TextComponent("&avotingpluginbungee voteparty force - Force a vote party");
|
||||
msg[6] = new TextComponent(
|
||||
"&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes");
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("voteparty")) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("Force")) {
|
||||
bungee.setCurrentVotePartyVotes(bungee.getCurrentVotePartyVotesRequired());
|
||||
bungee.checkVoteParty();
|
||||
sender.sendMessage(new TextComponent("Vote party forced"));
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[1].equalsIgnoreCase("SetVoteCount")) {
|
||||
if (isInt(args[2])) {
|
||||
bungee.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
|
||||
sender.sendMessage(new TextComponent("Set current vote party votes to " + args[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!"));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
if (st == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
public class MultiProxyServerSocketConfigurationBungee implements MultiProxyServerSocketConfiguration {
|
||||
private String server;
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
public MultiProxyServerSocketConfigurationBungee(String s, Configuration config) {
|
||||
server = s;
|
||||
host = config.getString("Host", "");
|
||||
port = config.getInt("Port", 1234);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
||||
-1747
File diff suppressed because it is too large.
Load diff
-127
@@ -1,127 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
public VotingPluginVelocityCommand(VotingPluginVelocity plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Invocation invocation) {
|
||||
CommandSource source = invocation.source();
|
||||
// Get the arguments after the command alias
|
||||
String[] args = invocation.arguments();
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
plugin.reload(false);
|
||||
source.sendMessage(Component.text("Reloading VotingPluginBungee").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
plugin.reload(true);
|
||||
source.sendMessage(Component.text("Reloading VotingPluginBungee MySQL").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
plugin.vote(user, site, false, true, 0, null, null);
|
||||
source.sendMessage(Component.text("Sending vote").color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("forcetimechange")) {
|
||||
if (args.length >= 2) {
|
||||
plugin.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
|
||||
source.sendMessage(Component.text("Triggering time change: " + args[1]).color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (plugin.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
source.sendMessage(
|
||||
Component.text("Checking status, waiting for response, check console, method: sockets")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
} else if (plugin.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
source.sendMessage(Component
|
||||
.text("Checking status, waiting for response, check console, method: pluginmessaging")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
plugin.sendServerNameMessage();
|
||||
} else if (plugin.getMethod().equals(BungeeMethod.REDIS)) {
|
||||
source.sendMessage(
|
||||
Component.text("Checking status, waiting for response, check console, method: redis")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
plugin.sendServerNameMessage();
|
||||
} else {
|
||||
source.sendMessage(Component.text("Not using socket/pluginmessage method, command unavailable")
|
||||
.color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("multiproxystatus")) {
|
||||
plugin.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
|
||||
|
||||
source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
String[] msg = new String[7];
|
||||
msg[0] = "votingpluginbungee reload - Reload plugin";
|
||||
msg[1] = "votingpluginbungee reloadmysql - Reload plugin including mysql";
|
||||
msg[2] = "votingpluginbungee vote (player) (servicesite) - Send bungee vote";
|
||||
msg[3] = "votingpluginbungee status - Check socket connection status";
|
||||
msg[4] = "&avotingpluginbungee forcetimechange (timetype) - Force a time change";
|
||||
msg[5] = "&avotingpluginbungee voteparty force - Force a vote party";
|
||||
msg[6] = "&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes";
|
||||
for (String m : msg) {
|
||||
source.sendMessage(Component.text(m).color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("voteparty")) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("Force")) {
|
||||
plugin.setCurrentVotePartyVotes(plugin.getCurrentVotePartyVotesRequired());
|
||||
plugin.checkVoteParty();
|
||||
source.sendMessage(Component.text("Vote party forced").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[1].equalsIgnoreCase("SetVoteCount")) {
|
||||
if (isInt(args[2])) {
|
||||
plugin.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
|
||||
source.sendMessage(Component.text("Set current vote party votes to " + args[2])
|
||||
.color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
if (st == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Invocation invocation) {
|
||||
return invocation.source().hasPermission("votingpluginbungee.admin");
|
||||
}
|
||||
}
|
||||
+172
-156
@@ -15,28 +15,28 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigSpigot;
|
||||
import com.bencodez.advancedcore.bungeeapi.GlobalMessage.GlobalMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.GlobalMessage.GlobalMessageListener;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageListener;
|
||||
import com.bencodez.simpleapi.servercomm.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
|
||||
import com.bencodez.simpleapi.sql.data.DataValue;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueBoolean;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigSpigot;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeVersion;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -78,29 +78,6 @@ public class BungeeHandler implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
if (socketHandler != null) {
|
||||
socketHandler.closeConnection();
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* @EventHandler public void onDateChange(DateChangedEvent event) { if
|
||||
* (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
* plugin.getPluginMessaging().sendPluginMessage("timeupdate",
|
||||
* plugin.getServerDataFile().getPrevMonth() + "//" +
|
||||
* plugin.getServerDataFile().getPrevDay() + "//" +
|
||||
* plugin.getServerDataFile().getPrevWeekDay()); } }
|
||||
*/
|
||||
|
||||
public void checkGlobalData() {
|
||||
HashMap<String, DataValue> data = globalDataHandler.getExact(plugin.getBungeeSettings().getServer());
|
||||
// plugin.debug(data.toString());
|
||||
@@ -131,19 +108,21 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<>();
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(true));
|
||||
dataToSet.put("Processing", new DataValueBoolean(false));
|
||||
globalDataHandler.setData(plugin.getBungeeSettings().getServer(), dataToSet);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
/*
|
||||
* @EventHandler public void onDateChange(DateChangedEvent event) { if
|
||||
* (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
* plugin.getPluginMessaging().sendPluginMessage("timeupdate",
|
||||
* plugin.getServerDataFile().getPrevMonth() + "//" +
|
||||
* plugin.getServerDataFile().getPrevDay() + "//" +
|
||||
* plugin.getServerDataFile().getPrevWeekDay()); } }
|
||||
*/
|
||||
|
||||
public boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
|
||||
boolean isProcessing = false;
|
||||
@@ -167,101 +146,31 @@ 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;
|
||||
}
|
||||
|
||||
public void loadGlobalMysql() {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
if (timer != null) {
|
||||
timer.shutdown();
|
||||
try {
|
||||
timer.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
timer.shutdownNow();
|
||||
}
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkGlobalData();
|
||||
}
|
||||
}, 60, 10, TimeUnit.SECONDS);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
|
||||
}
|
||||
}, 1, 60, TimeUnit.MINUTES);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
|
||||
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
plugin.getTimeChecker().setProcessingEnabled(false);
|
||||
public void close() {
|
||||
if (socketHandler != null) {
|
||||
socketHandler.closeConnection();
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,12 +192,12 @@ public class BungeeHandler implements Listener {
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
sendData(ArrayUtils.convert(list));
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
redisHandler.sendMessage(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
|
||||
@@ -415,10 +324,6 @@ public class BungeeHandler implements Listener {
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
@@ -596,28 +501,28 @@ public class BungeeHandler implements Listener {
|
||||
});
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
redisHandler = new RedisHandler(plugin.getBungeeSettings().getRedisHost(),
|
||||
plugin.getBungeeSettings().getRedisPort(), plugin.getBungeeSettings().getRedisUsername(),
|
||||
plugin.getBungeeSettings().getRedisPassword()) {
|
||||
|
||||
@Override
|
||||
protected void onMessage(String channel, String[] message) {
|
||||
plugin.getLogger().info(channel + ArrayUtils.makeStringList(ArrayUtils.convert(message)));
|
||||
if (message.length > 0) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (int i = 1; i < message.length; i++) {
|
||||
list.add(message[i]);
|
||||
}
|
||||
globalMessageHandler.onMessage(message[0], list);
|
||||
public void debug(String message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
protected void onMessage(String channel, String[] message) {
|
||||
plugin.getLogger().info(channel + ArrayUtils.makeStringList(ArrayUtils.convert(message)));
|
||||
if (message.length > 0) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (int i = 1; i < message.length; i++) {
|
||||
list.add(message[i]);
|
||||
}
|
||||
globalMessageHandler.onMessage(message[0], list);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -635,8 +540,13 @@ public class BungeeHandler implements Listener {
|
||||
redisThread.start();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
if (plugin.getBungeeSettings().isPluginMessageEncryption()) {
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
plugin.getPluginMessaging().setEncryptionHandler(encryptionHandler);
|
||||
}
|
||||
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
|
||||
@@ -715,7 +625,8 @@ public class BungeeHandler implements Listener {
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
clientHandler = new ClientHandler(plugin.getBungeeSettings().getBungeeServerHost(),
|
||||
plugin.getBungeeSettings().getBungeeServerPort(), encryptionHandler,
|
||||
@@ -740,7 +651,8 @@ public class BungeeHandler implements Listener {
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
data[2]);
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
@@ -773,7 +685,8 @@ public class BungeeHandler implements Listener {
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
data[2]);
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
@@ -883,6 +796,109 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
}
|
||||
|
||||
public void loadGlobalMysql() {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
if (timer != null) {
|
||||
timer.shutdown();
|
||||
try {
|
||||
timer.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
timer.shutdownNow();
|
||||
}
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkGlobalData();
|
||||
}
|
||||
}, 60, 10, TimeUnit.SECONDS);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
|
||||
}
|
||||
}, 1, 60, TimeUnit.MINUTES);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
|
||||
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
plugin.getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
plugin.getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
plugin.getTimeChecker().setProcessingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendData(String... strings) {
|
||||
clientHandler.sendMessage(strings);
|
||||
}
|
||||
File renamed without changes.
+143
-134
@@ -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.sql.Column;
|
||||
import com.bencodez.simpleapi.updater.Updater;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
import com.bencodez.votingplugin.commands.CommandLoader;
|
||||
@@ -116,7 +117,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
private ArrayList<CommandHandler> adminVoteCommand;
|
||||
|
||||
@Getter
|
||||
private LinkedHashMap<java.util.UUID, ArrayList<String>> advancedTab = new LinkedHashMap<java.util.UUID, ArrayList<String>>();
|
||||
private LinkedHashMap<java.util.UUID, ArrayList<String>> advancedTab = new LinkedHashMap<>();
|
||||
|
||||
@Getter
|
||||
private BroadcastHandler broadcastHandler;
|
||||
@@ -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;
|
||||
|
||||
@@ -231,6 +236,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Getter
|
||||
private UserManager votingPluginUserManager;
|
||||
|
||||
@Getter
|
||||
private TimeQueueHandler timeQueueHandler;
|
||||
|
||||
@Getter
|
||||
private ServiceSiteHandler serviceSiteHandler;
|
||||
|
||||
@Getter
|
||||
private long lastBackgroundTaskTimeTaken = -1;
|
||||
|
||||
private boolean firstTimeLoaded = false;
|
||||
|
||||
public void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
|
||||
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
|
||||
}
|
||||
@@ -244,6 +260,26 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkFirstTimeLoaded() {
|
||||
if (!firstTimeLoaded) {
|
||||
|
||||
if (getGui().isChestVoteTopUseSkull()) {
|
||||
int maxToLoad = 200;
|
||||
for (TopVoter top : topVoter.keySet()) {
|
||||
int num = 1;
|
||||
Set<TopVoterPlayer> players = topVoter.get(top).keySet();
|
||||
for (TopVoterPlayer p : players) {
|
||||
if (num <= maxToLoad) {
|
||||
getSkullCacheHandler().addToCache(p.getUuid(), p.getPlayerName());
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
firstTimeLoaded = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check votifier.
|
||||
*/
|
||||
@@ -281,7 +317,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
public ArrayList<TopVoterPlayer> convertSet(Set<TopVoterPlayer> set) {
|
||||
return new ArrayList<TopVoterPlayer>(set);
|
||||
return new ArrayList<>(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -292,7 +328,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
public LinkedHashMap<TopVoterPlayer, Integer> getTopVoter(TopVoter top) {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> top1 = topVoter.get(top);
|
||||
if (top1 == null) {
|
||||
top1 = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
top1 = new LinkedHashMap<>();
|
||||
}
|
||||
return top1;
|
||||
}
|
||||
@@ -303,6 +339,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
* @param uuid the uuid
|
||||
* @return the user
|
||||
*/
|
||||
@Deprecated
|
||||
public VotingPluginUser getUser(UUID uuid) {
|
||||
return getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
}
|
||||
@@ -350,16 +387,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<VoteSite> getVoteSitesEnabled() {
|
||||
ArrayList<VoteSite> sites = new ArrayList<VoteSite>();
|
||||
for (VoteSite site : getVoteSites()) {
|
||||
if (site.isEnabled()) {
|
||||
sites.add(site);
|
||||
}
|
||||
}
|
||||
return sites;
|
||||
}
|
||||
|
||||
public String getVoteSiteName(boolean checkEnabled, String... urls) {
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(checkEnabled);
|
||||
|
||||
@@ -392,6 +419,16 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<VoteSite> getVoteSitesEnabled() {
|
||||
ArrayList<VoteSite> sites = new ArrayList<>();
|
||||
for (VoteSite site : getVoteSites()) {
|
||||
if (site.isEnabled()) {
|
||||
sites.add(site);
|
||||
}
|
||||
}
|
||||
return sites;
|
||||
}
|
||||
|
||||
public String getVoteSiteServiceSite(String name) {
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(true);
|
||||
if (name == null) {
|
||||
@@ -401,10 +438,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
for (String siteName : sites) {
|
||||
String URL = getConfigVoteSites().getServiceSite(siteName);
|
||||
if (URL != null) {
|
||||
if (URL.equalsIgnoreCase(name)) {
|
||||
return URL;
|
||||
}
|
||||
if (name.equalsIgnoreCase(siteName)) {
|
||||
if (URL.equalsIgnoreCase(name) || name.equalsIgnoreCase(siteName)) {
|
||||
return URL;
|
||||
}
|
||||
}
|
||||
@@ -433,6 +467,15 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void loadBungeeHandler() {
|
||||
bungeeHandler = new BungeeHandler(this);
|
||||
bungeeHandler.load();
|
||||
|
||||
if (getOptions().getServer().equalsIgnoreCase("PleaseSet")) {
|
||||
getLogger().warning("Bungeecoord is true and server name is not set, bungeecoord features may not work");
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDirectlyDefined() {
|
||||
getRewardHandler().getDirectlyDefinedRewards().clear();
|
||||
// AllSites reward
|
||||
@@ -1010,6 +1053,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
private void loadVoteTimer() {
|
||||
voteTimer = Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Log vote.
|
||||
*
|
||||
@@ -1032,22 +1079,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
new VotingPluginMetrics().load(plugin);
|
||||
}
|
||||
|
||||
private void loadVoteTimer() {
|
||||
voteTimer = Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
|
||||
@Getter
|
||||
private TimeQueueHandler timeQueueHandler;
|
||||
|
||||
private void loadBungeeHandler() {
|
||||
bungeeHandler = new BungeeHandler(this);
|
||||
bungeeHandler.load();
|
||||
|
||||
if (getOptions().getServer().equalsIgnoreCase("PleaseSet")) {
|
||||
getLogger().warning("Bungeecoord is true and server name is not set, bungeecoord features may not work");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostLoad() {
|
||||
// auto conversion for Shop.yml
|
||||
@@ -1064,6 +1095,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
loadVersionFile();
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
|
||||
// only purges if enabled in config
|
||||
getVotingPluginUserManager().purgeOldPlayersNoData();
|
||||
|
||||
voteTester = new VoteTester(plugin);
|
||||
|
||||
loadVoteTimer();
|
||||
@@ -1107,20 +1141,23 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
});
|
||||
|
||||
topVoterHandler = new TopVoterHandler(this);
|
||||
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
lastMonthTopVoter = new LinkedHashMap<>();
|
||||
previousMonthsTopVoters = new LinkedHashMap<>();
|
||||
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>>();
|
||||
topVoter = new LinkedHashMap<>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
topVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
|
||||
topVoter.put(top, new LinkedHashMap<>());
|
||||
}
|
||||
voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
|
||||
voteToday = new LinkedHashMap<>();
|
||||
voteLog = new Logger(plugin, new File(plugin.getDataFolder() + File.separator + "Log", "votelog.txt"));
|
||||
|
||||
new AdminGUI(this).loadHook();
|
||||
@@ -1288,7 +1325,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
if (getProfile().contains("dev")) {
|
||||
if (plugin.getDescription().getVersion().contains("SNAPSHOT")) {
|
||||
plugin.getLogger().info(
|
||||
"Using dev build, this is not a stable build, use at your own risk. Build number: " + buildNumber);
|
||||
}
|
||||
@@ -1339,9 +1376,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ServiceSiteHandler serviceSiteHandler;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
@@ -1359,9 +1393,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
if (!configFile.isOverrideVersionDisable()) {
|
||||
Bukkit.getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
} else {
|
||||
plugin.getLogger().warning("Overriding version disable, beware of using this! This may cause issues!");
|
||||
}
|
||||
plugin.getLogger().warning("Overriding version disable, beware of using this! This may cause issues!");
|
||||
}
|
||||
|
||||
setupFiles();
|
||||
@@ -1495,8 +1528,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 +1549,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
broadcastHandler.schedule(getConfigFile().getFormatAlternateBroadcastDelay());
|
||||
}
|
||||
|
||||
updateAdvancedCoreHook();
|
||||
plugin.loadVoteSites();
|
||||
|
||||
reloadAdvancedCore(userStorage);
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
@@ -1567,9 +1602,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Loaded Files");
|
||||
}
|
||||
|
||||
@Getter
|
||||
private long lastBackgroundTaskTimeTaken = -1;
|
||||
|
||||
public void update() {
|
||||
if (update || configFile.isAlwaysUpdate()) {
|
||||
if (!updateStarted && plugin != null) {
|
||||
@@ -1580,6 +1612,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());
|
||||
@@ -1588,17 +1621,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
|
||||
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
|
||||
LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday = new LinkedHashMap<>();
|
||||
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter = new LinkedHashMap<>();
|
||||
|
||||
ArrayList<TopVoter> topVotersToCheck = new ArrayList<TopVoter>();
|
||||
ArrayList<TopVoter> topVotersToCheck = new ArrayList<>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (plugin == null) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getConfigFile().getLoadTopVoter(top)) {
|
||||
topVotersToCheck.add(top);
|
||||
tempTopVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
|
||||
tempTopVoter.put(top, new LinkedHashMap<>());
|
||||
}
|
||||
}
|
||||
boolean topVoterIgnorePermissionUse = plugin.getConfigFile()
|
||||
@@ -1615,61 +1648,59 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
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 = getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils
|
||||
.getInstance().getYearFromMili(time))) {
|
||||
|
||||
times.put(entry.getKey(),
|
||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(time),
|
||||
ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
if (plugin != null) {
|
||||
if (!plugin.getPlaceholders().getCacheLevel().onlineOnly()
|
||||
|| user.isOnline()) {
|
||||
plugin.getPlaceholders().onUpdate(user, false);
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
} else {
|
||||
if ((plugin == null) || !plugin.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance()
|
||||
.getYearFromMili(time))) {
|
||||
|
||||
times.put(entry.getKey(), LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
if (plugin != null) {
|
||||
if (!plugin.getPlaceholders().getCacheLevel().onlineOnly()
|
||||
|| user.isOnline()) {
|
||||
plugin.getPlaceholders().onUpdate(user, false);
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
@@ -1711,36 +1742,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean firstTimeLoaded = false;
|
||||
|
||||
public void checkFirstTimeLoaded() {
|
||||
if (!firstTimeLoaded) {
|
||||
|
||||
if (getGui().isChestVoteTopUseSkull()) {
|
||||
int maxToLoad = 200;
|
||||
for (TopVoter top : topVoter.keySet()) {
|
||||
int num = 1;
|
||||
Set<TopVoterPlayer> players = topVoter.get(top).keySet();
|
||||
for (TopVoterPlayer p : players) {
|
||||
if (num <= maxToLoad) {
|
||||
SkullHandler.getInstance().loadSkull(p.getPlayerName());
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
firstTimeLoaded = true;
|
||||
}
|
||||
|
||||
public void updateAdvancedCoreHook() {
|
||||
getJavascriptEngine().put("VotingPlugin", this);
|
||||
allowDownloadingFromSpigot(15358);
|
||||
setConfigData(new YMLConfig(this, configFile.getData()) {
|
||||
|
||||
@Override
|
||||
public void setValue(String path, Object value) {
|
||||
configFile.setValue(path, value);
|
||||
public void createSection(String key) {
|
||||
configFile.createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1749,8 +1758,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
configFile.createSection(key);
|
||||
public void setValue(String path, Object value) {
|
||||
configFile.setValue(path, value);
|
||||
}
|
||||
});
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
+22
-28
@@ -16,9 +16,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite", new Callable<String>() {
|
||||
@@ -28,9 +27,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites", new Callable<String>() {
|
||||
@@ -40,9 +38,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative", new Callable<String>() {
|
||||
@@ -51,14 +48,13 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
for (String cum : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(Integer.parseInt(cum))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
for (String cum : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(Integer.parseInt(cum))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty", new Callable<String>() {
|
||||
@@ -67,9 +63,8 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
return "False";
|
||||
} else {
|
||||
return "True";
|
||||
}
|
||||
return "True";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("placeholder_cache_level", new Callable<String>() {
|
||||
@@ -85,14 +80,13 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
for (String milestone : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(Integer.parseInt(milestone))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
for (String milestone : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(Integer.parseInt(milestone))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward", new Callable<String>() {
|
||||
@@ -102,9 +96,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday", new Callable<String>() {
|
||||
@@ -186,9 +179,11 @@ public class VotingPluginMetrics {
|
||||
int total = plugin.getUserManager().getAllUUIDs().size();
|
||||
if (total > 800000) {
|
||||
return ">800000";
|
||||
} else if (total > 700000) {
|
||||
}
|
||||
if (total > 700000) {
|
||||
return "700000-800000";
|
||||
} else if (total > 600000) {
|
||||
}
|
||||
if (total > 600000) {
|
||||
return "600000-700000";
|
||||
} else if (total > 500000) {
|
||||
return "500000-600000";
|
||||
@@ -255,9 +250,8 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "" + plugin.getBungeeHandler().getMethod().toString();
|
||||
} else {
|
||||
return "Disabled";
|
||||
}
|
||||
return "Disabled";
|
||||
}
|
||||
}));
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
+3
-3
@@ -18,7 +18,7 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
public class BroadcastHandler {
|
||||
private VotingPluginMain plugin;
|
||||
private ScheduledExecutorService timer;
|
||||
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<String>();
|
||||
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public BroadcastHandler(VotingPluginMain plugin, int delay) {
|
||||
this.plugin = plugin;
|
||||
@@ -39,11 +39,11 @@ public class BroadcastHandler {
|
||||
playersText += ", ";
|
||||
}
|
||||
}
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("numberofplayers", "" + size);
|
||||
placeholders.put("players", playersText);
|
||||
bc = PlaceholderUtils.replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
+174
-120
@@ -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;
|
||||
@@ -33,19 +31,18 @@ import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerManager;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
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.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;
|
||||
import com.bencodez.simpleapi.command.TabCompleteHandler;
|
||||
import com.bencodez.simpleapi.debug.DebugLevel;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.simpleapi.updater.Updater;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.executers.CommandAliases;
|
||||
@@ -54,6 +51,7 @@ import com.bencodez.votingplugin.commands.gui.admin.AdminVoteHelp;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVotePerms;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholders;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholdersPlayer;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteTopPoints;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVotePlayer;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative;
|
||||
@@ -69,6 +67,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;
|
||||
@@ -102,32 +101,6 @@ public class CommandLoader {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void processSlotClick(Player player, VotingPluginUser user, String slot) {
|
||||
if (MessageAPI.startsWithIgnoreCase(slot, "url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the adminPerm
|
||||
*/
|
||||
@@ -235,8 +208,6 @@ public class CommandLoader {
|
||||
if (handle.hasPerm(player)) {
|
||||
// plugin.debug("has perm");
|
||||
return true;
|
||||
} else {
|
||||
// plugin.debug("no perm " + cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,8 +219,6 @@ public class CommandLoader {
|
||||
if (handle.hasPerm(player)) {
|
||||
// plugin.debug("has perm");
|
||||
return true;
|
||||
} else {
|
||||
// plugin.debug("no perm " + cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,7 +242,7 @@ public class CommandLoader {
|
||||
* Load admin vote command.
|
||||
*/
|
||||
private void loadAdminVoteCommand() {
|
||||
plugin.setAdminVoteCommand(new ArrayList<CommandHandler>());
|
||||
plugin.setAdminVoteCommand(new ArrayList<>());
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "CurrentPluginTime" },
|
||||
"VotingPlugin.Commands.AdminVote.CurrentPluginTime|" + adminPerm, "Current plugin time") {
|
||||
@@ -289,13 +258,6 @@ public class CommandLoader {
|
||||
.add(new PlayerCommandHandler(plugin, new String[] { "User", "(player)", "SetPoints", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetPoints|" + adminPerm, "Set players voting points") {
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.setPoints(Integer.parseInt(args[3]));
|
||||
sender.sendMessage(MessageAPI.colorize("&cSet " + args[1] + " points to " + args[3]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeAll(CommandSender sender, String[] args) {
|
||||
int num = Integer.parseInt(args[3]);
|
||||
@@ -311,6 +273,13 @@ public class CommandLoader {
|
||||
}
|
||||
sender.sendMessage(MessageAPI.colorize("&cDone setting all players points to " + args[3]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.setPoints(Integer.parseInt(args[3]));
|
||||
sender.sendMessage(MessageAPI.colorize("&cSet " + args[1] + " points to " + args[3]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
@@ -327,6 +296,18 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "TopPoints" },
|
||||
"VotingPlugin.Commands.AdminVote.TopPoints|" + adminPerm, "Open the top points GUI", false) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cLoading top points, please wait...");
|
||||
|
||||
new AdminVoteTopPoints(plugin, sender,
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender), 1).open();
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "PauseRewards" },
|
||||
"VotingPlugin.Commands.AdminVote.PauseRewards|" + adminPerm, "Pause rewards globally") {
|
||||
|
||||
@@ -385,7 +366,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting...");
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
ArrayList<Integer> nums = new ArrayList<>();
|
||||
|
||||
for (String str : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
try {
|
||||
@@ -473,18 +454,6 @@ public class CommandLoader {
|
||||
.add(new PlayerCommandHandler(plugin, new String[] { "User", "(player)", "AddPoints", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.AddPoints|" + adminPerm, "Add to players voting points") {
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
synchronized (pointLock) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.cache();
|
||||
int newTotal = 0;
|
||||
newTotal = user.addPoints(Integer.parseInt(args[3]));
|
||||
sender.sendMessage(MessageAPI.colorize("&cGave " + args[1] + " " + args[3] + " points"
|
||||
+ ", " + args[1] + " now has " + newTotal + " points"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeAll(CommandSender sender, String[] args) {
|
||||
int num = Integer.parseInt(args[3]);
|
||||
@@ -501,6 +470,18 @@ public class CommandLoader {
|
||||
}
|
||||
sender.sendMessage(MessageAPI.colorize("&cGave " + "all players" + " " + args[3] + " points"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
synchronized (pointLock) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.cache();
|
||||
int newTotal = 0;
|
||||
newTotal = user.addPoints(Integer.parseInt(args[3]));
|
||||
sender.sendMessage(MessageAPI.colorize("&cGave " + args[1] + " " + args[3] + " points"
|
||||
+ ", " + args[1] + " now has " + newTotal + " points"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
@@ -726,6 +707,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 +735,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 +776,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 +851,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 +860,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") {
|
||||
|
||||
@@ -1009,15 +1016,6 @@ public class CommandLoader {
|
||||
new String[] { "User", "(player)", "AddMilestoneCount", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.AddMilestoneCount|" + adminPerm, "Add milestonecount") {
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.setMilestoneCount(user.getMilestoneCount() + Integer.parseInt(args[3]));
|
||||
plugin.getSpecialRewards().checkMilestone(user, null,
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
sender.sendMessage(MessageAPI.colorize("&cAdded milestonecount for " + args[1]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeAll(CommandSender sender, String[] args) {
|
||||
int toAdd = Integer.parseInt(args[3]);
|
||||
@@ -1033,6 +1031,15 @@ public class CommandLoader {
|
||||
}
|
||||
sender.sendMessage(MessageAPI.colorize("&cFinished adding milestonecount for all players"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.setMilestoneCount(user.getMilestoneCount() + Integer.parseInt(args[3]));
|
||||
plugin.getSpecialRewards().checkMilestone(user, null,
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
sender.sendMessage(MessageAPI.colorize("&cAdded milestonecount for " + args[1]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
@@ -1053,13 +1060,6 @@ public class CommandLoader {
|
||||
"VotingPlugin.Commands.AdminVote.ClearGottenMilestones|" + adminPerm,
|
||||
"Clears received milestones") {
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.setHasGottenMilestone(new HashMap<String, Boolean>());
|
||||
sender.sendMessage(MessageAPI.colorize("&cClearing gotten milestones for " + args[1]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeAll(CommandSender sender, String[] args) {
|
||||
String path = "GottenMileStones";
|
||||
@@ -1069,11 +1069,18 @@ public class CommandLoader {
|
||||
sender.sendMessage(MessageAPI.colorize("&cClearing gotten milestones for all players..."));
|
||||
plugin.getUserManager().removeAllKeyValues(path, DataType.STRING);
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
plugin.getUserManager().getDataManager().cacheUser(p.getUniqueId());
|
||||
plugin.getUserManager().getDataManager().cacheUser(p.getUniqueId(), p.getName());
|
||||
}
|
||||
sender.sendMessage(
|
||||
MessageAPI.colorize("&cFinished clearing gotten milestones for all players"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeSinglePlayer(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(args[1]);
|
||||
user.setHasGottenMilestone(new HashMap<>());
|
||||
sender.sendMessage(MessageAPI.colorize("&cClearing gotten milestones for " + args[1]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "Vote", "(player)", "All" },
|
||||
@@ -1090,7 +1097,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 +1124,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 +1158,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 +1213,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 +1238,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 +1306,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 +1667,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 +1751,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,
|
||||
@@ -1798,8 +1813,7 @@ public class CommandLoader {
|
||||
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager()
|
||||
.getAllKeys(UserStorage.value(args[1]));
|
||||
Queue<Entry<UUID, ArrayList<Column>>> players = new LinkedList<Entry<UUID, ArrayList<Column>>>(
|
||||
cols.entrySet());
|
||||
Queue<Entry<UUID, ArrayList<Column>>> players = new LinkedList<>(cols.entrySet());
|
||||
ArrayList<String> uuids = plugin.getUserManager().getAllUUIDs();
|
||||
|
||||
while (players.size() > 0) {
|
||||
@@ -1850,7 +1864,7 @@ public class CommandLoader {
|
||||
* Load aliases.
|
||||
*/
|
||||
public void loadAliases() {
|
||||
commands = new HashMap<String, CommandHandler>();
|
||||
commands = new HashMap<>();
|
||||
if (!plugin.getConfigFile().isLoadCommandAliases()) {
|
||||
return;
|
||||
}
|
||||
@@ -1965,7 +1979,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
ArrayList<String> voteSites = new ArrayList<String>();
|
||||
ArrayList<String> voteSites = new ArrayList<>();
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
voteSites.add(voteSite.getKey());
|
||||
}
|
||||
@@ -2058,7 +2072,7 @@ public class CommandLoader {
|
||||
* Load tab complete.
|
||||
*/
|
||||
public void loadTabComplete() {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
ArrayList<String> sites = new ArrayList<>();
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
sites.add(site.getKey());
|
||||
}
|
||||
@@ -2067,7 +2081,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
ArrayList<String> sites = new ArrayList<>();
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
sites.add(site.getKey());
|
||||
}
|
||||
@@ -2079,7 +2093,7 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<String> topVoter = new ArrayList<String>();
|
||||
ArrayList<String> topVoter = new ArrayList<>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
topVoter.add(top.toString());
|
||||
}
|
||||
@@ -2088,7 +2102,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
ArrayList<String> topVoter = new ArrayList<String>();
|
||||
ArrayList<String> topVoter = new ArrayList<>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
topVoter.add(top.toString());
|
||||
}
|
||||
@@ -2105,7 +2119,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
ArrayList<String> sites = new ArrayList<>();
|
||||
for (String str : plugin.getShopFile().getShopIdentifiers()) {
|
||||
sites.add(str);
|
||||
}
|
||||
@@ -2122,7 +2136,7 @@ public class CommandLoader {
|
||||
* Load vote command.
|
||||
*/
|
||||
private void loadVoteCommand() {
|
||||
plugin.setVoteCommand(new ArrayList<CommandHandler>());
|
||||
plugin.setVoteCommand(new ArrayList<>());
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()) {
|
||||
plugin.getVoteCommand().add(new CommandHandler(plugin, new String[] { "SetPrimaryAccount", "(player)" },
|
||||
"VotingPlugin.Commands.Vote.SetPrimaryAccount|" + modPerm, "Set primary account", false) {
|
||||
@@ -2245,13 +2259,13 @@ public class CommandLoader {
|
||||
if (identifier != null) {
|
||||
|
||||
if (limitPass) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points, true)) {
|
||||
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
|
||||
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
@@ -2445,6 +2459,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") {
|
||||
|
||||
@@ -2532,7 +2561,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
int daily = 0;
|
||||
int weekly = 0;
|
||||
@@ -2677,7 +2706,7 @@ public class CommandLoader {
|
||||
if (cPlayer.getPoints() >= pointsToGive) {
|
||||
user.addPoints(pointsToGive);
|
||||
cPlayer.removePoints(pointsToGive);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("transfer", "" + pointsToGive);
|
||||
placeholders.put("touser", "" + user.getPlayerName());
|
||||
placeholders.put("fromuser", "" + cPlayer.getPlayerName());
|
||||
@@ -2741,8 +2770,7 @@ public class CommandLoader {
|
||||
for (String ident : plugin.getConfigFile().getCustomCommands()) {
|
||||
ConfigurationSection section = plugin.getConfigFile().getCustomCommands(ident);
|
||||
@SuppressWarnings("unchecked")
|
||||
String[] args = ArrayUtils
|
||||
.convert((ArrayList<String>) section.getList("Args", new ArrayList<String>()));
|
||||
String[] args = ArrayUtils.convert((ArrayList<String>) section.getList("Args", new ArrayList<>()));
|
||||
plugin.getVoteCommand().add(new CommandHandler(plugin, args, section.getString("Permission", ""),
|
||||
section.getString("HelpMessage", "")) {
|
||||
|
||||
@@ -2750,7 +2778,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, section.getString("Message", ""));
|
||||
for (String str : (ArrayList<String>) section.getList("Commands", new ArrayList<String>())) {
|
||||
for (String str : (ArrayList<String>) section.getList("Commands", new ArrayList<>())) {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -2804,6 +2832,32 @@ public class CommandLoader {
|
||||
}
|
||||
}
|
||||
|
||||
public void processSlotClick(Player player, VotingPluginUser user, String slot) {
|
||||
if (MessageAPI.startsWithIgnoreCase(slot, "url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the commands.
|
||||
*
|
||||
File renamed without changes.
+4
-6
@@ -40,7 +40,7 @@ public class CommandAliases implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
ArrayList<String> argsNew = new ArrayList<String>();
|
||||
ArrayList<String> argsNew = new ArrayList<>();
|
||||
argsNew.add(cmdHandle.getArgs()[0]);
|
||||
for (String arg : args) {
|
||||
argsNew.add(arg);
|
||||
@@ -48,7 +48,7 @@ public class CommandAliases implements CommandExecutor {
|
||||
plugin.debug("Attempting cmd...");
|
||||
plugin.debug("Inputed args: " + ArrayUtils.makeStringList(argsNew));
|
||||
|
||||
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
|
||||
ArrayList<CommandHandler> handles = new ArrayList<>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
@@ -91,11 +91,9 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(
|
||||
MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
File renamed without changes.
+13
-13
@@ -49,7 +49,7 @@ public class AdminGUI {
|
||||
* @return ArrayList of buttons
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<>();
|
||||
buttons.add(new BInventoryButton("&cVoteSites",
|
||||
new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
@@ -241,7 +241,7 @@ public class AdminGUI {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("Enabled: " + voteSite.isEnabled());
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
|
||||
@@ -251,17 +251,17 @@ public class AdminGUI {
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
lore.add("VoteDelayMin: " + voteSite.getVoteDelayMin());
|
||||
|
||||
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
inv.addButton(count,
|
||||
new BInventoryButton(voteSite.getKey(), ArrayUtils.convert(lore), new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
inv.openInventory(player);
|
||||
@@ -281,7 +281,7 @@ public class AdminGUI {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ArrayList<String> playerNames = new ArrayList<String>();
|
||||
ArrayList<String> playerNames = new ArrayList<>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
@@ -302,8 +302,8 @@ public class AdminGUI {
|
||||
});
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
.allowCustomOption(true).request(event.getWhoClicked());
|
||||
}, ArrayUtils.convert(playerNames)).usingMethod(InputMethod.INVENTORY).allowCustomOption(true)
|
||||
.request(event.getWhoClicked());
|
||||
}
|
||||
});
|
||||
|
||||
File renamed without changes.
+4
-4
@@ -35,7 +35,7 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelp(CommandSender sender, int page) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
ArrayList<TextComponent> text = adminHelpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
@@ -61,8 +61,8 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
+5
-5
@@ -40,7 +40,7 @@ public class AdminVotePerms extends GUIHandler {
|
||||
}
|
||||
|
||||
public String[] listPerms(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
@@ -100,7 +100,7 @@ public class AdminVotePerms extends GUIHandler {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
ArrayList<String> text = new ArrayList<>();
|
||||
|
||||
text.add("&c&lCommand : Permissions " + page + "/" + maxPage);
|
||||
|
||||
@@ -115,10 +115,10 @@ public class AdminVotePerms extends GUIHandler {
|
||||
|
||||
public ArrayList<String> listPerms(CommandSender sender, String player, int page) {
|
||||
Player p = Bukkit.getPlayer(player);
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
ArrayList<String> text = new ArrayList<>();
|
||||
if (p != null) {
|
||||
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
@@ -180,7 +180,7 @@ public class AdminVotePerms extends GUIHandler {
|
||||
}
|
||||
|
||||
public String[] listPermsDev(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("Command");
|
||||
msg.add(" Permissions (seperated by |");
|
||||
msg.add(" Help messasge");
|
||||
+3
-3
@@ -48,7 +48,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -66,7 +66,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -79,7 +79,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cPlaceholders:");
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
+3
-3
@@ -45,7 +45,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user, identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -60,7 +60,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
String value = placeholder.placeholderRequest(identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -70,7 +70,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cPlaceholders:");
|
||||
VotingPluginUser placeholderUser = user;
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.player.VoteGUI;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class AdminVoteTopPoints extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public AdminVoteTopPoints(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topPoints1 = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
|
||||
for (String uuid : plugin.getVotingPluginUserManager().getAllUUIDs()) {
|
||||
VotingPluginUser vpUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
vpUser.dontCache();
|
||||
int points = vpUser.getPoints();
|
||||
if (points > 0) {
|
||||
topPoints1.put(vpUser.getTopVoterPlayer(), points);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topPoints = plugin.getTopVoterHandler().sortByValues(topPoints1,
|
||||
false);
|
||||
|
||||
users = topPoints.entrySet();
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
playerSlots.addAll(customizationPlayerSlots);
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory("Top Points");
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
BInventoryButton button = 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) {
|
||||
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
|
||||
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());
|
||||
|
||||
if (customzationEnabled && !playerSlots.isEmpty()) {
|
||||
button.setSlot(playerSlots.remove());
|
||||
}
|
||||
|
||||
inv.setCloseInv(plugin.getGui().isChestVoteTopCloseGUIOnClick());
|
||||
|
||||
inv.addButton(button);
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
if (customzationEnabled) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user)
|
||||
.setSlot(customization.getInt("BackButtonSlot", 0)));
|
||||
} else {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteTop.Customization";
|
||||
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) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (customization == null || !customzationEnabled || !customization.getBoolean("RemoveBottomBar")) {
|
||||
inv.setPages(true);
|
||||
}
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
+1
-1
@@ -52,7 +52,7 @@ public class AdminVoteCumulative extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
ArrayList<Integer> nums = new ArrayList<>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (MessageAPI.isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
-1
@@ -63,7 +63,6 @@ public class AdminVoteCumulativeRemove extends GUIHandler {
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
-1
@@ -63,7 +63,6 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
+1
-1
@@ -52,7 +52,7 @@ public class AdminVoteMilestones extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
ArrayList<Integer> nums = new ArrayList<>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (MessageAPI.isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
File renamed without changes.
+1
-1
@@ -141,7 +141,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("Shop." + identifier + ".Rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
File renamed without changes.
File renamed without changes.
+2
-2
@@ -31,11 +31,11 @@ public class VoteBest extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteBestTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteBestLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("HighestDailyTotal", "" + user.getHighestDailyTotal());
|
||||
placeholders.put("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal());
|
||||
placeholders.put("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal());
|
||||
+3
-2
@@ -64,7 +64,7 @@ public class VoteGUI extends GUIHandler {
|
||||
}
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
String[] today = new VoteToday(plugin, player, user, 1).voteTodayGUI();
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
if (today.length > 0) {
|
||||
for (int i = today.length - 1; i < today.length && list.size() < 10 && i >= 0; i--) {
|
||||
list.add(today[i]);
|
||||
@@ -151,7 +151,8 @@ public class VoteGUI extends GUIHandler {
|
||||
String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
|
||||
if (cmd.equalsIgnoreCase("none")) {
|
||||
return;
|
||||
} else if (!cmd.equals("")) {
|
||||
}
|
||||
if (!cmd.equals("")) {
|
||||
event.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
+8
-8
@@ -34,8 +34,8 @@ public class VoteHelp extends GUIHandler {
|
||||
}
|
||||
|
||||
public ArrayList<TextComponent> helpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class VoteHelp extends GUIHandler {
|
||||
plugin.getConfigFile().getFormatCommandsVoteHelpLine(), hoverColor));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
@@ -65,8 +65,8 @@ public class VoteHelp extends GUIHandler {
|
||||
}
|
||||
|
||||
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class VoteHelp extends GUIHandler {
|
||||
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
@@ -108,8 +108,8 @@ public class VoteHelp extends GUIHandler {
|
||||
|
||||
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
ArrayList<TextComponent> text = new ArrayList<>();
|
||||
if (NMSManager.getInstance().isVersion("1.12")) {
|
||||
text = helpTextLegacy(sender);
|
||||
} else {
|
||||
+4
-4
@@ -33,7 +33,7 @@ public class VoteLast extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
@@ -80,10 +80,10 @@ public class VoteLast extends GUIHandler {
|
||||
PlaceholderUtils
|
||||
.replacePlaceHolder(
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getGui()
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui()
|
||||
.getChestVoteURLURLText(),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"sitename", site.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
+9
-6
@@ -37,7 +37,7 @@ public class VoteNext extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
@@ -64,7 +64,7 @@ public class VoteNext extends GUIHandler {
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout nextLayout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
@@ -93,10 +93,13 @@ public class VoteNext extends GUIHandler {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(siteNameDisplay)
|
||||
.setLore(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time", user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1), 1000, 1000) {
|
||||
new UpdatingBInventoryButton(plugin,
|
||||
site.getItem().setName(siteNameDisplay)
|
||||
.setLore(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time",
|
||||
user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1),
|
||||
1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
+11
-4
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +127,7 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
if (limitPass) {
|
||||
if (!plugin.getShopFile().isVoteShopRequireConfirmation(identifier)) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("identifier",
|
||||
plugin.getShopFile().getShopIdentifierIdentifierName(identifier));
|
||||
placeholders.put("points", "" + points);
|
||||
@@ -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());
|
||||
}
|
||||
});
|
||||
+1
-1
@@ -56,7 +56,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
user.cache();
|
||||
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
|
||||
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
+2
-2
@@ -32,11 +32,11 @@ public class VoteStreak extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteStreakTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteStreakLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("DailyStreak", "" + user.getDayVoteStreak());
|
||||
placeholders.put("WeeklyStreak", "" + user.getWeekVoteStreak());
|
||||
placeholders.put("MonthlyStreak", "" + user.getMonthVoteStreak());
|
||||
+31
-23
@@ -44,7 +44,7 @@ public class VoteToday extends GUIHandler {
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
String[] voteToday = voteToday();
|
||||
|
||||
int maxPage = voteToday.length / pagesize;
|
||||
@@ -52,7 +52,7 @@ public class VoteToday extends GUIHandler {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("page", "" + page);
|
||||
placeholders.put("maxpage", "" + maxPage);
|
||||
|
||||
@@ -91,7 +91,7 @@ public class VoteToday extends GUIHandler {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
String msg = plugin.getGui().getChestVoteTodayLine();
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("VoteSite", voteSite.getDisplayName());
|
||||
placeholders.put("Time", timeString);
|
||||
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
|
||||
@@ -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,42 +116,49 @@ 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()));
|
||||
}
|
||||
|
||||
public String[] voteToday() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", voteSite.getKey());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
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);
|
||||
}
|
||||
@@ -161,7 +168,7 @@ public class VoteToday extends GUIHandler {
|
||||
}
|
||||
|
||||
public String[] voteTodayGUI() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
LocalDateTime mostRecent = null;
|
||||
@@ -175,12 +182,13 @@ public class VoteToday extends GUIHandler {
|
||||
if (mostRecent != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = mostRecent.format(formatter);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", mostRecentSite.getKey());
|
||||
placeholders.put("sitename", mostRecentSite.getDisplayName());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
+3
-3
@@ -56,7 +56,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +85,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<Integer>();
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
@@ -109,7 +109,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
BInventoryButton button = new BInventoryButton(playerItem
|
||||
.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
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;
|
||||
}
|
||||
|
||||
public void next(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
if (yearMonthList.size() <= index) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data for requested index");
|
||||
return;
|
||||
}
|
||||
yearMonth = yearMonthList.get(index);
|
||||
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
if (!plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
|
||||
player.sendMessage(ChatColor.RED + "Can't open previous months, no data");
|
||||
return;
|
||||
}
|
||||
users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
|
||||
|
||||
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<>());
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -32,7 +32,7 @@ public class VoteTotal extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
int daily = user.getTotal(TopVoter.Daily);
|
||||
int weekly = user.getTotal(TopVoter.Weekly);
|
||||
+5
-5
@@ -56,7 +56,7 @@ public class VoteURL extends GUIHandler {
|
||||
}
|
||||
|
||||
public ArrayList<String> getChat(CommandSender sender, boolean bypassCanVote) {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
ArrayList<String> sites = new ArrayList<>();
|
||||
|
||||
List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
|
||||
if (title != null) {
|
||||
@@ -89,7 +89,7 @@ public class VoteURL extends GUIHandler {
|
||||
}
|
||||
}
|
||||
if (user != null) {
|
||||
HashMap<String, String> phs = new HashMap<String, String>();
|
||||
HashMap<String, String> phs = new HashMap<>();
|
||||
phs.put("DailyTotal", "" + user.getTotal(TopVoter.Daily));
|
||||
phs.put("WeekTotal", "" + user.getTotal(TopVoter.Weekly));
|
||||
phs.put("MonthTotal", "" + user.getTotal(TopVoter.Monthly));
|
||||
@@ -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)) {
|
||||
@@ -229,7 +229,7 @@ public class VoteURL extends GUIHandler {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("voteurl", voteSite.getVoteURL());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("player", player.getName());
|
||||
File renamed without changes.
+2
-2
@@ -32,9 +32,9 @@ public class AdminVoteTabCompleter implements TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
List<String> tab = new ArrayList<String>();
|
||||
List<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(),
|
||||
sender, args, args.length - 1));
|
||||
+4
-4
@@ -39,7 +39,7 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] argsIn) {
|
||||
ArrayList<String> msgArray = new ArrayList<String>();
|
||||
ArrayList<String> msgArray = new ArrayList<>();
|
||||
msgArray.add("");
|
||||
for (String arg : argsIn) {
|
||||
msgArray.add(arg);
|
||||
@@ -47,11 +47,11 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
String[] args = ArrayUtils.convert(msgArray);
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
ArrayList<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<>();
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.getAdminVoteCommand());
|
||||
+4
-4
@@ -33,12 +33,12 @@ public class VoteTabCompleter implements TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
ArrayList<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender,
|
||||
args, args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
+10
-2
@@ -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;
|
||||
@@ -39,6 +39,14 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private String RedisUsername = "";
|
||||
|
||||
@ConfigDataString(path = "PluginMessageChannel")
|
||||
@Getter
|
||||
private String pluginMessagingChannel = "vp:vp";
|
||||
|
||||
@ConfigDataBoolean(path = "PluginMessageEncryption")
|
||||
@Getter
|
||||
private boolean pluginMessageEncryption = false;
|
||||
|
||||
@ConfigDataString(path = "Redis.Prefix")
|
||||
@Getter
|
||||
private String RedisPrefix = "";
|
||||
@@ -117,7 +125,7 @@ public class BungeeSettings extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "BungeeVotePartyGlobalCommands")
|
||||
@Getter
|
||||
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<String>();
|
||||
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<>();
|
||||
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
+140
-137
@@ -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;
|
||||
@@ -121,15 +121,15 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "DisabledCommands")
|
||||
@Getter
|
||||
private ArrayList<String> disabledCommands = new ArrayList<String>();
|
||||
private ArrayList<String> disabledCommands = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "DisabledDefaultPermissions")
|
||||
@Getter
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<String>();
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "CachedPlaceholders")
|
||||
@Getter
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "DisableInteractEvent")
|
||||
@Getter
|
||||
@@ -337,45 +337,15 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "VotingBroadcastBlacklist")
|
||||
@Getter
|
||||
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<String>();
|
||||
|
||||
public Config(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the black list.
|
||||
*
|
||||
* @return the black list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getBlackList() {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
|
||||
}
|
||||
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<>();
|
||||
|
||||
@ConfigDataKeys(path = "CustomCommands")
|
||||
@Getter
|
||||
private Set<String> customCommands = new HashSet<String>();
|
||||
private Set<String> customCommands = new HashSet<>();
|
||||
|
||||
@ConfigDataKeys(path = "CustomPlaceholderReturns")
|
||||
@Getter
|
||||
private Set<String> customPlaceholderReturns = new HashSet<String>();
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns(String placeholder) {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<String>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
|
||||
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
|
||||
}
|
||||
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
private Set<String> customPlaceholderReturns = new HashSet<>();
|
||||
|
||||
@ConfigDataString(path = "Format.BroadcastMsg")
|
||||
@Getter
|
||||
@@ -395,7 +365,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "Format.Commands.Vote.Best.Lines")
|
||||
@Getter
|
||||
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<String>();
|
||||
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<>();
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Best.Title")
|
||||
@Getter
|
||||
@@ -441,10 +411,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String placeholderCacheLevelString = "AUTO";
|
||||
|
||||
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
|
||||
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Layout")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextLayout = "&3%SiteName%: &6%info%";
|
||||
@@ -453,69 +419,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String formatCommandsVoteNextTitle = "&3&l%player% Next Votes:";
|
||||
|
||||
/**
|
||||
* Gets the commands vote party.
|
||||
*
|
||||
* @return the commands vote party
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteParty() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteStreakLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Streak.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteStreakTitle = "&3&l%player% Vote Streak";
|
||||
|
||||
/**
|
||||
* Gets the commands vote text.
|
||||
*
|
||||
* @return the commands vote text
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteText() {
|
||||
ArrayList<String> str = new ArrayList<String>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotal() {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total",
|
||||
new ArrayList<String>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&l%player% Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotalAll() {
|
||||
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
|
||||
new ArrayList<String>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&lServer Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Sites")
|
||||
@Getter
|
||||
private String formatCommandsVoteURLS = "&4%num%: &c&l%SiteName% - &c%url%";
|
||||
@@ -567,9 +474,11 @@ public class Config extends YMLFile {
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line2")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine2 = "#%position%";
|
||||
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line3")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine3 = "%player%";
|
||||
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line4")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine4 = "%votes% Votes";
|
||||
@@ -609,40 +518,13 @@ public class Config extends YMLFile {
|
||||
@ConfigDataString(path = "Format.InvalidCommand.Vote")
|
||||
@Getter
|
||||
private String formatInvalidCommandVote = "&4No valid arguments, see /vote help!";
|
||||
|
||||
@ConfigDataString(path = "Format.InvalidCommand.AdminVote")
|
||||
@Getter
|
||||
private String formatInvalidCommandAdminVote = "&4No valid arguments, see /adminvote help!";
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
*
|
||||
* @return the vote help
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatVoteHelp() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "GiveDefaultPermission")
|
||||
@Getter
|
||||
private boolean giveDefaultPermission = true;
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return isLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return isLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return isLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return isLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.AllTime")
|
||||
@Getter
|
||||
private boolean loadTopVoterAllTime = true;
|
||||
@@ -663,13 +545,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
|
||||
@@ -677,7 +563,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "RequestAPI.DisabledMethods")
|
||||
@Getter
|
||||
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<String>();
|
||||
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "StoreTopVoters.Daily")
|
||||
@Getter
|
||||
@@ -711,6 +597,127 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean voteRemindingRemindOnlyOnce = false;
|
||||
|
||||
@ConfigDataString(path = "VoteTopDefault")
|
||||
@Getter
|
||||
private String voteTopDefault = "Monthly";
|
||||
|
||||
public Config(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the black list.
|
||||
*
|
||||
* @return the black list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getBlackList() {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<>());
|
||||
}
|
||||
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns(String placeholder) {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
|
||||
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote party.
|
||||
*
|
||||
* @return the commands vote party
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteParty() {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteStreakLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote text.
|
||||
*
|
||||
* @return the commands vote text
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteText() {
|
||||
ArrayList<String> str = new ArrayList<>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotal() {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total", new ArrayList<>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&l%player% Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotalAll() {
|
||||
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
|
||||
new ArrayList<>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&lServer Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
*
|
||||
* @return the vote help
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatVoteHelp() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<>());
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return isLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return isLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return isLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return isLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
|
||||
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
@@ -720,10 +727,6 @@ public class Config extends YMLFile {
|
||||
return "VoteReminding.Rewards";
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "VoteTopDefault")
|
||||
@Getter
|
||||
private String voteTopDefault = "Monthly";
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
+12
-12
@@ -14,8 +14,8 @@ 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.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
@@ -138,6 +138,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(site).getConfigurationSection("Item");
|
||||
}
|
||||
|
||||
public String getPermissionToView(String siteName) {
|
||||
return getData(siteName).getString("PermissionToView", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
@@ -168,10 +172,6 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
public int getVoteDelayDailyHour(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayDailyHour", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
@@ -182,6 +182,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(siteName).getDouble("VoteDelay", 24);
|
||||
}
|
||||
|
||||
public int getVoteDelayDailyHour(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayDailyHour", 0);
|
||||
}
|
||||
|
||||
public double getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getDouble("VoteDelayMin", 0);
|
||||
}
|
||||
@@ -239,7 +243,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return the vote sites load
|
||||
*/
|
||||
public ArrayList<VoteSite> getVoteSitesLoad() {
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<>();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames(true);
|
||||
if (voteSiteNames != null) {
|
||||
for (String site : voteSiteNames) {
|
||||
@@ -276,7 +280,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
}
|
||||
|
||||
public ArrayList<String> getVoteSitesNames(boolean checkEnabled) {
|
||||
ArrayList<String> siteNames = new ArrayList<String>();
|
||||
ArrayList<String> siteNames = new ArrayList<>();
|
||||
if (getData().isConfigurationSection("VoteSites")) {
|
||||
siteNames = ArrayUtils.convert(getData().getConfigurationSection("VoteSites").getKeys(false));
|
||||
}
|
||||
@@ -298,10 +302,6 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return siteNames;
|
||||
}
|
||||
|
||||
public String getPermissionToView(String siteName) {
|
||||
return getData(siteName).getString("PermissionToView", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
@@ -309,7 +309,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL(String siteName) {
|
||||
return getData(siteName).getString("VoteURL");
|
||||
return getData(siteName).getString("VoteURL", "");
|
||||
}
|
||||
|
||||
public boolean getWaitUntilVoteDelay(String siteName) {
|
||||
+85
-85
@@ -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.ConfigDataConfigurationSection;
|
||||
@@ -50,7 +50,7 @@ public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.TopLayout")
|
||||
@Getter
|
||||
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<String>();
|
||||
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<>();
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.Title")
|
||||
@Getter
|
||||
@@ -134,11 +134,6 @@ public class GUI extends YMLFile {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
|
||||
@Getter
|
||||
private ConfigurationSection CHESTBackButton;
|
||||
@@ -163,58 +158,14 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private String chestVoteGUIName = "&cVoteGUI: &c&l%player%";
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot command
|
||||
*/
|
||||
|
||||
public String getChestVoteGUISlotCommand(String slot) {
|
||||
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot lore.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot lore
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
@ConfigDataKeys(path = "CHEST.VoteGUI")
|
||||
@Getter
|
||||
private Set<String> chestVoteGUISlots = new HashSet<String>();
|
||||
|
||||
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
private Set<String> chestVoteGUISlots = new HashSet<>();
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.Customization")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTopCustomization;
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot slot
|
||||
*/
|
||||
public int getChestVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteLast.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteLastBackButton = false;
|
||||
@@ -239,10 +190,6 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private String chestVoteNextLine = "%time%";
|
||||
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteRewardName")
|
||||
@Getter
|
||||
private String chestVoteRewardName = "VoteReward";
|
||||
@@ -321,7 +268,7 @@ public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "CHEST.VoteTop.SwitchItem.TopVoters")
|
||||
@Getter
|
||||
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<String>();
|
||||
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<>();
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.AllTimeTotal.Item")
|
||||
@Getter
|
||||
@@ -335,22 +282,6 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalDayTotalItem;
|
||||
|
||||
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getChestVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getChestVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getChestVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.MonthTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalMonthTotalItem;
|
||||
@@ -393,18 +324,7 @@ public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataKeys(path = "CHEST.VoteURL.ExtraItems")
|
||||
@Getter
|
||||
private Set<String> chestVoteURLExtraItems = new HashSet<String>();
|
||||
|
||||
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
public Set<String> getChestGUIExtraItems(String gui) {
|
||||
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
private Set<String> chestVoteURLExtraItems = new HashSet<>();
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SiteName")
|
||||
@Getter
|
||||
@@ -438,6 +358,86 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private boolean chestVoteURLViewAllUrlsButtonEnabled = false;
|
||||
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public Set<String> getChestGUIExtraItems(String gui) {
|
||||
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot command
|
||||
*/
|
||||
|
||||
public String getChestVoteGUISlotCommand(String slot) {
|
||||
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot lore.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot lore
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot slot
|
||||
*/
|
||||
public int getChestVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getChestVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getChestVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getChestVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
+48
-52
@@ -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;
|
||||
@@ -48,11 +48,54 @@ public class ShopFile extends YMLFile {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.BackButton")
|
||||
@Getter
|
||||
private boolean voteShopBackButton = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.ReopenGUIOnPurchase")
|
||||
@Getter
|
||||
private boolean voteShopReopenGUIOnPurchase = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.Enabled")
|
||||
@Getter
|
||||
private boolean voteShopEnabled = true;
|
||||
|
||||
@ConfigDataString(path = "VoteShop.Name")
|
||||
@Getter
|
||||
private String voteShopName = "VoteShop";
|
||||
|
||||
@ConfigDataKeys(path = "ExtraItems")
|
||||
@Getter
|
||||
private Set<String> voteShopExtraItems = new HashSet<>();
|
||||
|
||||
public ShopFile(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Shop.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void convertFromGUIFile() {
|
||||
// booleans
|
||||
setValue("VoteShop.Enabled", plugin.getGui().getData().getBoolean("CHEST.VoteShopEnabled"));
|
||||
setValue("VoteShop.BackButton", plugin.getGui().getData().getBoolean("CHEST.VoteShopBackButton"));
|
||||
setValue("VoteShop.HideLimitReached", plugin.getGui().getData().getBoolean("CHEST.VoteShopHideLimitedReached"));
|
||||
setValue("VoteShop.RequireConfirmation",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopRequireConfirmation"));
|
||||
setValue("VoteShop.ReopenGUIOnPurchase",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopReopenGUIOnPurchase"));
|
||||
|
||||
// strings
|
||||
setValue("VoteShop.Name", plugin.getGui().getData().getString("CHEST.VoteShopName"));
|
||||
setValue("VoteShop.LimitReached", plugin.getGui().getData().getString("CHEST.VoteShopLimitReached"));
|
||||
setValue("VoteShop.Disabled", plugin.getGui().getData().getString("CHEST.VoteShopDisabled"));
|
||||
|
||||
// sections
|
||||
setValue("Shop", plugin.getGui().getData().getConfigurationSection("CHEST.Shop"));
|
||||
setValue("ExtraItems", plugin.getGui().getData().getConfigurationSection("CHEST.VoteShopExtraItems"));
|
||||
setValue("ShopConfirmPurchase", plugin.getGui().getData().getConfigurationSection("CHEST.ShopConfirmPurchase"));
|
||||
saveData();
|
||||
|
||||
}
|
||||
|
||||
public void createShop(String value) {
|
||||
ConfigurationSection shopData = getData().createSection("Shop." + value);
|
||||
shopData.set("Identifier_Name", value);
|
||||
@@ -69,9 +112,9 @@ public class ShopFile extends YMLFile {
|
||||
saveData();
|
||||
}
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
|
||||
@Getter
|
||||
private ConfigurationSection CHESTBackButton;
|
||||
public ConfigurationSection getGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("ExtraItems." + item);
|
||||
}
|
||||
|
||||
public int getShopIdentifierCost(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Cost");
|
||||
@@ -94,21 +137,13 @@ public class ShopFile extends YMLFile {
|
||||
if (shop != null) {
|
||||
return shop.getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getShopIdentifierSection(String identifier) {
|
||||
return getData().getConfigurationSection("Shop." + identifier);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.BackButton")
|
||||
@Getter
|
||||
private boolean voteShopBackButton = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.ReopenGUIOnPurchase")
|
||||
@Getter
|
||||
private boolean voteShopReopenGUIOnPurchase = true;
|
||||
|
||||
public boolean getVoteShopCloseGUI(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".CloseGUI", true);
|
||||
}
|
||||
@@ -117,14 +152,6 @@ public class ShopFile extends YMLFile {
|
||||
return getData().getBoolean("Shop." + shop + ".HideOnNoPermission", true);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.Enabled")
|
||||
@Getter
|
||||
private boolean voteShopEnabled = true;
|
||||
|
||||
@ConfigDataString(path = "VoteShop.Name")
|
||||
@Getter
|
||||
private String voteShopName = "VoteShop";
|
||||
|
||||
public boolean getVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".NotBuyable", false);
|
||||
}
|
||||
@@ -150,14 +177,6 @@ public class ShopFile extends YMLFile {
|
||||
return getData().getBoolean("Shop." + shop + ".Reset.Weekly", false);
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("VoteShopExtraItems." + item);
|
||||
}
|
||||
|
||||
@ConfigDataKeys(path = "VoteShopExtraItems")
|
||||
@Getter
|
||||
private Set<String> voteShopExtraItems = new HashSet<String>();
|
||||
|
||||
public boolean isVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("Shop." + identifier + ".RequireConfirmation", isVoteShopRequireConfirmation());
|
||||
}
|
||||
@@ -172,29 +191,6 @@ public class ShopFile extends YMLFile {
|
||||
plugin.saveResource("Shop.yml", true);
|
||||
}
|
||||
|
||||
public void convertFromGUIFile() {
|
||||
// booleans
|
||||
setValue("VoteShop.Enabled", plugin.getGui().getData().getBoolean("CHEST.VoteShopEnabled"));
|
||||
setValue("VoteShop.BackButton", plugin.getGui().getData().getBoolean("CHEST.VoteShopBackButton"));
|
||||
setValue("VoteShop.HideLimitReached", plugin.getGui().getData().getBoolean("CHEST.VoteShopHideLimitedReached"));
|
||||
setValue("VoteShop.RequireConfirmation",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopRequireConfirmation"));
|
||||
setValue("VoteShop.ReopenGUIOnPurchase",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopReopenGUIOnPurchase"));
|
||||
|
||||
// strings
|
||||
setValue("VoteShop.Name", plugin.getGui().getData().getString("CHEST.VoteShopName"));
|
||||
setValue("VoteShop.LimitReached", plugin.getGui().getData().getString("CHEST.VoteShopLimitReached"));
|
||||
setValue("VoteShop.Disabled", plugin.getGui().getData().getString("CHEST.VoteShopDisabled"));
|
||||
|
||||
// sections
|
||||
setValue("Shop", plugin.getGui().getData().getConfigurationSection("CHEST.Shop"));
|
||||
setValue("ExtraItems", plugin.getGui().getData().getConfigurationSection("CHEST.VoteShopExtraItems"));
|
||||
setValue("ShopConfirmPurchase", plugin.getGui().getData().getConfigurationSection("CHEST.ShopConfirmPurchase"));
|
||||
saveData();
|
||||
|
||||
}
|
||||
|
||||
public void removeShop(String value) {
|
||||
getData().set("Shop." + value, null);
|
||||
saveData();
|
||||
+123
-107
@@ -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,13 +76,13 @@ 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<>();
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<String>();
|
||||
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
@@ -102,119 +103,29 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private double voteStreakRequirementWeek = 50;
|
||||
|
||||
public SpecialRewardsConfig(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean getCumulativeRewardEnabled(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Enabled");
|
||||
}
|
||||
|
||||
public String getCumulativeRewardsPath(int cumulative) {
|
||||
return "Cumulative." + cumulative + ".Rewards";
|
||||
}
|
||||
|
||||
public List<Integer> getCumulativeBlackList(int cumulative) {
|
||||
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
|
||||
}
|
||||
|
||||
public boolean getCumulativeRecurring(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
|
||||
}
|
||||
|
||||
@ConfigDataKeys(path = "Cumulative")
|
||||
@Getter
|
||||
private Set<String> cumulativeVotes = new HashSet<String>();
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameDay(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameMonth(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameWeek(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
public String getCumulativeVotesTotal(int cumulative) {
|
||||
String str = getData().getString("Cumulative." + cumulative + ".TotalToUse", "");
|
||||
if (str.isEmpty()) {
|
||||
if (getCumulativeVotesInSameMonth(cumulative)) {
|
||||
return TopVoter.Monthly.toString();
|
||||
} else if (getCumulativeVotesInSameWeek(cumulative)) {
|
||||
return TopVoter.Weekly.toString();
|
||||
} else if (getCumulativeVotesInSameDay(cumulative)) {
|
||||
return TopVoter.Daily.toString();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
private Set<String> cumulativeVotes = new HashSet<>();
|
||||
|
||||
@ConfigDataKeys(path = "DailyAwards")
|
||||
@Getter
|
||||
private Set<String> dailyPossibleRewardPlaces = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone reward enabled
|
||||
*/
|
||||
public boolean getMilestoneRewardEnabled(int milestones) {
|
||||
return getData().getBoolean("MileStones." + milestones + ".Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone rewards.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone rewards
|
||||
*/
|
||||
public String getMilestoneRewardsPath(int milestones) {
|
||||
return "MileStones." + milestones + ".Rewards";
|
||||
}
|
||||
private Set<String> dailyPossibleRewardPlaces = new HashSet<>();
|
||||
|
||||
@ConfigDataKeys(path = "MileStones")
|
||||
@Getter
|
||||
private Set<String> milestoneVotes = new HashSet<String>();
|
||||
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
* @return the monthly possible reward places
|
||||
*/
|
||||
public Set<String> getMonthlyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
private Set<String> milestoneVotes = new HashSet<>();
|
||||
|
||||
@ConfigDataBoolean(path = "ResetMilestonesMonthly")
|
||||
@Getter
|
||||
private boolean resetMilestonesMonthly = false;
|
||||
|
||||
@ConfigDataString(path = "VoteParty.Broadcast")
|
||||
@Getter
|
||||
private String votePartyBroadcast = "";
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalCommands", secondPath = "VoteParty.Commands")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalCommands = new ArrayList<String>();
|
||||
private ArrayList<String> votePartyGlobalCommands = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.CountFakeVotes")
|
||||
@Getter
|
||||
@@ -232,8 +143,13 @@ 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;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
|
||||
@@ -259,11 +175,115 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@ConfigDataInt(path = "VoteParty.UserVotesRequired")
|
||||
@Getter
|
||||
private int votePartyUserVotesRequired = 0;
|
||||
|
||||
@ConfigDataInt(path = "VoteParty.VotesRequired")
|
||||
@Getter
|
||||
private int votePartyVotesRequired = 0;
|
||||
|
||||
@ConfigDataKeys(path = "WeeklyAwards")
|
||||
@Getter
|
||||
private Set<String> weeklyPossibleRewardPlaces = new HashSet<>();
|
||||
|
||||
public SpecialRewardsConfig(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public List<Integer> getCumulativeBlackList(int cumulative) {
|
||||
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
|
||||
}
|
||||
|
||||
public boolean getCumulativeRecurring(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
|
||||
}
|
||||
|
||||
public boolean getCumulativeRewardEnabled(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Enabled");
|
||||
}
|
||||
|
||||
public String getCumulativeRewardsPath(int cumulative) {
|
||||
return "Cumulative." + cumulative + ".Rewards";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameDay(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameMonth(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameWeek(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
public String getCumulativeVotesTotal(int cumulative) {
|
||||
String str = getData().getString("Cumulative." + cumulative + ".TotalToUse", "");
|
||||
if (str.isEmpty()) {
|
||||
if (getCumulativeVotesInSameMonth(cumulative)) {
|
||||
return TopVoter.Monthly.toString();
|
||||
}
|
||||
if (getCumulativeVotesInSameWeek(cumulative)) {
|
||||
return TopVoter.Weekly.toString();
|
||||
}
|
||||
if (getCumulativeVotesInSameDay(cumulative)) {
|
||||
return TopVoter.Daily.toString();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone reward enabled
|
||||
*/
|
||||
public boolean getMilestoneRewardEnabled(int milestones) {
|
||||
return getData().getBoolean("MileStones." + milestones + ".Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone rewards.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone rewards
|
||||
*/
|
||||
public String getMilestoneRewardsPath(int milestones) {
|
||||
return "MileStones." + milestones + ".Rewards";
|
||||
}
|
||||
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
* @return the monthly possible reward places
|
||||
*/
|
||||
public Set<String> getMonthlyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequiredWithTypo() {
|
||||
int increase = getVotePartyIncreaseVotesRequired();
|
||||
if (increase > 0) {
|
||||
return increase;
|
||||
}
|
||||
return getVotePartyIncreaseVotesRquired();
|
||||
}
|
||||
|
||||
public boolean getVoteStreakRewardEnabled(String type, String s) {
|
||||
return getData().getBoolean("VoteStreak." + type + "." + s + ".Enabled");
|
||||
}
|
||||
@@ -278,9 +298,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<String>();
|
||||
return new HashSet<>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,10 +308,6 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
@ConfigDataKeys(path = "WeeklyAwards")
|
||||
@Getter
|
||||
private Set<String> weeklyPossibleRewardPlaces = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
+122
-122
@@ -16,7 +16,7 @@ import org.bukkit.event.Listener;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
@@ -29,27 +29,18 @@ public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<>();
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
private boolean cooldownCheckEnabled = false;
|
||||
|
||||
public void checkEnabled() {
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
|
||||
cooldownCheckEnabled = true;
|
||||
} else {
|
||||
cooldownCheckEnabled = false;
|
||||
}
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
public void check(UUID uuid) {
|
||||
@@ -60,25 +51,6 @@ public class CoolDownCheck implements Listener {
|
||||
check(user);
|
||||
}
|
||||
|
||||
public void checkPerSite(UUID uuid) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.dontCache();
|
||||
}
|
||||
checkPerSite(user);
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
schedule(user, true);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user, true);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void check(VotingPluginUser user) {
|
||||
boolean coolDownCheck = user.getCoolDownCheck();
|
||||
if (coolDownCheck) {
|
||||
@@ -93,6 +65,48 @@ public class CoolDownCheck implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkAllVoteSite(VoteSite site) {
|
||||
plugin.getLogger().info("Checking vote cooldown rewards for all players: " + site.getKey());
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
checkPerSite(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey());
|
||||
}
|
||||
|
||||
public void checkEnabled() {
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
|
||||
cooldownCheckEnabled = true;
|
||||
} else {
|
||||
cooldownCheckEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkPerSite(UUID uuid) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.dontCache();
|
||||
}
|
||||
checkPerSite(user);
|
||||
}
|
||||
|
||||
public synchronized void checkPerSite(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
@@ -117,6 +131,74 @@ public class CoolDownCheck implements Listener {
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
user.dontCache();
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
checkPerSite(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward", new RewardOptions());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
|
||||
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName()).addPlaceholder("url",
|
||||
event.getSite().getVoteURL(false)));
|
||||
}
|
||||
|
||||
public void schedule(VotingPluginUser user, boolean force) {
|
||||
if (user.getSitesVotedOn() > 0 || force) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
check(uuid);
|
||||
}
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
} else {
|
||||
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void schedulePerSite(VotingPluginUser user, boolean force) {
|
||||
if (user.getSitesVotedOn() > 0 || force) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
@@ -143,97 +225,15 @@ public class CoolDownCheck implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void schedule(VotingPluginUser user, boolean force) {
|
||||
if (user.getSitesVotedOn() > 0 || force) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
check(uuid);
|
||||
}
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
} else {
|
||||
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
|
||||
}
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
schedule(user, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
user.dontCache();
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
checkPerSite(user);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void checkAllVoteSite(VoteSite site) {
|
||||
plugin.getLogger().info("Checking vote cooldown rewards for all players: " + site.getKey());
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
checkPerSite(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user, true);
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward", new RewardOptions());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
|
||||
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName()).addPlaceholder("url",
|
||||
event.getSite().getVoteURL(false)));
|
||||
}
|
||||
|
||||
}
|
||||
+97
-98
@@ -38,54 +38,6 @@ public class ServerData {
|
||||
}
|
||||
}
|
||||
|
||||
public void setShopConverted(boolean value) {
|
||||
getData().set("VoteShopConverted", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public boolean isVoteShopConverted() {
|
||||
return getData().getBoolean("VoteShopConverted");
|
||||
}
|
||||
|
||||
public void updatePlaceholders() {
|
||||
boolean data = getData().getBoolean("AutoCacheUpdated", false);
|
||||
if (!data) {
|
||||
List<String> placeholders = getAutoCachedPlaceholder();
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
placeholders.set(i, placeholders.get(i).toLowerCase());
|
||||
}
|
||||
setAutoCachedPlaceholder(placeholders);
|
||||
getData().set("AutoCacheUpdated", true);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public void addVoteShopPurchase(String ident) {
|
||||
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
|
||||
}
|
||||
|
||||
public void setVoteShopPurchases(String ident, int amount) {
|
||||
getData().set("VoteShopPurchases." + ident, amount);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getVoteShopPurchases(String ident) {
|
||||
return getData().getInt("VoteShopPurchases." + ident);
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public List<String> getAutoCachedPlaceholder() {
|
||||
return getData().getStringList("AutoCachePlaceholders");
|
||||
}
|
||||
|
||||
public List<String> getDisabledReminders() {
|
||||
return getData().getStringList("DisabledReminders");
|
||||
}
|
||||
|
||||
public synchronized void addServiceSite(String site) {
|
||||
ArrayList<String> l = getServiceSites();
|
||||
if (!getServiceSites().contains(site)) {
|
||||
@@ -116,6 +68,34 @@ public class ServerData {
|
||||
getSignSkullLocation("" + count), getSignData("" + count), getSignPosition("" + count)));
|
||||
}
|
||||
|
||||
public void addTimeVoted(int num, VoteTimeQueue vote) {
|
||||
getData().set("TimedVoteCache." + num + ".Name", vote.getName());
|
||||
getData().set("TimedVoteCache." + num + ".Service", vote.getService());
|
||||
getData().set("TimedVoteCache." + num + ".Time", vote.getTime());
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void addVoteShopPurchase(String ident) {
|
||||
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
|
||||
}
|
||||
|
||||
public void clearTimedVoteCache() {
|
||||
getData().set("TimedVoteCache", null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public List<String> getAutoCachedPlaceholder() {
|
||||
return getData().getStringList("AutoCachePlaceholders");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyRequired() {
|
||||
return getData().getInt("BungeeVotePartyRequired");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
@@ -130,9 +110,13 @@ public class ServerData {
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<String> getDisabledReminders() {
|
||||
return getData().getStringList("DisabledReminders");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getServiceSites() {
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<String>());
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +160,7 @@ public class ServerData {
|
||||
try {
|
||||
return getData().getConfigurationSection("Signs").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,10 +179,25 @@ public class ServerData {
|
||||
getData().getDouble("Signs." + sign + ".Skull.Z"));
|
||||
}
|
||||
|
||||
public Set<String> getTimedVoteCacheKeys() {
|
||||
if (getData().isConfigurationSection("TimedVoteCache")) {
|
||||
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getTimedVoteCacheSection(String num) {
|
||||
return getData().getConfigurationSection("TimedVoteCache." + num);
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
public int getVoteShopPurchases(String ident) {
|
||||
return getData().getInt("VoteShopPurchases." + ident);
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num == plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
@@ -216,6 +215,10 @@ public class ServerData {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVoteShopConverted() {
|
||||
return getData().getBoolean("VoteShopConverted");
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
@@ -268,11 +271,40 @@ public class ServerData {
|
||||
plugin.getServerDataFile().saveData();
|
||||
}
|
||||
|
||||
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
|
||||
ArrayList<String> uuids = new ArrayList<>();
|
||||
for (UUID uuid : disabledReminders) {
|
||||
uuids.add(uuid.toString());
|
||||
}
|
||||
getData().set("DisabledReminders", uuids);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyCurrent(int current) {
|
||||
getData().set("BungeeVotePartyCurrent", current);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyRequired(int required) {
|
||||
getData().set("BungeeVotePartyRequired", required);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setServiceSites(ArrayList<String> list) {
|
||||
getData().set("ServiceSites", list);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setShopConverted(boolean value) {
|
||||
getData().set("VoteShopConverted", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setSign(String count, Location location, Location skullLocation, String data, int position) {
|
||||
|
||||
getData().set("Signs." + count + ".World", location.getWorld().getName());
|
||||
@@ -312,6 +344,11 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteShopPurchases(String ident, int amount) {
|
||||
getData().set("VoteShopPurchases." + ident, amount);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void updateLastVoteParty() {
|
||||
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
|
||||
saveData();
|
||||
@@ -323,31 +360,17 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyRequired() {
|
||||
return getData().getInt("BungeeVotePartyRequired");
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyCurrent(int current) {
|
||||
getData().set("BungeeVotePartyCurrent", current);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyRequired(int required) {
|
||||
getData().set("BungeeVotePartyRequired", required);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
for (UUID uuid : disabledReminders) {
|
||||
uuids.add(uuid.toString());
|
||||
public void updatePlaceholders() {
|
||||
boolean data = getData().getBoolean("AutoCacheUpdated", false);
|
||||
if (!data) {
|
||||
List<String> placeholders = getAutoCachedPlaceholder();
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
placeholders.set(i, placeholders.get(i).toLowerCase());
|
||||
}
|
||||
setAutoCachedPlaceholder(placeholders);
|
||||
getData().set("AutoCacheUpdated", true);
|
||||
saveData();
|
||||
}
|
||||
getData().set("DisabledReminders", uuids);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -356,28 +379,4 @@ public class ServerData {
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
|
||||
public void addTimeVoted(int num, VoteTimeQueue vote) {
|
||||
getData().set("TimedVoteCache." + num + ".Name", vote.getName());
|
||||
getData().set("TimedVoteCache." + num + ".Service", vote.getService());
|
||||
getData().set("TimedVoteCache." + num + ".Time", vote.getTime());
|
||||
saveData();
|
||||
}
|
||||
|
||||
public Set<String> getTimedVoteCacheKeys() {
|
||||
if (getData().isConfigurationSection("TimedVoteCache")) {
|
||||
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
|
||||
} else {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getTimedVoteCacheSection(String num) {
|
||||
return getData().getConfigurationSection("TimedVoteCache." + num);
|
||||
}
|
||||
|
||||
public void clearTimedVoteCache() {
|
||||
getData().set("TimedVoteCache", null);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -3,8 +3,8 @@ package com.bencodez.votingplugin.events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -55,7 +55,7 @@ public class PlayerPostVoteEvent extends Event {
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long voteTime = 0;
|
||||
@@ -64,7 +64,8 @@ public class PlayerPostVoteEvent extends Event {
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee, long voteTime) {
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee,
|
||||
long voteTime) {
|
||||
super(true);
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -3,8 +3,8 @@ package com.bencodez.votingplugin.events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+6
-4
@@ -8,7 +8,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -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();
|
||||
@@ -74,14 +76,14 @@ public class PlayerJoinEvent implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
final Player player = event.getPlayer();
|
||||
plugin.getLoginTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(player.getUniqueId());
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
plugin.getPlaceholders().onLogout(user);
|
||||
+29
-9
@@ -13,10 +13,10 @@ import org.bukkit.event.Listener;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerManager;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -50,7 +50,25 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
String playerName = event.getPlayer();
|
||||
plugin.debug("Processing PlayerVoteEvent: " + playerName + "/" + event.getServiceSite());
|
||||
|
||||
boolean notValid = false;
|
||||
if (!PlayerManager.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
if (!playerName.startsWith(plugin.getOptions().getBedrockPlayerPrefix())
|
||||
&& !plugin.getOptions().getBedrockPlayerPrefix().isEmpty()) {
|
||||
if (!event.isBungee() && PlayerManager.getInstance().isValidUser(
|
||||
plugin.getOptions().getBedrockPlayerPrefix() + playerName,
|
||||
plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
plugin.debug("Detected a bedrock user without bedrock prefix, adjusting");
|
||||
playerName = plugin.getOptions().getBedrockPlayerPrefix() + playerName;
|
||||
} else {
|
||||
notValid = true;
|
||||
}
|
||||
} else {
|
||||
notValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (notValid) {
|
||||
if (!plugin.getConfigFile().isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
@@ -86,7 +104,7 @@ public class PlayerVoteListener implements Listener {
|
||||
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + event.getServiceSite() + "'");
|
||||
|
||||
ArrayList<String> services = new ArrayList<String>();
|
||||
ArrayList<String> services = new ArrayList<>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
@@ -117,13 +135,12 @@ public class PlayerVoteListener implements Listener {
|
||||
if (!event.isRealVote()) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " did a not real vote, bypassing WaitUntilVoteDelay");
|
||||
} else {
|
||||
if (user.hasPermission("VotingPlugin.BypassWaitUntilVoteDelay")) {
|
||||
plugin.getLogger()
|
||||
.info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing");
|
||||
} else {
|
||||
if (!user.hasPermission("VotingPlugin.BypassWaitUntilVoteDelay")) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
}
|
||||
plugin.getLogger()
|
||||
.info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +151,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 +243,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());
|
||||
File renamed without changes.
+1
-1
@@ -8,8 +8,8 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
File renamed without changes.
+13
-14
@@ -16,7 +16,7 @@ import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -132,7 +132,7 @@ public class VoteSite {
|
||||
|
||||
} else {
|
||||
String bc = MessageAPI.colorize(plugin.getConfigFile().getFormatBroadCastMsg());
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", playerName);
|
||||
placeholders.put("nickname",
|
||||
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
|
||||
@@ -142,7 +142,7 @@ public class VoteSite {
|
||||
placeholders.put("neededvotes", "" + plugin.getVoteParty().getNeededVotes());
|
||||
bc = PlaceholderUtils.replacePlaceHolder(bc, placeholders);
|
||||
bc = PlaceholderUtils.replacePlaceHolders(user.getOfflinePlayer(), bc);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
@@ -164,9 +164,8 @@ public class VoteSite {
|
||||
plugin.getLogger().warning("Invalid display item section in site: " + key);
|
||||
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid display item for site: " + key)
|
||||
.setLore("&cInvalid display item for site: " + key);
|
||||
} else {
|
||||
return new ItemBuilder(item);
|
||||
}
|
||||
return new ItemBuilder(item);
|
||||
}
|
||||
|
||||
public ConfigurationSection getSiteData() {
|
||||
@@ -180,12 +179,11 @@ public class VoteSite {
|
||||
public String getVoteURL(boolean json) {
|
||||
if (!plugin.getConfigFile().isFormatCommandsVoteForceLinks() || !json || MessageAPI.containsJson(voteURL)) {
|
||||
return voteURL;
|
||||
} else {
|
||||
if (!voteURL.startsWith("http")) {
|
||||
return "[Text=\"" + voteURL + "\",url=\"http://" + voteURL + "\"]";
|
||||
}
|
||||
return "[Text=\"" + voteURL + "\",url=\"" + voteURL + "\"]";
|
||||
}
|
||||
if (!voteURL.startsWith("http")) {
|
||||
return "[Text=\"" + voteURL + "\",url=\"http://" + voteURL + "\"]";
|
||||
}
|
||||
return "[Text=\"" + voteURL + "\",url=\"" + voteURL + "\"]";
|
||||
}
|
||||
|
||||
public String getVoteURLJsonStrip() {
|
||||
@@ -202,15 +200,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() {
|
||||
+4
-2
@@ -44,7 +44,8 @@ public class MVdWPlaceholders {
|
||||
.getVotingPluginUser(event.getOfflinePlayer());
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()
|
||||
&& user.hasPrimaryAccount()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
return place.placeholderRequest(user,
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
@@ -55,7 +56,8 @@ public class MVdWPlaceholders {
|
||||
|
||||
}
|
||||
|
||||
for (final NonPlayerPlaceHolder<VotingPluginUser> place : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (final NonPlayerPlaceHolder<VotingPluginUser> place : plugin.getPlaceholders()
|
||||
.getNonPlayerPlaceholders()) {
|
||||
String str = place.getIdentifier();
|
||||
if (!str.endsWith("_")) {
|
||||
PlaceholderAPI.registerPlaceholder(VotingPluginMain.plugin, "VotingPlugin_" + str,
|
||||
+186
-164
@@ -41,35 +41,52 @@ import lombok.Getter;
|
||||
public class PlaceHolders {
|
||||
|
||||
@Getter
|
||||
private ArrayList<NonPlayerPlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<NonPlayerPlaceHolder<VotingPluginUser>>();
|
||||
private ArrayList<NonPlayerPlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder<VotingPluginUser>> placeholders = new ArrayList<PlaceHolder<VotingPluginUser>>();
|
||||
private ArrayList<PlaceHolder<VotingPluginUser>> placeholders = new ArrayList<>();
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<>();
|
||||
|
||||
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<>();
|
||||
|
||||
@Getter
|
||||
private PlaceholderCacheLevel cacheLevel;
|
||||
|
||||
public PlaceHolders(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
onUpdate();
|
||||
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player), player.isOnline());
|
||||
public void checkNonCachedPlaceholders() {
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll().toLowerCase();
|
||||
if (toCache.startsWith("votingplugin")) {
|
||||
toCache = toCache.substring("votingplugin_".length());
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.matches(toCache)) {
|
||||
* placeholder.setUseCache(true, toCache); cachedPlaceholders.add(toCache);
|
||||
* plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
* plugin.extraDebug("Auto Caching placeholder " + toCache); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.extraDebug("Auto Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
|
||||
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
@Getter
|
||||
private PlaceholderCacheLevel cacheLevel;
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
return getPlaceHolder(p, identifier, true);
|
||||
}
|
||||
@@ -96,26 +113,32 @@ public class PlaceHolders {
|
||||
identifier = identifier.replaceAll("custom_", "");
|
||||
}
|
||||
|
||||
if (custom && plugin.getConfigFile().getCustomPlaceholderReturns().contains(identifier)) {
|
||||
String str = getPlaceholderValue(p, identifier, javascript, true, useCache);
|
||||
String returnStr = plugin.getConfigFile().getCustomPlaceholderReturns(identifier, str);
|
||||
if (!returnStr.isEmpty()) {
|
||||
return returnStr;
|
||||
}
|
||||
return str;
|
||||
} else {
|
||||
if (!custom || !plugin.getConfigFile().getCustomPlaceholderReturns().contains(identifier)) {
|
||||
return getPlaceholderValue(p, identifier, javascript, forceProcess, useCache);
|
||||
}
|
||||
String str = getPlaceholderValue(p, identifier, javascript, true, useCache);
|
||||
String returnStr = plugin.getConfigFile().getCustomPlaceholderReturns(identifier, str);
|
||||
if (!returnStr.isEmpty()) {
|
||||
return returnStr;
|
||||
}
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
|
||||
identifier = PlaceholderUtils.replaceJavascript(p, identifier);
|
||||
}
|
||||
return getPlaceHolder(p, identifier, false);
|
||||
}
|
||||
|
||||
public String getPlaceholderValue(OfflinePlayer p, String identifier, boolean javascript, boolean forceProcess,
|
||||
boolean useCache) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript && p != null) {
|
||||
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);
|
||||
@@ -157,81 +180,81 @@ public class PlaceHolders {
|
||||
}
|
||||
}
|
||||
|
||||
UUID uuid = user.getJavaUUID();
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
try {
|
||||
if (placeholder.matches(identifier)) {
|
||||
if (placeholder instanceof CalculatingPlaceholder<?>) {
|
||||
if (useCache) {
|
||||
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
if (cPlaceholder.getCacheData().containsKey(user.getJavaUUID())) {
|
||||
return cPlaceholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
return cache.get(p.getUniqueId());
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
|
||||
if (forceProcess) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
} else {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return ".";
|
||||
}
|
||||
} else {
|
||||
if (!useCache) {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(uuid)) {
|
||||
if (cPlaceholder.getCacheData().containsKey(uuid)) {
|
||||
return cPlaceholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
return cache.get(uuid);
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
|
||||
if (forceProcess) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
} else {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return ".";
|
||||
}
|
||||
}
|
||||
if (!useCache) {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
|
||||
if (cache.containsKey(uuid)) {
|
||||
return cache.get(uuid);
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
|
||||
if (forceProcess) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
} else {
|
||||
if (useCache) {
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
}
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
|
||||
if (forceProcess) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
} else {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return ".";
|
||||
}
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
return ".";
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -243,13 +266,6 @@ public class PlaceHolders {
|
||||
return "Not a valid placeholder";
|
||||
}
|
||||
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
|
||||
identifier = PlaceholderUtils.replaceJavascript(p, identifier);
|
||||
}
|
||||
return getPlaceHolder(p, identifier, false);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
placeholders.clear();
|
||||
nonPlayerPlaceholders.clear();
|
||||
@@ -352,6 +368,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) {
|
||||
@@ -487,7 +515,7 @@ public class PlaceHolders {
|
||||
return plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
|
||||
}
|
||||
long smallest = -1;
|
||||
HashMap<Long, VoteSite> times = new HashMap<Long, VoteSite>();
|
||||
HashMap<Long, VoteSite> times = new HashMap<>();
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
long t = user.voteNextDurationTime(site);
|
||||
if (smallest == -1) {
|
||||
@@ -516,9 +544,23 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get number of sites available to be voted on").updateDataKey("LastVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("SitesAvailableTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getTotalNumberOfSites();
|
||||
}
|
||||
}.withDescription("Get total number of sites available to be voted on"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
placeholders.add(new CalculatingPlaceholder<VotingPluginUser>("Next_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderDataRequest(VotingPluginUser user, String identifier) {
|
||||
long time = user.getTime(voteSite);
|
||||
return "" + time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
if (getCacheData().containsKey(user.getJavaUUID())) {
|
||||
@@ -530,12 +572,6 @@ public class PlaceHolders {
|
||||
}
|
||||
return user.voteCommandNextInfo(voteSite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String placeholderDataRequest(VotingPluginUser user, String identifier) {
|
||||
long time = user.getTime(voteSite);
|
||||
return "" + time;
|
||||
}
|
||||
}.withDescription("How long until user can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Last_" + voteSite.getKey()) {
|
||||
|
||||
@@ -573,6 +609,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 +641,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]);
|
||||
@@ -614,7 +653,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Month_Position") {
|
||||
|
||||
@@ -630,7 +669,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
}.withDescription("Get user's current top voter position"));
|
||||
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_LastMonth_Position") {
|
||||
@@ -653,7 +692,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 +729,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]);
|
||||
@@ -702,7 +741,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at position in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at position in top voter"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_MonthVotes_") {
|
||||
|
||||
@@ -741,7 +780,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]);
|
||||
@@ -753,7 +792,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at postion in top voter"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_WeekVotes_") {
|
||||
|
||||
@@ -792,7 +831,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]);
|
||||
@@ -804,7 +843,7 @@ public class PlaceHolders {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
}.useStartsWith().withDescription("Get username at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VotePartyContributedVotes") {
|
||||
|
||||
@@ -1049,7 +1088,7 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Time until plugin time month changes"));
|
||||
|
||||
Set<String> placeholdersSet = new HashSet<String>();
|
||||
Set<String> placeholdersSet = new HashSet<>();
|
||||
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
|
||||
if (getCacheLevel().equals(PlaceholderCacheLevel.AUTO)) {
|
||||
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
|
||||
@@ -1127,16 +1166,6 @@ public class PlaceHolders {
|
||||
});
|
||||
}
|
||||
|
||||
public void onVotePartyUpdate() {
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { if
|
||||
* (placeholder.getIdentifier().startsWith("VoteParty")) { for (String ident :
|
||||
* placeholder.getCache().keySet()) { placeholder.getCache().put(ident,
|
||||
* placeholder.placeholderRequest(ident)); } } } }
|
||||
*/
|
||||
}
|
||||
|
||||
public void onBungeeVotePartyUpdate() {
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
@@ -1157,6 +1186,22 @@ public class PlaceHolders {
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
checkNonCachedPlaceholders();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(p), true);
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { for (String ident :
|
||||
* placeholder.getCache().keySet()) { if (ident != null) { String str =
|
||||
* placeholder.placeholderRequest(ident); if (str != null) {
|
||||
* placeholder.getCache().put(ident, str); } } else {
|
||||
* plugin.debug("ident null: " + placeholder.getIdentifier()); } } } }
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
public void onUpdate(VotingPluginUser user, boolean login) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
@@ -1186,30 +1231,23 @@ public class PlaceHolders {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkNonCachedPlaceholders() {
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll().toLowerCase();
|
||||
if (toCache.startsWith("votingplugin")) {
|
||||
toCache = toCache.substring("votingplugin_".length());
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.matches(toCache)) {
|
||||
* placeholder.setUseCache(true, toCache); cachedPlaceholders.add(toCache);
|
||||
* plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
* plugin.extraDebug("Auto Caching placeholder " + toCache); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.extraDebug("Auto Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
public void onVotePartyUpdate() {
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { if
|
||||
* (placeholder.getIdentifier().startsWith("VoteParty")) { for (String ident :
|
||||
* placeholder.getCache().keySet()) { placeholder.getCache().put(ident,
|
||||
* placeholder.placeholderRequest(ident)); } } } }
|
||||
*/
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
onUpdate();
|
||||
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player), player.isOnline());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,20 +1261,4 @@ public class PlaceHolders {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
checkNonCachedPlaceholders();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(p), true);
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { for (String ident :
|
||||
* placeholder.getCache().keySet()) { if (ident != null) { String str =
|
||||
* placeholder.placeholderRequest(ident); if (str != null) {
|
||||
* placeholder.getCache().put(ident, str); } } else {
|
||||
* plugin.debug("ident null: " + placeholder.getIdentifier()); } } } }
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -13,10 +13,7 @@ public enum PlaceholderCacheLevel {
|
||||
}
|
||||
|
||||
public boolean onlineOnly() {
|
||||
if (this == AUTOALL) {
|
||||
return false;
|
||||
}
|
||||
if (this == SPECIFICALL) {
|
||||
if ((this == AUTOALL) || (this == SPECIFICALL)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
+5
-5
@@ -29,13 +29,13 @@ public class VotingPluginExpansion extends PlaceholderExpansion {
|
||||
return "1.6";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(OfflinePlayer p, String indendifier) {
|
||||
return plugin.getPlaceholders().getPlaceHolder(p, indendifier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+10
-3
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -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
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
public enum BungeeMethod {
|
||||
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
public class BungeeVersion {
|
||||
public static int getPluginMessageVersion() {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+120
@@ -0,0 +1,120 @@
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
|
||||
public class VotingPluginProxyCommand {
|
||||
private VotingPluginProxy plugin;
|
||||
|
||||
public VotingPluginProxyCommand(VotingPluginProxy plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the command and return a message as a String.
|
||||
*
|
||||
* @param args Command arguments
|
||||
* @return The resulting message to send
|
||||
*/
|
||||
public String execute(String[] args) {
|
||||
if (args.length == 0)
|
||||
return "&cPlease provide a valid command. Use 'help' to view all commands.";
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "reload":
|
||||
plugin.reloadCore(false);
|
||||
return "&aReloading VotingPlugin";
|
||||
|
||||
case "reloadmysql":
|
||||
plugin.reloadCore(true);
|
||||
return "&aReloading VotingPlugin including MySQL";
|
||||
|
||||
case "vote":
|
||||
if (args.length >= 3) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
plugin.vote(user, site, false, true, 0, null, null);
|
||||
return "&aVote sent for " + user + " on " + site;
|
||||
}
|
||||
return "&cUsage: vote <player> <site>";
|
||||
|
||||
case "forcetimechange":
|
||||
if (args.length >= 2) {
|
||||
plugin.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
|
||||
return "&aTriggered time change to " + args[1];
|
||||
}
|
||||
return "&cUsage: forcetimechange <TimeType>";
|
||||
|
||||
case "status":
|
||||
return handleStatusCommand();
|
||||
|
||||
case "multiproxystatus":
|
||||
plugin.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
|
||||
return "&aSent status message across multi-proxy";
|
||||
|
||||
case "help":
|
||||
return getHelpMessage();
|
||||
|
||||
case "voteparty":
|
||||
return handleVotePartyCommand(args);
|
||||
|
||||
default:
|
||||
return "&cUnknown command. Use 'help' to view all commands.";
|
||||
}
|
||||
}
|
||||
|
||||
private String handleStatusCommand() {
|
||||
BungeeMethod method = plugin.getMethod();
|
||||
switch (method) {
|
||||
case SOCKETS:
|
||||
plugin.status();
|
||||
return "&aChecking status via sockets. Check console for details.";
|
||||
|
||||
case PLUGINMESSAGING:
|
||||
case REDIS:
|
||||
plugin.status();
|
||||
plugin.sendServerNameMessage();
|
||||
return "&aChecking status with method: " + method.toString().toLowerCase();
|
||||
|
||||
default:
|
||||
return "&cStatus command unavailable for the current connection method.";
|
||||
}
|
||||
}
|
||||
|
||||
private String handleVotePartyCommand(String[] args) {
|
||||
if (args.length > 1) {
|
||||
if ("force".equalsIgnoreCase(args[1])) {
|
||||
plugin.setCurrentVotePartyVotes(plugin.getCurrentVotePartyVotesRequired());
|
||||
plugin.checkVoteParty();
|
||||
return "&aVote party forced";
|
||||
} else if ("setvotecount".equalsIgnoreCase(args[1]) && args.length > 2 && isInt(args[2])) {
|
||||
plugin.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
|
||||
return "&aSet current vote party votes to " + args[2];
|
||||
} else {
|
||||
return "&cInvalid usage. Use 'help' for correct syntax.";
|
||||
}
|
||||
}
|
||||
return "&cUsage: voteparty <force/setvotecount>";
|
||||
}
|
||||
|
||||
private String getHelpMessage() {
|
||||
StringBuilder helpBuilder = new StringBuilder("&aVotingPlugin Commands:\n");
|
||||
helpBuilder.append("/votingplugin reload - Reload the plugin\n");
|
||||
helpBuilder.append("/votingplugin reloadmysql - Reload the plugin including MySQL\n");
|
||||
helpBuilder.append("/votingplugin vote <player> <site> - Send a vote\n");
|
||||
helpBuilder.append("/votingplugin forcetimechange <TimeType> - Force a time change\n");
|
||||
helpBuilder.append("/votingplugin status - Check connection status\n");
|
||||
helpBuilder.append("/votingplugin multiproxystatus - Send status message across proxies\n");
|
||||
helpBuilder.append("/votingplugin voteparty <force/setvotecount> - Trigger or modify vote party\n");
|
||||
return helpBuilder.toString();
|
||||
}
|
||||
|
||||
private boolean isInt(String str) {
|
||||
try {
|
||||
Integer.parseInt(str);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package com.bencodez.votingplugin.proxy;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface VotingPluginProxyConfig {
|
||||
|
||||
public boolean getAllowUnJoined();
|
||||
|
||||
public String getBedrockPlayerPrefix();
|
||||
|
||||
public List<String> getBlockedServers();
|
||||
|
||||
public boolean getBroadcast();
|
||||
|
||||
public String getBungeeHost();
|
||||
|
||||
public boolean getBungeeManageTotals();
|
||||
|
||||
public String getBungeeMethod();
|
||||
|
||||
public int getBungeePort();
|
||||
|
||||
public String getPluginMessageChannel();
|
||||
|
||||
public boolean getPluginMessageEncryption();
|
||||
|
||||
public boolean getDebug();
|
||||
|
||||
public String getFallBack();
|
||||
|
||||
public boolean getGlobalDataEnabled();
|
||||
|
||||
public boolean getGlobalDataUseMainMySQL();
|
||||
|
||||
public int getLimitVotePoints();
|
||||
|
||||
public int getMaxAmountOfVotesPerDay();
|
||||
|
||||
public String getMultiProxyMethod();
|
||||
|
||||
public boolean getMultiProxyOneGlobalReward();
|
||||
|
||||
public String getMultiProxyRedisHost();
|
||||
|
||||
public String getMultiProxyRedisPassword();
|
||||
|
||||
public int getMultiProxyRedisPort();
|
||||
|
||||
public boolean getMultiProxyRedisUseExistingConnection();
|
||||
|
||||
public String getMultiProxyRedisUsername();
|
||||
|
||||
public Collection<String> getMultiProxyServers();
|
||||
|
||||
public Map<String, Object> getMultiProxyServersConfiguration(String s);
|
||||
|
||||
public String getMultiProxySocketHostHost();
|
||||
|
||||
public int getMultiProxySocketHostPort();
|
||||
|
||||
public boolean getMultiProxySupport();
|
||||
|
||||
public boolean getOnlineMode();
|
||||
|
||||
public int getPointsOnVote();
|
||||
|
||||
public boolean getPrimaryServer();
|
||||
|
||||
public String getProxyServerName();
|
||||
|
||||
public List<String> getProxyServers();
|
||||
|
||||
public String getRedisHost();
|
||||
|
||||
public String getRedisPassword();
|
||||
|
||||
public int getRedisPort();
|
||||
|
||||
public String getRedisPrefix();
|
||||
|
||||
public String getRedisUsername();
|
||||
|
||||
public boolean getSendVotesToAllServers();
|
||||
|
||||
public Map<String, Object> getSpigotServerConfiguration(String s);
|
||||
|
||||
public Collection<String> getSpigotServers();
|
||||
|
||||
public boolean getStoreMonthTotalsWithDate();
|
||||
|
||||
public boolean getTimeChangeFailSafeBypass();
|
||||
|
||||
public int getTimeHourOffSet();
|
||||
|
||||
public String getTimeZone();
|
||||
|
||||
public boolean getUseMonthDateTotalsAsPrimaryTotal();
|
||||
|
||||
public boolean getUUIDLookup();
|
||||
|
||||
public int getVoteCacheTime();
|
||||
|
||||
public String getVotePartyBroadcast();
|
||||
|
||||
public List<String> getVotePartyBungeeCommands();
|
||||
|
||||
public boolean getVotePartyEnabled();
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired();
|
||||
|
||||
public boolean getVotePartySendToAllServers();
|
||||
|
||||
public List<String> getVotePartyServersToSend();
|
||||
|
||||
public int getVotePartyVotesRequired();
|
||||
|
||||
public boolean getWaitForUserOnline();
|
||||
|
||||
public List<String> getWhiteListedServers();
|
||||
|
||||
public void load();
|
||||
|
||||
public void save();
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
+170
-128
@@ -1,18 +1,22 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class Config {
|
||||
public class Config implements VotingPluginProxyConfig {
|
||||
private VotingPluginBungee bungee;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
@@ -21,60 +25,28 @@ public class Config {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public String getRedisHost() {
|
||||
return getData().getString("Redis.Host", "");
|
||||
}
|
||||
|
||||
public int getRedisPort() {
|
||||
return getData().getInt("Redis.Port", 6379);
|
||||
}
|
||||
|
||||
public String getRedisUsername() {
|
||||
return getData().getString("Redis.Username", "");
|
||||
}
|
||||
|
||||
public String getRedisPrefix() {
|
||||
return getData().getString("Redis.Prefix", "");
|
||||
}
|
||||
|
||||
public String getRedisPassword() {
|
||||
return getData().getString("Redis.Password", "");
|
||||
public Map<String, Object> configToMap(Configuration config) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
if (config != null) {
|
||||
config.getKeys().forEach(key -> map.put(key, config.get(key)));
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getData().getBoolean("AllowUnJoined", false);
|
||||
}
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getData().getStringList("BlockedServers");
|
||||
}
|
||||
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getData().getStringList("WhiteListedServers");
|
||||
}
|
||||
|
||||
public boolean getBroadcast() {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public String getBedrockPlayerPrefix() {
|
||||
return getData().getString("BedrockPlayerPrefix", ".");
|
||||
}
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
return getData().getBoolean("OnlineMode", true);
|
||||
public List<String> getBlockedServers() {
|
||||
return getData().getStringList("BlockedServers");
|
||||
}
|
||||
|
||||
public boolean getUUIDLookup() {
|
||||
return getData().getBoolean("UUIDLookup", true);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getData().getBoolean("GlobalData.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getData().getBoolean("GlobalData.UseMainMySQL", true);
|
||||
public boolean getBroadcast() {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
@@ -93,98 +65,90 @@ public class Config {
|
||||
return getData().getInt("BungeeServer.Port", 1297);
|
||||
}
|
||||
|
||||
public int getLimitVotePoints() {
|
||||
return getData().getInt("LimitVotePoints", -1);
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return getData().getBoolean("Debug", false);
|
||||
}
|
||||
|
||||
public boolean getMultiProxySupport() {
|
||||
return getData().getBoolean("MultiProxySupport", false);
|
||||
}
|
||||
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getData().getInt("MaxAmountOfVotesPerDay", -1);
|
||||
}
|
||||
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return getData().getInt("MultiProxySocketHost.Port", 1297);
|
||||
}
|
||||
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return getData().getString("MultiProxySocketHost.Host", "");
|
||||
}
|
||||
|
||||
public boolean getMultiProxyOneGlobalReward() {
|
||||
return getData().getBoolean("MultiProxyOneGlobalReward", false);
|
||||
}
|
||||
|
||||
public Configuration getMultiProxyServersConfiguration(String s) {
|
||||
return getData().getSection("MultiProxyServers." + s);
|
||||
}
|
||||
|
||||
public Collection<String> getMultiProxyServers() {
|
||||
return getData().getSection("MultiProxyServers").getKeys();
|
||||
}
|
||||
|
||||
public boolean getPrimaryServer() {
|
||||
return getData().getBoolean("PrimaryServer", false);
|
||||
}
|
||||
|
||||
public String getFallBack() {
|
||||
return getData().getString("FallBackServer", "");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getData().getBoolean("GlobalData.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getData().getBoolean("SendVotesToAllServers");
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getData().getBoolean("GlobalData.UseMainMySQL", true);
|
||||
}
|
||||
|
||||
public Configuration getSpigotServerConfiguration(String s) {
|
||||
return getData().getSection("SpigotServers." + s);
|
||||
public int getLimitVotePoints() {
|
||||
return getData().getInt("LimitVotePoints", -1);
|
||||
}
|
||||
|
||||
public Collection<String> getSpigotServers() {
|
||||
return getData().getSection("SpigotServers").getKeys();
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getData().getBoolean("VoteParty.SendToAllServers", true);
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired", 100);
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
|
||||
}
|
||||
|
||||
public int getVoteCacheTime() {
|
||||
return getData().getInt("VoteCacheTime", -1);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getData().getInt("MaxAmountOfVotesPerDay", -1);
|
||||
}
|
||||
|
||||
public String getMultiProxyMethod() {
|
||||
return getData().getString("MultiProxyMethod", "SOCKET");
|
||||
}
|
||||
|
||||
public boolean getMultiProxyOneGlobalReward() {
|
||||
return getData().getBoolean("MultiProxyOneGlobalReward", false);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getData().getString("MultiProxyRedis.Host", "");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getData().getString("MultiProxyRedis.Password", "");
|
||||
}
|
||||
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getData().getInt("MultiProxyRedis.Port", 6379);
|
||||
}
|
||||
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getData().getBoolean("MultiProxyRedis.UseExistingConnection", false);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getData().getString("MultiProxyRedis.Username", "");
|
||||
}
|
||||
|
||||
public Collection<String> getMultiProxyServers() {
|
||||
return getData().getSection("MultiProxyServers").getKeys();
|
||||
}
|
||||
|
||||
public Map<String, Object> getMultiProxyServersConfiguration(String s) {
|
||||
return configToMap(getData().getSection("MultiProxyServers." + s));
|
||||
}
|
||||
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return getData().getString("MultiProxySocketHost.Host", "");
|
||||
}
|
||||
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return getData().getInt("MultiProxySocketHost.Port", 1297);
|
||||
}
|
||||
|
||||
public boolean getMultiProxySupport() {
|
||||
return getData().getBoolean("MultiProxySupport", false);
|
||||
}
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
return getData().getBoolean("OnlineMode", true);
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
|
||||
public boolean getPrimaryServer() {
|
||||
return getData().getBoolean("PrimaryServer", false);
|
||||
}
|
||||
|
||||
public String getProxyServerName() {
|
||||
return getData().getString("ProxyServerName", "SOCKET");
|
||||
}
|
||||
@@ -193,32 +157,100 @@ public class Config {
|
||||
return getData().getStringList("ProxyServers");
|
||||
}
|
||||
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getData().getBoolean("MultiProxyRedis.UseExistingConnection", false);
|
||||
public String getRedisHost() {
|
||||
return getData().getString("Redis.Host", "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
public String getRedisPassword() {
|
||||
return getData().getString("Redis.Password", "");
|
||||
}
|
||||
|
||||
public int getRedisPort() {
|
||||
return getData().getInt("Redis.Port", 6379);
|
||||
}
|
||||
|
||||
public String getRedisPrefix() {
|
||||
return getData().getString("Redis.Prefix", "");
|
||||
}
|
||||
|
||||
public String getRedisUsername() {
|
||||
return getData().getString("Redis.Username", "");
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getData().getBoolean("SendVotesToAllServers");
|
||||
}
|
||||
|
||||
public Map<String, Object> getSpigotServerConfiguration(String s) {
|
||||
return configToMap(getData().getSection("SpigotServers." + s));
|
||||
}
|
||||
|
||||
public Collection<String> getSpigotServers() {
|
||||
return getData().getSection("SpigotServers").getKeys();
|
||||
}
|
||||
|
||||
public boolean getStoreMonthTotalsWithDate() {
|
||||
return getData().getBoolean("StoreMonthTotalsWithDate", false);
|
||||
}
|
||||
|
||||
public boolean getTimeChangeFailSafeBypass() {
|
||||
return getData().getBoolean("TimeChangeFailSafeBypass", false);
|
||||
}
|
||||
|
||||
public int getTimeHourOffSet() {
|
||||
return getData().getInt("TimeHourOffSet");
|
||||
}
|
||||
|
||||
public String getTimeZone() {
|
||||
return getData().getString("TimeZone", "");
|
||||
}
|
||||
|
||||
public boolean getUseMonthDateTotalsAsPrimaryTotal() {
|
||||
return getData().getBoolean("UseMonthDateTotalsAsPrimaryTotal", false);
|
||||
}
|
||||
|
||||
public boolean getUUIDLookup() {
|
||||
return getData().getBoolean("UUIDLookup", true);
|
||||
}
|
||||
|
||||
public int getVoteCacheTime() {
|
||||
return getData().getInt("VoteCacheTime", -1);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getData().getStringList("VoteParty.BungeeCommands");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getData().getString("MultiProxyRedis.Host", "");
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled", false);
|
||||
}
|
||||
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getData().getInt("MultiProxyRedis.Port", 6379);
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getData().getString("MultiProxyRedis.Username", "");
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getData().getBoolean("VoteParty.SendToAllServers", true);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getData().getString("MultiProxyRedis.Password", "");
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired", 100);
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getData().getStringList("WhiteListedServers");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -252,4 +284,14 @@ public class Config {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginMessageChannel() {
|
||||
return getData().getString("PluginMessageChannel", "vp:vp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPluginMessageEncryption() {
|
||||
return getData().getBoolean("PluginMessageEncryption", false);
|
||||
}
|
||||
|
||||
}
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bencodez.simpleapi.file.BungeeJsonFile;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
public class NonVotedPlayersCache extends BungeeJsonFile {
|
||||
private VotingPluginBungee plugin;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
|
||||
public NonVotedPlayersCache(VotingPluginBungee plugin) {
|
||||
super(new File(plugin.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
if (!plugin.getVotingPluginProxy().getProxyMySQL().containsKeyQuery(player.getUniqueId().toString())) {
|
||||
addPlayer(player.getUniqueId().toString(), player.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayer(String uuid, String playerName) {
|
||||
setString("NonVotedPlayers." + playerName + ".UUID", uuid);
|
||||
setLong("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
|
||||
save();
|
||||
}
|
||||
|
||||
public void addPlayerCheck(String uuid, String playerName) {
|
||||
if (!plugin.getVotingPluginProxy().getProxyMySQL().containsKeyQuery(uuid)) {
|
||||
addPlayer(uuid, playerName);
|
||||
}
|
||||
}
|
||||
|
||||
public void check() {
|
||||
for (String player : getKeys("NonVotedPlayers")) {
|
||||
long time = getLong("NonVotedPlayers." + player + ".LastTime", 0);
|
||||
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
|
||||
removePlayer(player);
|
||||
} else {
|
||||
String uuid = getString("NonVotedPlayers." + player + ".UUID", "");
|
||||
if (!uuid.isEmpty()) {
|
||||
if (plugin.getVotingPluginProxy().getProxyMySQL().containsKeyQuery(uuid)) {
|
||||
removePlayer(player);
|
||||
}
|
||||
} else {
|
||||
removePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
public String playerExists(String playerName) {
|
||||
String uuid = getString("NonVotedPlayers." + playerName + ".UUID", "");
|
||||
if (!uuid.isEmpty()) {
|
||||
return uuid;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void removePlayer(String player) {
|
||||
plugin.debug("Removing nonvotedplayer: " + player);
|
||||
remove("NonVotedPlayers." + player);
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.simpleapi.file.BungeeJsonFile;
|
||||
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
public class VoteCache extends BungeeJsonFile {
|
||||
private VotingPluginBungee bungee;
|
||||
|
||||
public VoteCache(VotingPluginBungee bungee) {
|
||||
super(new File(bungee.getDataFolder(), "votecache.json"));
|
||||
this.bungee = bungee;
|
||||
initialize();
|
||||
}
|
||||
|
||||
private void initialize() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
// Reload the JSON file to ensure latest data
|
||||
reload();
|
||||
}
|
||||
|
||||
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
|
||||
String path = "TimedVoteCache." + num;
|
||||
setString(path + ".Name", voteTimedQueue.getName());
|
||||
setString(path + ".Service", voteTimedQueue.getService());
|
||||
setLong(path + ".Time", voteTimedQueue.getTime());
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
String path = "VoteCache." + server + "." + num;
|
||||
setString(path + ".Name", voteData.getPlayerName());
|
||||
setString(path + ".Service", voteData.getService());
|
||||
setString(path + ".UUID", voteData.getUuid());
|
||||
setLong(path + ".Time", voteData.getTime());
|
||||
setBoolean(path + ".Real", voteData.isRealVote());
|
||||
setString(path + ".Text", voteData.getText());
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
String path = "OnlineCache." + player + "." + num;
|
||||
setString(path + ".Name", voteData.getPlayerName());
|
||||
setString(path + ".Service", voteData.getService());
|
||||
setString(path + ".UUID", voteData.getUuid());
|
||||
setLong(path + ".Time", voteData.getTime());
|
||||
setBoolean(path + ".Real", voteData.isRealVote());
|
||||
setString(path + ".Text", voteData.getText());
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
setString("VoteCache", null);
|
||||
setString("OnlineCache", null);
|
||||
setString("TimedVoteCache", null);
|
||||
save();
|
||||
}
|
||||
|
||||
public Collection<String> getOnlineVotes(String name) {
|
||||
return getKeys("OnlineCache." + name);
|
||||
}
|
||||
|
||||
public JsonElement getOnlineVotes(String name, String num) {
|
||||
return getNode("OnlineCache." + name + "." + num);
|
||||
}
|
||||
|
||||
public Collection<String> getPlayers() {
|
||||
return getKeys("OnlineCache");
|
||||
}
|
||||
|
||||
public Collection<String> getServers() {
|
||||
return getKeys("VoteCache");
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getKeys("VoteCache." + server);
|
||||
}
|
||||
|
||||
public JsonElement getServerVotes(String server, String num) {
|
||||
return getNode("VoteCache." + server + "." + num);
|
||||
}
|
||||
|
||||
public Collection<String> getTimedVoteCache() {
|
||||
return getKeys("TimedVoteCache");
|
||||
}
|
||||
|
||||
public JsonElement getTimedVoteCache(String key) {
|
||||
return getNode("TimedVoteCache." + key);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getInt("VoteParty.Cache." + server, 0);
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getInt("VoteParty.CurrentVotes", 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getInt("VoteParty.IncreaseVotes", 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
setInt("VoteParty.Cache." + server, amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
setInt("VoteParty.CurrentVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
setInt("VoteParty.IncreaseVotes", amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
super.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
super.reload();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import com.vexsoftware.votifier.bungee.events.VotifierEvent;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
@@ -28,7 +28,7 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
|
||||
vote.setServiceName(serviceSite);
|
||||
}
|
||||
|
||||
plugin.vote(vote.getUsername(), serviceSite, true, true, 0, null, null);
|
||||
plugin.getVotingPluginProxy().vote(vote.getUsername(), serviceSite, true, true, 0, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
+863
@@ -0,0 +1,863 @@
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.CodeSource;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.mysql.BungeeMySQL;
|
||||
import com.bencodez.simpleapi.sql.DataType;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigBungee;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeVersion;
|
||||
import com.bencodez.votingplugin.proxy.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxy;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyConfig;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
@Getter
|
||||
private Config config;
|
||||
|
||||
private NonVotedPlayersCache nonVotedPlayersCache;
|
||||
|
||||
private VoteCache voteCacheFile;
|
||||
|
||||
private String buildNumber = "NOTSET";
|
||||
|
||||
private VoteEventBungee voteEventBungee;
|
||||
|
||||
@Getter
|
||||
private VotingPluginProxy votingPluginProxy;
|
||||
|
||||
public void debug(String msg) {
|
||||
if (config.getDebug()) {
|
||||
getLogger().info("Debug: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
public void debug2(String msg) {
|
||||
debug(msg);
|
||||
}
|
||||
|
||||
public Set<String> getAvailableAllServers() {
|
||||
Set<String> servers = new HashSet<>();
|
||||
if (config.getWhiteListedServers().isEmpty()) {
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
servers.add(s);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
servers.addAll(config.getWhiteListedServers());
|
||||
}
|
||||
|
||||
return servers;
|
||||
}
|
||||
|
||||
public String getProperPlayerName(String uuid, String currentName) {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if (p != null && p.isConnected()) {
|
||||
return p.getName();
|
||||
}
|
||||
return currentName;
|
||||
}
|
||||
|
||||
private Configuration getVersionFile() {
|
||||
try {
|
||||
CodeSource src = this.getClass().getProtectionDomain().getCodeSource();
|
||||
if (src != null) {
|
||||
URL jar = src.getLocation();
|
||||
ZipInputStream zip = null;
|
||||
zip = new ZipInputStream(jar.openStream());
|
||||
while (true) {
|
||||
ZipEntry e = zip.getNextEntry();
|
||||
if (e != null) {
|
||||
String name = e.getName();
|
||||
if (name.equals("votingpluginversion.yml")) {
|
||||
Reader defConfigStream = new InputStreamReader(zip);
|
||||
if (defConfigStream != null) {
|
||||
Configuration conf = ConfigurationProvider
|
||||
.getProvider(net.md_5.bungee.config.YamlConfiguration.class)
|
||||
.load(defConfigStream);
|
||||
|
||||
defConfigStream.close();
|
||||
return conf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isOnline(ProxiedPlayer p) {
|
||||
if (p != null) {
|
||||
return p.isConnected();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
votingPluginProxy
|
||||
.setProxyMySQL(new BungeeMySQL(this, "VotingPlugin_Users", config.getData(), config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<String> servers = new ArrayList<>();
|
||||
for (String s : getAvailableAllServers()) {
|
||||
servers.add(s);
|
||||
}
|
||||
|
||||
if (config.getGlobalDataEnabled()) {
|
||||
if (config.getGlobalDataUseMainMySQL()) {
|
||||
votingPluginProxy.setGlobalDataHandler(new GlobalDataHandlerProxy(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", getVotingPluginProxy().getProxyMySQL().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void debugEx(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
getLogger().info(text);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
getLogger().warning(text);
|
||||
}
|
||||
}, servers) {
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, type.toString(), false);
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "FinishedProcessing", true);
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "Processing", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getVotingPluginProxy().getProxyMySQL().copyColumnData(TopVoter.Monthly.getColumnName(),
|
||||
"LastMonthTotal");
|
||||
}
|
||||
getVotingPluginProxy().getProxyMySQL().wipeColumnData(TopVoter.of(type).getColumnName(),
|
||||
DataType.INTEGER);
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
}
|
||||
for (String s : getAvailableAllServers()) {
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(s, "ForceUpdate", true);
|
||||
if (getVotingPluginProxy().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
getVotingPluginProxy().sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (getVotingPluginProxy().getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
getVotingPluginProxy().sendServerMessage(s, "BungeeTimeChange");
|
||||
}
|
||||
}
|
||||
|
||||
getVotingPluginProxy().processQueue();
|
||||
|
||||
}
|
||||
});
|
||||
} else {
|
||||
votingPluginProxy
|
||||
.setGlobalDataHandler(new GlobalDataHandlerProxy(new GlobalMySQL("VotingPlugin_GlobalData",
|
||||
new MysqlConfigBungee(config.getData().getSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void debugEx(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
getLogger().info(text);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
getLogger().warning(text);
|
||||
}
|
||||
}, servers) {
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, type.toString(),
|
||||
false);
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "FinishedProcessing",
|
||||
true);
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(server, "Processing", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getVotingPluginProxy().getProxyMySQL()
|
||||
.copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getVotingPluginProxy().getProxyMySQL().wipeColumnData(TopVoter.of(type).getColumnName(),
|
||||
DataType.INTEGER);
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
}
|
||||
for (String s : getAvailableAllServers()) {
|
||||
getVotingPluginProxy().getGlobalDataHandler().setBoolean(s, "ForceUpdate", true);
|
||||
if (getVotingPluginProxy().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
getVotingPluginProxy().sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (getVotingPluginProxy().getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
getVotingPluginProxy().sendServerMessage(s, "BungeeTimeChange");
|
||||
}
|
||||
}
|
||||
|
||||
getVotingPluginProxy().processQueue();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("FinishedProcessing",
|
||||
"VARCHAR(5)");
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getGlobalDataHandler().getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
}
|
||||
|
||||
// column types
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("Reminded", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("DisableBroadcast", "VARCHAR(5)");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastOnline", "VARCHAR(20)");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("PlayerName", "VARCHAR(30)");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("DailyTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("WeeklyTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("DayVoteStreak", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("BestDayVoteStreak", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("WeekVoteStreak", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("BestWeekVoteStreak", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("VotePartyVotes", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("MonthVoteStreak", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("Points", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("HighestDailyTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("AllTimeTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("HighestMonthlyTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("MilestoneCount", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastWeeklyTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("OfflineRewards", "MEDIUMTEXT");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
|
||||
if (config.getStoreMonthTotalsWithDate()) {
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType(
|
||||
getVotingPluginProxy().getMonthTotalsWithDatePath(LocalDateTime.now()), "INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType(
|
||||
getVotingPluginProxy().getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(1)),
|
||||
"INT DEFAULT '0'");
|
||||
getVotingPluginProxy().getProxyMySQL().alterColumnType(
|
||||
getVotingPluginProxy().getMonthTotalsWithDatePath(LocalDateTime.now().plusMonths(2)),
|
||||
"INT DEFAULT '0'");
|
||||
}
|
||||
}
|
||||
|
||||
public void loadVersionFile() {
|
||||
Configuration conf = getVersionFile();
|
||||
if (conf != null) {
|
||||
buildNumber = conf.get("buildnumber", "NOTSET");
|
||||
}
|
||||
}
|
||||
|
||||
public void login(ProxiedPlayer p) {
|
||||
if (p != null && p.getServer() != null && p.getServer().getInfo() != null) {
|
||||
final ProxiedPlayer proxiedPlayer = p;
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
getVotingPluginProxy().login(proxiedPlayer.getName(), proxiedPlayer.getUniqueId().toString(),
|
||||
proxiedPlayer.getServer().getInfo().getName());
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (getVotingPluginProxy().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
getLogger().info("VotingPlugin saving vote cache: " + getVotingPluginProxy().getCachedVotes().size() + "/"
|
||||
+ getVotingPluginProxy().getCachedOnlineVotes().size());
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : getVotingPluginProxy().getCachedVotes()
|
||||
.entrySet()) {
|
||||
String server = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVote(server, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : getVotingPluginProxy().getCachedOnlineVotes()
|
||||
.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!getVotingPluginProxy().getTimeChangeQueue().isEmpty()) {
|
||||
int num = 0;
|
||||
for (VoteTimeQueue vote : getVotingPluginProxy().getTimeChangeQueue()) {
|
||||
voteCacheFile.addTimedVote(num, vote);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
getVotingPluginProxy().onDisable();
|
||||
|
||||
voteCacheFile.save();
|
||||
nonVotedPlayersCache.save();
|
||||
|
||||
getLogger().info("VotingPlugin disabled");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
|
||||
config = new Config(this);
|
||||
config.load();
|
||||
|
||||
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
|
||||
|
||||
votingPluginProxy = new VotingPluginProxy() {
|
||||
|
||||
@Override
|
||||
public void addNonVotedPlayer(String uuid, String playerName) {
|
||||
nonVotedPlayersCache.addPlayer(uuid, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void broadcast(String message) {
|
||||
getProxy().broadcast(new TextComponent(ChatColor.translateAlternateColorCodes('&', message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String str) {
|
||||
debug2(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getAllAvailableServers() {
|
||||
return getAvailableAllServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VotingPluginProxyConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentPlayerServer(String player) {
|
||||
return getProxy().getPlayer(player).getServer().getInfo().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getDataFolderPlugin() {
|
||||
return getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProperName(String uuid, String playerName) {
|
||||
return getProperPlayerName(uuid, playerName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUUID(String playerName) {
|
||||
|
||||
if (!config.getOnlineMode()) {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(StandardCharsets.UTF_8))
|
||||
.toString();
|
||||
}
|
||||
ProxiedPlayer p = getProxy().getPlayer(playerName);
|
||||
if (p != null && p.isConnected()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
|
||||
for (Entry<UUID, String> entry : getVotingPluginProxy().getUuidPlayerNameCache().entrySet()) {
|
||||
if (entry.getValue().equalsIgnoreCase(playerName)) {
|
||||
return entry.getKey().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (getVotingPluginProxy().getProxyMySQL() != null) {
|
||||
String str = getVotingPluginProxy().getProxyMySQL().getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginVersion() {
|
||||
return getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheCurrentVotePartyVotes() {
|
||||
return voteCacheFile.getVotePartyCurrentVotes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getVoteCacheLastUpdated() {
|
||||
return voteCacheFile.getLong("Time.LastUpdated", 0L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCachePrevDay() {
|
||||
return voteCacheFile.getInt("Time.Day", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVoteCachePrevMonth() {
|
||||
return voteCacheFile.getString("Time.Month", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCachePrevWeek() {
|
||||
return voteCacheFile.getInt("Time.Week", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getVoteCacheVotePartyIncreaseVotesRequired() {
|
||||
return voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
ProxiedPlayer player = getProxy().getPlayer(playerName);
|
||||
return player != null && player.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isServerValid(String server) {
|
||||
return getProxy().getServerInfo(server) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSomeoneOnlineServer(String server) {
|
||||
return !getProxy().getServerInfo(server).getPlayers().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVoteCacheIgnoreTime() {
|
||||
return voteCacheFile.getBoolean("Time.IgnoreTime", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
getLogger().info(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String message) {
|
||||
getLogger().severe(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsync(Runnable run) {
|
||||
runAsyncNow(run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runConsoleCommand(String command) {
|
||||
getProxy().getPluginManager().dispatchCommand(getProxy().getConsole(), command);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveVoteCacheFile() {
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendPluginMessageData(String server, String channel, byte[] data, boolean queue) {
|
||||
getProxy().getServerInfo(server).sendData(channel, data, queue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheLastUpdated() {
|
||||
voteCacheFile.setLong("Time.LastUpdated", System.currentTimeMillis());
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevDay(int day) {
|
||||
voteCacheFile.setInt("Time.Day", day);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevMonth(String text) {
|
||||
voteCacheFile.setString("Time.Month", text);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCachePrevWeek(int week) {
|
||||
voteCacheFile.setInt("Time.Week", week);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVoteCacheIgnoreTime(boolean ignore) {
|
||||
voteCacheFile.setBoolean("Time.IgnoreTime", ignore);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVotePartyCurrentVotes(int votes) {
|
||||
voteCacheFile.setVotePartyCurrentVotes(votes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVoteCacheVotePartyIncreaseVotesRequired(int votes) {
|
||||
voteCacheFile.setVotePartyInreaseVotesRequired(votes);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warn(String message) {
|
||||
getLogger().warning(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadCore(boolean mysql) {
|
||||
reloadPlugin(mysql);
|
||||
}
|
||||
|
||||
};
|
||||
try {
|
||||
Class.forName("com.vexsoftware.votifier.bungee.events.VotifierEvent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
getVotingPluginProxy().setVotifierEnabled(false);
|
||||
}
|
||||
if (getVotingPluginProxy().isVotifierEnabled()) {
|
||||
try {
|
||||
voteEventBungee = new VoteEventBungee(this);
|
||||
getProxy().getPluginManager().registerListener(this, voteEventBungee);
|
||||
} catch (Exception e) {
|
||||
getVotingPluginProxy().setVotifierEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean mysqlLoaded = true;
|
||||
try {
|
||||
if (!config.getData().getString("Host", "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
mysqlLoaded = false;
|
||||
getLogger().severe("MySQL settings not set in bungeeconfig.yml");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mysqlLoaded = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
this.getProxy().registerChannel(getConfig().getPluginMessageChannel());
|
||||
|
||||
if (mysqlLoaded) {
|
||||
|
||||
voteCacheFile = new VoteCache(this);
|
||||
// voteCacheFile.load();
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(this);
|
||||
// nonVotedPlayersCache.load();
|
||||
|
||||
getVotingPluginProxy().load();
|
||||
|
||||
try {
|
||||
for (String key : voteCacheFile.getTimedVoteCache()) {
|
||||
JsonElement dataElement = voteCacheFile.getTimedVoteCache(key);
|
||||
|
||||
if (dataElement != null && dataElement.isJsonObject()) {
|
||||
JsonObject data = dataElement.getAsJsonObject();
|
||||
String name = data.has("Name") ? data.get("Name").getAsString() : "";
|
||||
String service = data.has("Service") ? data.get("Service").getAsString() : "";
|
||||
long time = data.has("Time") ? data.get("Time").getAsLong() : 0L;
|
||||
|
||||
getVotingPluginProxy().getTimeChangeQueue().add(new VoteTimeQueue(name, service, time));
|
||||
}
|
||||
}
|
||||
|
||||
getVotingPluginProxy().processQueue();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
for (String server : voteCacheFile.getServers()) {
|
||||
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
|
||||
for (String num : voteCacheFile.getServerVotes(server)) {
|
||||
JsonElement dataElement = voteCacheFile.getServerVotes(server, num);
|
||||
|
||||
if (dataElement != null && dataElement.isJsonObject()) {
|
||||
JsonObject data = dataElement.getAsJsonObject();
|
||||
|
||||
String name = data.has("Name") ? data.get("Name").getAsString() : "";
|
||||
String uuid = data.has("UUID") ? data.get("UUID").getAsString() : "";
|
||||
String service = data.has("Service") ? data.get("Service").getAsString() : "";
|
||||
long time = data.has("Time") ? data.get("Time").getAsLong() : 0L;
|
||||
boolean real = data.has("Real") && data.get("Real").getAsBoolean();
|
||||
String text = data.has("Text") ? data.get("Text").getAsString() : "";
|
||||
|
||||
votes.add(new OfflineBungeeVote(name, uuid, service, time, real, text));
|
||||
}
|
||||
}
|
||||
getVotingPluginProxy().getCachedVotes().put(server, votes);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
for (String player : voteCacheFile.getPlayers()) {
|
||||
ArrayList<OfflineBungeeVote> votes = new ArrayList<>();
|
||||
for (String num : voteCacheFile.getOnlineVotes(player)) {
|
||||
JsonElement dataElement = voteCacheFile.getOnlineVotes(player, num);
|
||||
|
||||
if (dataElement != null && dataElement.isJsonObject()) {
|
||||
JsonObject data = dataElement.getAsJsonObject();
|
||||
|
||||
String name = data.has("Name") ? data.get("Name").getAsString() : "";
|
||||
String uuid = data.has("UUID") ? data.get("UUID").getAsString() : "";
|
||||
String service = data.has("Service") ? data.get("Service").getAsString() : "";
|
||||
long time = data.has("Time") ? data.get("Time").getAsLong() : 0L;
|
||||
boolean real = data.has("Real") && data.get("Real").getAsBoolean();
|
||||
String text = data.has("Text") ? data.get("Text").getAsString() : "";
|
||||
|
||||
votes.add(new OfflineBungeeVote(name, uuid, service, time, real, text));
|
||||
}
|
||||
}
|
||||
getLogger().info("VoteCache: " + player);
|
||||
getVotingPluginProxy().getCachedOnlineVotes().put(player, votes);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
voteCacheFile.clearData();
|
||||
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (String server : getVotingPluginProxy().getCachedVotes().keySet()) {
|
||||
getVotingPluginProxy().checkCachedVotes(server);
|
||||
}
|
||||
|
||||
for (String player : getVotingPluginProxy().getCachedOnlineVotes().keySet()) {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(player));
|
||||
if (p != null) {
|
||||
getVotingPluginProxy().checkOnlineVotes(p.getName(), player, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 120l, 60l, TimeUnit.SECONDS);
|
||||
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
debug("Checking nonvotedplayers.yml...");
|
||||
nonVotedPlayersCache.check();
|
||||
}
|
||||
if (voteCacheFile != null) {
|
||||
voteCacheFile.save();
|
||||
}
|
||||
}
|
||||
}, 1l, 60l, TimeUnit.MINUTES);
|
||||
|
||||
}
|
||||
|
||||
if (!getVotingPluginProxy().isVotifierEnabled()) {
|
||||
if (!(getConfig().getMultiProxySupport() && !getConfig().getPrimaryServer())) {
|
||||
getLogger().warning("Votifier event not found, not loading votifier event");
|
||||
}
|
||||
}
|
||||
|
||||
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("bungee_method", () -> getConfig().getBungeeMethod().toString()));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("sendtoallservers",
|
||||
() -> "" + getConfig().getSendVotesToAllServers()));
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("allowunjoined", () -> "" + getConfig().getAllowUnJoined()));
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("pointsonvote", () -> "" + getConfig().getPointsOnVote()));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("bungeemanagetotals",
|
||||
() -> "" + getConfig().getBungeeManageTotals()));
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("waitforuseronline", () -> "" + getConfig().getWaitForUserOnline()));
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("globaldata_enabled", () -> "" + getConfig().getGlobalDataEnabled()));
|
||||
if (getConfig().getGlobalDataEnabled()) {
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("globaldata_usemainmysql",
|
||||
() -> "" + getConfig().getGlobalDataUseMainMySQL()));
|
||||
}
|
||||
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("multi_proxy_support_enabled",
|
||||
() -> "" + getConfig().getMultiProxySupport()));
|
||||
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("dev_build_number", () -> "" + buildNumber));
|
||||
}
|
||||
|
||||
loadVersionFile();
|
||||
|
||||
getLogger().info("VotingPlugin loaded, using method: " + getVotingPluginProxy().getMethod().toString()
|
||||
+ ", PluginMessagingVersion: " + BungeeVersion.getPluginMessageVersion());
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
getLogger().info("Detected using dev build number: " + buildNumber);
|
||||
}
|
||||
getVotingPluginProxy().sendServerNameMessage();
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent ev) {
|
||||
if (!ev.getTag().equals(getConfig().getPluginMessageChannel().toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ev.setCancelled(true);
|
||||
|
||||
if (!(ev.getSender() instanceof Server)) {
|
||||
debug("Ignore plugin message");
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayInputStream instream = new ByteArrayInputStream(ev.getData());
|
||||
DataInputStream in = new DataInputStream(instream);
|
||||
try {
|
||||
getVotingPluginProxy().onPluginMessageReceived(in);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadPlugin(boolean loadMysql) {
|
||||
config.load();
|
||||
if (loadMysql) {
|
||||
try {
|
||||
if (!config.getData().getString("Host", "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
getLogger().severe("MySQL settings not set in bungeeconfig.yml");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
getVotingPluginProxy().reload();
|
||||
}
|
||||
|
||||
private void runAsyncNow(Runnable runnable) {
|
||||
getProxy().getScheduler().runAsync(this, runnable);
|
||||
}
|
||||
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.bencodez.votingplugin.proxy.bungee;
|
||||
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginProxyCommand;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
public class VotingPluginBungeeCommand extends Command {
|
||||
private VotingPluginBungee bungee;
|
||||
|
||||
public VotingPluginBungeeCommand(VotingPluginBungee bungee) {
|
||||
super("votingpluginbungee", "votingplugin.admin");
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender.hasPermission("votingplugin.admin")) {
|
||||
String result = new VotingPluginProxyCommand(bungee.getVotingPluginProxy()).execute(args);
|
||||
if (result != null) {
|
||||
sender.sendMessage(new TextComponent(result.replace("&", "§")));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!".replace("&", "§")));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
if (st == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+72
-75
@@ -1,35 +1,21 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
package com.bencodez.votingplugin.proxy.multiproxy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public abstract class MultiProxyHandler {
|
||||
public abstract boolean getMultiProxySupportEnabled();
|
||||
|
||||
public abstract EncryptionHandler getEncryptionHandler();
|
||||
|
||||
public abstract File getPluginDataFolder();
|
||||
|
||||
public abstract void setEncryptionHandler(EncryptionHandler encryptionHandler);
|
||||
|
||||
public abstract void logInfo(String msg);
|
||||
|
||||
public abstract boolean getDebug();
|
||||
|
||||
public abstract String getVersion();
|
||||
|
||||
private HashMap<String, ClientHandler> multiproxyClientHandles;
|
||||
|
||||
private SocketHandler multiproxySocketHandler;
|
||||
@@ -41,19 +27,9 @@ public abstract class MultiProxyHandler {
|
||||
|
||||
}
|
||||
|
||||
public void sendMultiProxyServerMessage(String... messageData) {
|
||||
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
|
||||
for (ClientHandler h : multiproxyClientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
} else if (getMultiProxyMethod().equals(MultiProxyMethod.REDIS)) {
|
||||
for (String server : getProxyServers()) {
|
||||
multiProxyRedis.sendMessage("VotingPluginProxy_" + server, messageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract void addNonVotedPlayerCache(String string, String string2);
|
||||
|
||||
public abstract List<String> getProxyServers();
|
||||
public abstract void clearVote(String string);
|
||||
|
||||
public void close() {
|
||||
if (multiproxySocketHandler != null) {
|
||||
@@ -65,11 +41,49 @@ public abstract class MultiProxyHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract boolean getDebug();
|
||||
|
||||
public abstract EncryptionHandler getEncryptionHandler();
|
||||
|
||||
public abstract MultiProxyMethod getMultiProxyMethod();
|
||||
|
||||
public abstract String getMultiProxyPassword();
|
||||
|
||||
public abstract String getMultiProxyRedisHost();
|
||||
|
||||
public abstract int getMultiProxyRedisPort();
|
||||
|
||||
public abstract boolean getMultiProxyRedisUseExistingConnection();
|
||||
|
||||
public abstract String getMultiProxyServerName();
|
||||
|
||||
public abstract Collection<String> getMultiProxyServers();
|
||||
|
||||
public abstract MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s);
|
||||
|
||||
public abstract String getMultiProxySocketHostHost();
|
||||
|
||||
public abstract int getMultiProxySocketHostPort();
|
||||
|
||||
public abstract boolean getMultiProxySupportEnabled();
|
||||
|
||||
public abstract String getMultiProxyUsername();
|
||||
|
||||
public abstract File getPluginDataFolder();
|
||||
|
||||
public abstract boolean getPrimaryServer();
|
||||
|
||||
public abstract List<String> getProxyServers();
|
||||
|
||||
public abstract RedisHandler getRedisHandler();
|
||||
|
||||
public abstract String getVersion();
|
||||
|
||||
public void loadMultiProxySupport() {
|
||||
if (getMultiProxySupportEnabled()) {
|
||||
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
|
||||
if (getEncryptionHandler() == null) {
|
||||
setEncryptionHandler(new EncryptionHandler(new File(getPluginDataFolder(), "secretkey.key")));
|
||||
setEncryptionHandler(new EncryptionHandler("VotingPlugin",new File(getPluginDataFolder(), "secretkey.key")));
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
@@ -117,7 +131,7 @@ public abstract class MultiProxyHandler {
|
||||
}
|
||||
});
|
||||
|
||||
multiproxyClientHandles = new HashMap<String, ClientHandler>();
|
||||
multiproxyClientHandles = new HashMap<>();
|
||||
for (String s : getMultiProxyServers()) {
|
||||
MultiProxyServerSocketConfiguration d = getMultiProxyServersConfiguration(s);
|
||||
multiproxyClientHandles.put(s,
|
||||
@@ -131,6 +145,13 @@ public abstract class MultiProxyHandler {
|
||||
multiProxyRedis = new RedisHandler(getMultiProxyRedisHost(), getMultiProxyRedisPort(),
|
||||
getMultiProxyUsername(), getMultiProxyPassword()) {
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (getDebug()) {
|
||||
logInfo("MultiProxyRedis: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(String channel, String[] data) {
|
||||
if (data.length > 0) {
|
||||
@@ -158,13 +179,6 @@ public abstract class MultiProxyHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (getDebug()) {
|
||||
logInfo("MultiProxyRedis: " + message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -182,48 +196,31 @@ public abstract class MultiProxyHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void runAsnc(Runnable runnable);
|
||||
|
||||
public abstract MultiProxyMethod getMultiProxyMethod();
|
||||
|
||||
public abstract RedisHandler getRedisHandler();
|
||||
|
||||
public abstract boolean getMultiProxyRedisUseExistingConnection();
|
||||
|
||||
public abstract String getMultiProxyPassword();
|
||||
|
||||
public abstract String getMultiProxyUsername();
|
||||
|
||||
public abstract String getMultiProxyServerName();
|
||||
|
||||
public abstract int getMultiProxyRedisPort();
|
||||
|
||||
public abstract String getMultiProxyRedisHost();
|
||||
|
||||
public abstract boolean getPrimaryServer();
|
||||
|
||||
public void login(String uuid, String playerName) {
|
||||
if (!getMultiProxySupportEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (getPrimaryServer()) {
|
||||
if (!getMultiProxySupportEnabled() || getPrimaryServer()) {
|
||||
return;
|
||||
}
|
||||
sendMultiProxyServerMessage("Login", uuid, playerName);
|
||||
}
|
||||
|
||||
public abstract int getMultiProxySocketHostPort();
|
||||
public abstract void logInfo(String msg);
|
||||
|
||||
public abstract String getMultiProxySocketHostHost();
|
||||
public abstract void runAsnc(Runnable runnable);
|
||||
|
||||
public abstract MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s);
|
||||
public void sendMultiProxyServerMessage(String... messageData) {
|
||||
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
|
||||
for (ClientHandler h : multiproxyClientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
} else if (getMultiProxyMethod().equals(MultiProxyMethod.REDIS)) {
|
||||
for (String server : getProxyServers()) {
|
||||
multiProxyRedis.sendMessage("VotingPluginProxy_" + server, messageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Collection<String> getMultiProxyServers();
|
||||
public abstract void setEncryptionHandler(EncryptionHandler encryptionHandler);
|
||||
|
||||
public abstract void triggerVote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
|
||||
BungeeMessageData text, String uuid);
|
||||
|
||||
public abstract void addNonVotedPlayerCache(String string, String string2);
|
||||
|
||||
public abstract void clearVote(String string);
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
package com.bencodez.votingplugin.proxy.multiproxy;
|
||||
|
||||
public enum MultiProxyMethod {
|
||||
SOCKETS, REDIS;
|
||||
Loaded 100 of 141 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user