Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
900237b7ea | ||
|
|
7fa7c2baf9 | ||
|
|
eec8d706ee | ||
|
|
d292ae4a18 | ||
|
|
f7d04f87db | ||
|
|
59e2f3da99 | ||
|
|
2a5b6c23da | ||
|
|
62560be2ab | ||
|
|
64993b8b53 | ||
|
|
18c4cd6b6d | ||
|
|
35e14f7a76 | ||
|
|
5c6490159b | ||
|
|
29f0c19a74 | ||
|
|
664500d61b | ||
|
|
e208cdf49b | ||
|
|
e295795ec4 | ||
|
|
c9d24b5e88 | ||
|
|
f09311e6fc | ||
|
|
02ea389f12 | ||
|
|
14ccfa3730 | ||
|
|
51ffe88557 | ||
|
|
7daa0545f3 | ||
|
|
ef7b9cb55a | ||
|
|
a410567de0 | ||
|
|
f00aeab649 | ||
|
|
a4494fc2e7 | ||
|
|
6333760508 | ||
|
|
012547f950 | ||
|
|
631d9c9a1c | ||
|
|
a61e3176a8 | ||
|
|
c013835725 | ||
|
|
ea8ed1e950 | ||
|
|
7dcb3a5f62 | ||
|
|
ed70727a76 | ||
|
|
3418d461e4 | ||
|
|
1e5ec8226a | ||
|
|
993fa19f85 | ||
|
|
7d3d777cb5 | ||
|
|
9829864a96 | ||
|
|
eec87f642f | ||
|
|
9cba16814a | ||
|
|
44ebd17356 |
No files matched your search
@@ -76,33 +76,34 @@ AllowUnJoinedCheckServer: true
|
||||
|
||||
# Configuration for VoteReminding
|
||||
# By default this should be all setup to work
|
||||
# as long as vote delays are done properly
|
||||
# as long as vote delays are done properly in votesites.yml
|
||||
VoteReminding:
|
||||
# Enable vote reminding
|
||||
# This will remind player when he can vote on all sites
|
||||
# Requires VoteDelays to be setup properly
|
||||
# Use /vote next to see when you can be reminded
|
||||
# Players require the perm "VotingPlugin.Login.RemindVotes" or "VotingPlugin.Player"
|
||||
# To remind if any votesite is available (rather than all) use the permission "VotingPlugin.Login.RemindVotes.Any"
|
||||
Enabled: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
RemindOnLogin: true
|
||||
|
||||
# Whether or not to remind only once when the player can vote
|
||||
# Does not apply to login reminds.
|
||||
RemindOnlyOnce: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
# Ignores value above
|
||||
RemindOnLogin: true
|
||||
|
||||
# Delay to remind votes in minutes
|
||||
# Only works if above is false
|
||||
# Set to -1 to disable
|
||||
RemindDelay: 30
|
||||
|
||||
# Run reward files on remind
|
||||
# Run rewards
|
||||
# and have the default message
|
||||
# Can add titles and more in the reward
|
||||
# This can also be edited via /av gui
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aRemember to vote!'
|
||||
Player: '&aYou have %sitesavailable% to vote on still!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
@@ -578,10 +579,11 @@ WaitUntilLoggedIn: true
|
||||
|
||||
# Preload skulls to improve performance
|
||||
# If false, skulls will be cached as they are used
|
||||
# assuming loadskulls is enabled
|
||||
PreloadSkulls: false
|
||||
|
||||
# Setting to false disables saving skulls in a cache to improve speeds
|
||||
# Will reduce ram usage if disabled
|
||||
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
|
||||
LoadSkulls: true
|
||||
|
||||
# Use vault for permission checks
|
||||
|
||||
@@ -221,7 +221,15 @@ commands:
|
||||
adminvoteRunCMD:
|
||||
description: Command Alias
|
||||
aliases: avRunCMD
|
||||
|
||||
adminvoteuseruuidremove:
|
||||
description: Command Alias
|
||||
aliases: avuseruuidremove
|
||||
adminvoteedit:
|
||||
description: Command Alias
|
||||
aliases: avedit
|
||||
adminvoteResetMilestoneCount:
|
||||
description: Command Alias
|
||||
aliases: avResetMilestoneCount
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
@@ -247,7 +255,7 @@ permissions:
|
||||
description: Permission for generating votesite message
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Permission to allow timed reminders
|
||||
VotingPlugin.Login.RemindVotes.Any:
|
||||
description: Remind if player can vote on any website, rather than all
|
||||
VotingPlugin.Login.RemindVotes.All:
|
||||
description: Remind if player can vote on all votesites, rather than any
|
||||
default: false
|
||||
|
||||
+142
-82
@@ -3,8 +3,8 @@
|
||||
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>VotingPlugin</artifactId>
|
||||
<version>6.4.1</version>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.5</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -13,13 +13,6 @@
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@@ -111,14 +104,10 @@
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>com.bencodez.advancedcore</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore</shadedPattern>
|
||||
</relocation>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin</shadedPattern>
|
||||
@@ -136,13 +125,12 @@
|
||||
<shadedPattern>${project.groupId}.votingplugin.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>xyz.upperlevel.spigot.book</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.upperlevel.book</shadedPattern>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<!-- Replace this with your package! -->
|
||||
<shadedPattern>${project.groupId}.votingplugin.bstats</shadedPattern>
|
||||
<pattern>xyz.upperlevel.spigot</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
@@ -175,50 +163,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</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>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>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
@@ -264,12 +208,16 @@
|
||||
<id>velocity</id>
|
||||
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bencodez repo</id>
|
||||
<url>http://51.161.110.19:8081/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -281,7 +229,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -314,40 +262,53 @@
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<build.profile.id>prod</build.profile.id>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod2</id>
|
||||
<properties>
|
||||
<build.profile.id>prod2</build.profile.id>
|
||||
<build.profile.id>prod</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>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>AdvancedCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<groupId>com.github.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -360,11 +321,110 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>AdvancedCore</artifactId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<properties>
|
||||
<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>
|
||||
<url>http://51.161.110.19:8081/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>http://51.161.110.19:8081/repository/maven-releases</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</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.0.0-M1</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>nexus</serverId>
|
||||
<nexusUrl>http://51.161.110.19:8081/nexus/</nexusUrl>
|
||||
<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>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -14,7 +14,6 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TimerTask;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -251,77 +250,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void convertDataStorage(UserStorage from, UserStorage to) {
|
||||
if (from == null || to == null) {
|
||||
throw new RuntimeException("Invalid Storage Method");
|
||||
}
|
||||
UserStorage cur = getStorageType();
|
||||
getOptions().setStorageType(from);
|
||||
if (getStorageType().equals(UserStorage.MYSQL) && getMysql() != null) {
|
||||
getMysql().clearCache();
|
||||
}
|
||||
ArrayList<String> uuids = new ArrayList<String>(UserManager.getInstance().getAllUUIDs());
|
||||
|
||||
while (uuids.size() > 0) {
|
||||
HashMap<VotingPluginUser, HashMap<String, String>> data = new HashMap<VotingPluginUser, HashMap<String, String>>();
|
||||
getOptions().setStorageType(from);
|
||||
loadUserAPI(getOptions().getStorageType());
|
||||
// setStorageType(to);
|
||||
|
||||
if (getStorageType().equals(UserStorage.MYSQL) && getMysql() != null) {
|
||||
getMysql().clearCache();
|
||||
}
|
||||
|
||||
ArrayList<String> converted = new ArrayList<String>();
|
||||
int i = 0;
|
||||
while (i < configFile.getConvertAmount() && i < uuids.size()) {
|
||||
String uuid = uuids.get(i);
|
||||
try {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
String value = user.getData().getValue(key);
|
||||
if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
|
||||
values.put(key, value);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
converted.add(uuid);
|
||||
data.put(user, values);
|
||||
debug("[Convert] Added " + uuid);
|
||||
} catch (Exception e) {
|
||||
debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
wait(configFile.getConvertDelay());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
uuids.removeAll(converted);
|
||||
|
||||
plugin.getLogger().info("Finished getting data from " + from.toString() + " Converting " + data.size()
|
||||
+ " users, " + uuids.size() + " left to convert");
|
||||
|
||||
getOptions().setStorageType(to);
|
||||
loadUserAPI(getOptions().getStorageType());
|
||||
if (getStorageType().equals(UserStorage.MYSQL) && getMysql() != null) {
|
||||
getMysql().clearCache();
|
||||
}
|
||||
|
||||
writeConvertData(data);
|
||||
}
|
||||
|
||||
getOptions().setStorageType(cur);
|
||||
reload();
|
||||
|
||||
plugin.getLogger().info("Finished convertting");
|
||||
}
|
||||
|
||||
public ArrayList<VotingPluginUser> convertSet(Set<VotingPluginUser> set) {
|
||||
return new ArrayList<VotingPluginUser>(set);
|
||||
}
|
||||
@@ -386,7 +314,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
return voteSite;
|
||||
}
|
||||
}
|
||||
if (configFile.isAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames().contains(siteName)) {
|
||||
if (configFile.isAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames(false).contains(siteName)) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
return new VoteSite(plugin, siteName.replace(".", "_"));
|
||||
}
|
||||
@@ -401,7 +329,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
* @return the vote site name
|
||||
*/
|
||||
public String getVoteSiteName(String... urls) {
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames();
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(false);
|
||||
for (String url : urls) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
@@ -431,7 +359,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
public String getVoteSiteServiceSite(String name) {
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames();
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(true);
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -524,7 +452,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getSpecialRewardsConfig().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("FirstVoteToday") {
|
||||
|
||||
@Override
|
||||
@@ -1195,7 +1123,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
if (!site.hasRewards() && !hasRewards) {
|
||||
issues = false;
|
||||
plugin.getLogger().warning("No rewards detected for the site: " + site.getKey()
|
||||
+ ". See https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards on how to add rewards");
|
||||
+ ". See https://github.com/BenCodez/VotingPlugin/wiki/Rewards on how to add rewards");
|
||||
}
|
||||
|
||||
boolean contains = false;
|
||||
@@ -1217,7 +1145,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().warning(
|
||||
"Detected an issue with voting sites, check the server startup log for more details");
|
||||
"Detected an issue with voting sites, check the server startup log for more details: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
|
||||
}
|
||||
}, 30l);
|
||||
}
|
||||
@@ -1250,7 +1178,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
loadVoteSites();
|
||||
|
||||
setJenkinsSite("ben12345rocks.com");
|
||||
setJenkinsSite("bencodez.com");
|
||||
updateAdvancedCoreHook();
|
||||
|
||||
}
|
||||
@@ -1375,6 +1303,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
placeholders.load();
|
||||
|
||||
voteReminding.loadRemindChecking();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -1508,30 +1438,4 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Updated VoteToday");
|
||||
}
|
||||
|
||||
private void writeConvertData(HashMap<VotingPluginUser, HashMap<String, String>> data) {
|
||||
boolean checkInt = getStorageType().equals(UserStorage.MYSQL);
|
||||
for (Entry<VotingPluginUser, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
String value = values.getValue();
|
||||
if (value != null && !value.equalsIgnoreCase("null")) {
|
||||
if (checkInt) {
|
||||
if (StringParser.getInstance().isInt(value)) {
|
||||
entry.getKey().getData().setInt(values.getKey(), Integer.parseInt(value));
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger()
|
||||
.warning("Exception occoured for '" + entry.getKey().getUUID() + "': " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,17 +65,17 @@ public class BungeeMySQL {
|
||||
}
|
||||
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads) {
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
bungee.getLogger().severe(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (bungee.getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
bungee.getLogger().severe(string);
|
||||
}
|
||||
};
|
||||
if (!mysql.connect(hostName, "" + port, user, pass, database, useSSL, lifeTime, str, publicKeyRetrieval)) {
|
||||
|
||||
@@ -382,7 +382,7 @@ public class BungeeMySQL {
|
||||
}
|
||||
|
||||
public void insertQuery(String index, List<Column> cols) {
|
||||
String query = "INSERT " + getName() + " ";
|
||||
String query = "INSERT IGNORE " + getName() + " ";
|
||||
|
||||
query += "set uuid='" + index + "', ";
|
||||
|
||||
|
||||
@@ -205,36 +205,6 @@ public class VotingPluginBungee extends Plugin {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int mysqlUpdate(ArrayList<Column> cols, String uuid, String column, int toAdd) {
|
||||
int num = getValue(cols, column) + toAdd;
|
||||
debug("Setting " + column + " to " + num + " for " + uuid);
|
||||
mysql.update(uuid, column, num, DataType.INTEGER);
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedVotes.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 : cachedOnlineVotes.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
mysql = new BungeeMySQL(this, "VotingPlugin_Users", config.getData());
|
||||
|
||||
@@ -265,6 +235,36 @@ public class VotingPluginBungee extends Plugin {
|
||||
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
|
||||
}
|
||||
|
||||
private int mysqlUpdate(ArrayList<Column> cols, String uuid, String column, int toAdd) {
|
||||
int num = getValue(cols, column) + toAdd;
|
||||
debug("Setting " + column + " to " + num + " for " + uuid);
|
||||
mysql.update(uuid, column, num, DataType.INTEGER);
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedVotes.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 : cachedOnlineVotes.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
@@ -659,7 +659,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
}
|
||||
uuid = u.toString();
|
||||
} else {
|
||||
getLogger().info("Ignoring vote from " + player);
|
||||
getLogger().info("Ignoring vote from " + player + " since player hasn't joined before");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -751,6 +751,9 @@ public class VotingPluginBungee extends Plugin {
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
|
||||
@@ -63,17 +63,17 @@ public class BungeeMySQL {
|
||||
}
|
||||
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads) {
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
plugin.getLogger().error(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (plugin.getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
plugin.getLogger().error(string);
|
||||
}
|
||||
};
|
||||
if (!mysql.connect(hostName, "" + port, user, pass, database, useSSL, lifeTime, str, publicKeyRetrieval)) {
|
||||
|
||||
@@ -380,7 +380,7 @@ public class BungeeMySQL {
|
||||
}
|
||||
|
||||
public void insertQuery(String index, List<Column> cols) {
|
||||
String query = "INSERT " + getName() + " ";
|
||||
String query = "INSERT IGNORE " + getName() + " ";
|
||||
|
||||
query += "set uuid='" + index + "', ";
|
||||
|
||||
|
||||
@@ -13,6 +13,10 @@ public class Config extends VelocityYMLFile {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getBoolean(getNode("AllowUnJoined"), false);
|
||||
}
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getStringList(getNode("BlockedServers"), new ArrayList<String>());
|
||||
}
|
||||
@@ -21,22 +25,14 @@ public class Config extends VelocityYMLFile {
|
||||
return getBoolean(getNode("Broadcast"), false);
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
public boolean getBungeeManageTotals() {
|
||||
return getBoolean(getNode("BungeeManageTotals"), true);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getBoolean(getNode("AllowUnJoined"), false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
public String getBungeeMethod() {
|
||||
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
|
||||
}
|
||||
@@ -53,6 +49,18 @@ public class Config extends VelocityYMLFile {
|
||||
return getString(getNode("FallBackServer"), "");
|
||||
}
|
||||
|
||||
public long getLong(ConfigurationNode node, long def) {
|
||||
return node.getLong(def);
|
||||
}
|
||||
|
||||
public ConfigurationNode getMysqlNode() {
|
||||
return getNode("MySQL");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getInt(getNode("PointsOnVote"), 1);
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getBoolean(getNode("SendVotesToAllServers"), true);
|
||||
}
|
||||
@@ -61,10 +69,6 @@ public class Config extends VelocityYMLFile {
|
||||
return getNode("SpigotServers", s);
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getInt(getNode("PointsOnVote"), 1);
|
||||
}
|
||||
|
||||
public Collection<String> getSpigotServers() {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (ConfigurationNode conf : getNode("SpigotServers").getChildrenList()) {
|
||||
@@ -73,11 +77,7 @@ public class Config extends VelocityYMLFile {
|
||||
return list;
|
||||
}
|
||||
|
||||
public ConfigurationNode getMysqlNode() {
|
||||
return getNode("MySQL");
|
||||
}
|
||||
|
||||
public long getLong(ConfigurationNode node, long def) {
|
||||
return node.getLong(def);
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
|
||||
public class VelocityYMLFile {
|
||||
@Getter
|
||||
private File file;
|
||||
@Getter
|
||||
private ConfigurationNode conf;
|
||||
@Getter
|
||||
private File file;
|
||||
private YAMLConfigurationLoader loader;
|
||||
|
||||
public VelocityYMLFile(File file) {
|
||||
@@ -41,31 +41,14 @@ public class VelocityYMLFile {
|
||||
|
||||
}
|
||||
|
||||
public ConfigurationNode getData() {
|
||||
return conf;
|
||||
}
|
||||
|
||||
public ConfigurationNode getNode(Object... path) {
|
||||
return getData().getNode(path);
|
||||
}
|
||||
|
||||
public List<String> getStringList(ConfigurationNode node, ArrayList<String> def) {
|
||||
try {
|
||||
return node.getList(TypeToken.of(String.class), def);
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(ConfigurationNode node, String def) {
|
||||
return node.getString(def);
|
||||
}
|
||||
|
||||
public boolean getBoolean(ConfigurationNode node, boolean def) {
|
||||
return node.getBoolean(def);
|
||||
}
|
||||
|
||||
public ConfigurationNode getData() {
|
||||
return conf;
|
||||
}
|
||||
|
||||
public int getInt(ConfigurationNode node, int def) {
|
||||
return node.getInt(def);
|
||||
}
|
||||
@@ -77,7 +60,24 @@ public class VelocityYMLFile {
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
|
||||
public ConfigurationNode getNode(Object... path) {
|
||||
return getData().getNode(path);
|
||||
}
|
||||
|
||||
public String getString(ConfigurationNode node, String def) {
|
||||
return node.getString(def);
|
||||
}
|
||||
|
||||
public List<String> getStringList(ConfigurationNode node, ArrayList<String> def) {
|
||||
try {
|
||||
return node.getList(TypeToken.of(String.class), def);
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
loader = YAMLConfigurationLoader.builder().setPath(file.toPath()).build();
|
||||
|
||||
|
||||
+260
-245
@@ -65,35 +65,44 @@ import ninja.leaping.configurate.ConfigurationNode;
|
||||
"BenCodez" }, dependencies = { @Dependency(id = "nuvotifier", optional = true) })
|
||||
public class VotingPluginVelocity {
|
||||
|
||||
private final ProxyServer server;
|
||||
@Getter
|
||||
private final Logger logger;
|
||||
private final Path dataDirectory;
|
||||
|
||||
private final Metrics.Factory metricsFactory;
|
||||
|
||||
@Getter
|
||||
private Config config;
|
||||
private static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.create("vp", "vp");
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
@Getter
|
||||
private BungeeMySQL mysql;
|
||||
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>> cachedVotes = new HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<String, ClientHandler> clientHandles;
|
||||
|
||||
@Getter
|
||||
private Config config;
|
||||
private final Path dataDirectory;
|
||||
private EncryptionHandler encryptionHandler;
|
||||
@Getter
|
||||
private final Logger logger;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
private final Metrics.Factory metricsFactory;
|
||||
|
||||
@Getter
|
||||
private BungeeMySQL mysql;
|
||||
|
||||
private NonVotedPlayersCache nonVotedPlayersCache;
|
||||
|
||||
private final ProxyServer server;
|
||||
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private VoteCache voteCacheFile;
|
||||
|
||||
@Inject
|
||||
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
|
||||
@DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
this.metricsFactory = metricsFactory;
|
||||
}
|
||||
|
||||
public void checkCachedVotes(RegisteredServer serverToCheck) {
|
||||
if (!serverToCheck.getPlayersConnected().isEmpty()) {
|
||||
if (cachedVotes.containsKey(serverToCheck)
|
||||
@@ -104,7 +113,10 @@ public class VotingPluginVelocity {
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
boolean toSend = true;
|
||||
if (getConfig().getWaitForUserOnline()) {
|
||||
Player p = server.getPlayer(UUID.fromString(cache.getUuid())).get();
|
||||
Player p = null;
|
||||
if (server.getPlayer(UUID.fromString(cache.getUuid())).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(cache.getUuid())).get();
|
||||
}
|
||||
if (p == null || !p.isActive()) {
|
||||
toSend = false;
|
||||
} else if (p != null && p.isActive() && !p.getCurrentServer().get().getServerInfo()
|
||||
@@ -151,13 +163,85 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
|
||||
@DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
this.metricsFactory = metricsFactory;
|
||||
public void debug(String msg) {
|
||||
if (config.getDebug()) {
|
||||
logger.info("Debug: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID fetchUUID(String playerName) throws Exception {
|
||||
// Get response from Mojang API
|
||||
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.connect();
|
||||
|
||||
if (connection.getResponseCode() == 400) {
|
||||
logger.info("There is no player with the name \"" + playerName + "\"!");
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
// Parse JSON response and get UUID
|
||||
JsonElement element = new JsonParser().parse(bufferedReader);
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
String uuidAsString = object.get("id").getAsString();
|
||||
|
||||
// Return UUID
|
||||
return parseUUIDFromString(uuidAsString);
|
||||
}
|
||||
|
||||
public String getProperName(String uuid, String currentName) {
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
Player p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUsername();
|
||||
}
|
||||
}
|
||||
return currentName;
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
if (server.getPlayer(playerName).isPresent()) {
|
||||
Player p = server.getPlayer(playerName).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
}
|
||||
if (mysql != null) {
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private int getValue(ArrayList<Column> cols, String column) {
|
||||
for (Column d : cols) {
|
||||
if (d.getName().equalsIgnoreCase(column)) {
|
||||
|
||||
Object value = d.getValue();
|
||||
int num = 0;
|
||||
if (value instanceof Integer) {
|
||||
try {
|
||||
num = (int) value;
|
||||
} catch (ClassCastException | NullPointerException ex) {
|
||||
}
|
||||
} else if (value instanceof String) {
|
||||
try {
|
||||
num = Integer.parseInt((String) value);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
@@ -189,34 +273,76 @@ public class VotingPluginVelocity {
|
||||
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
|
||||
}
|
||||
|
||||
public void reload(boolean loadMySQL) {
|
||||
config.reload();
|
||||
if (loadMySQL) {
|
||||
if (!config.getString(config.getNode("Host"), "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
logger.error("MySQL settings not set in bungeeconfig.yml");
|
||||
private int mysqlUpdate(ArrayList<Column> cols, String uuid, String column, int toAdd) {
|
||||
int num = getValue(cols, column) + toAdd;
|
||||
debug("Setting " + column + " to " + num + " for " + uuid);
|
||||
mysql.update(uuid, column, num, DataType.INTEGER);
|
||||
return num;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessagingReceived(PluginMessageEvent event) {
|
||||
if (event.getIdentifier().getId().equals(CHANNEL.getId())) {
|
||||
ByteArrayInputStream instream = new ByteArrayInputStream(event.getData());
|
||||
DataInputStream in = new DataInputStream(instream);
|
||||
try {
|
||||
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(outstream);
|
||||
String subchannel = in.readUTF();
|
||||
int size = in.readInt();
|
||||
|
||||
// check for status message returns
|
||||
if (subchannel.equalsIgnoreCase("statusokay")) {
|
||||
String server = in.readUTF();
|
||||
logger.info("Status okay for " + server);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
String player = in.readUTF();
|
||||
Player p = server.getPlayer(player).get();
|
||||
checkCachedVotes(p.getCurrentServer().get().getServer());
|
||||
checkOnlineVotes(p, p.getUniqueId().toString(), p.getCurrentServer().get().getServer());
|
||||
return;
|
||||
} else {
|
||||
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
out.writeUTF(in.readUTF());
|
||||
}
|
||||
for (RegisteredServer send : server.getAllServers()) {
|
||||
|
||||
if (send.getPlayersConnected().size() > 0) {
|
||||
send.sendPluginMessage(CHANNEL, outstream.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void status() {
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
if (s.getPlayersConnected().size() == 0) {
|
||||
getLogger().info("No players on server " + s + " to send test status message");
|
||||
} else {
|
||||
// send
|
||||
getLogger().info("Sending request for status message on " + s);
|
||||
sendPluginMessageServer(s, "Status", s.getServerInfo().getName());
|
||||
}
|
||||
} else {
|
||||
getLogger().info("Ignoring blocked server " + s);
|
||||
@Subscribe
|
||||
public void onProxyDisable(ProxyShutdownEvent event) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (Entry<RegisteredServer, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
|
||||
RegisteredServer server = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVote(server.getServerInfo().getName(), num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,115 +519,10 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyDisable(ProxyShutdownEvent event) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (Entry<RegisteredServer, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
|
||||
RegisteredServer server = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVote(server.getServerInfo().getName(), num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void playerServerConnected(ServerConnectedEvent event) {
|
||||
checkCachedVotes(event.getServer());
|
||||
checkOnlineVotes(event.getPlayer(), event.getPlayer().getUniqueId().toString(), event.getServer());
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessagingReceived(PluginMessageEvent event) {
|
||||
if (event.getIdentifier().getId().equals(CHANNEL.getId())) {
|
||||
ByteArrayInputStream instream = new ByteArrayInputStream(event.getData());
|
||||
DataInputStream in = new DataInputStream(instream);
|
||||
try {
|
||||
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(outstream);
|
||||
String subchannel = in.readUTF();
|
||||
int size = in.readInt();
|
||||
|
||||
// check for status message returns
|
||||
if (subchannel.equalsIgnoreCase("statusokay")) {
|
||||
String server = in.readUTF();
|
||||
logger.info("Status okay for " + server);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
String player = in.readUTF();
|
||||
Player p = server.getPlayer(player).get();
|
||||
checkCachedVotes(p.getCurrentServer().get().getServer());
|
||||
checkOnlineVotes(p, p.getUniqueId().toString(), p.getCurrentServer().get().getServer());
|
||||
return;
|
||||
} else {
|
||||
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
out.writeUTF(in.readUTF());
|
||||
}
|
||||
for (RegisteredServer send : server.getAllServers()) {
|
||||
|
||||
if (send.getPlayersConnected().size() > 0) {
|
||||
send.sendPluginMessage(CHANNEL, outstream.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
Player p = server.getPlayer(playerName).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
if (mysql != null) {
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public UUID fetchUUID(String playerName) throws Exception {
|
||||
// Get response from Mojang API
|
||||
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.connect();
|
||||
|
||||
if (connection.getResponseCode() == 400) {
|
||||
logger.info("There is no player with the name \"" + playerName + "\"!");
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
// Parse JSON response and get UUID
|
||||
JsonElement element = new JsonParser().parse(bufferedReader);
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
String uuidAsString = object.get("id").getAsString();
|
||||
|
||||
// Return UUID
|
||||
return parseUUIDFromString(uuidAsString);
|
||||
public void onVotifierEvent(VotifierEvent event) {
|
||||
Vote vote = event.getVote();
|
||||
logger.info("Vote received " + vote.getUsername() + " from service site " + vote.getServiceName());
|
||||
vote(vote.getUsername(), vote.getServiceName(), true);
|
||||
}
|
||||
|
||||
private UUID parseUUIDFromString(String uuidAsString) {
|
||||
@@ -522,54 +543,21 @@ public class VotingPluginVelocity {
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
}
|
||||
|
||||
public void debug(String msg) {
|
||||
if (config.getDebug()) {
|
||||
logger.info("Debug: " + msg);
|
||||
}
|
||||
@Subscribe
|
||||
public void playerServerConnected(ServerConnectedEvent event) {
|
||||
checkCachedVotes(event.getServer());
|
||||
checkOnlineVotes(event.getPlayer(), event.getPlayer().getUniqueId().toString(), event.getServer());
|
||||
}
|
||||
|
||||
private int getValue(ArrayList<Column> cols, String column) {
|
||||
for (Column d : cols) {
|
||||
if (d.getName().equalsIgnoreCase(column)) {
|
||||
|
||||
Object value = d.getValue();
|
||||
int num = 0;
|
||||
if (value instanceof Integer) {
|
||||
try {
|
||||
num = (int) value;
|
||||
} catch (ClassCastException | NullPointerException ex) {
|
||||
}
|
||||
} else if (value instanceof String) {
|
||||
try {
|
||||
num = Integer.parseInt((String) value);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return num;
|
||||
public void reload(boolean loadMySQL) {
|
||||
config.reload();
|
||||
if (loadMySQL) {
|
||||
if (!config.getString(config.getNode("Host"), "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
logger.error("MySQL settings not set in bungeeconfig.yml");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int mysqlUpdate(ArrayList<Column> cols, String uuid, String column, int toAdd) {
|
||||
int num = getValue(cols, column) + toAdd;
|
||||
debug("Setting " + column + " to " + num + " for " + uuid);
|
||||
mysql.update(uuid, column, num, DataType.INTEGER);
|
||||
return num;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onVotifierEvent(VotifierEvent event) {
|
||||
Vote vote = event.getVote();
|
||||
vote(vote.getUsername(), vote.getServiceName(), true);
|
||||
}
|
||||
|
||||
public String getProperName(String uuid, String currentName) {
|
||||
Player p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUsername();
|
||||
}
|
||||
return currentName;
|
||||
}
|
||||
|
||||
public void sendPluginMessageServer(RegisteredServer s, String channel, String... messageData) {
|
||||
@@ -593,6 +581,71 @@ public class VotingPluginVelocity {
|
||||
|
||||
}
|
||||
|
||||
public void sendServerMessage(String... messageData) {
|
||||
for (ClientHandler h : clientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendServerMessageServer(String server, String... messageData) {
|
||||
if (clientHandles.containsKey(server)) {
|
||||
clientHandles.get(server).sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSocketVote(String name, String service, BungeeMessageData text) {
|
||||
String uuid = getUUID(name);
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
sendServerMessage("bungeevote", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
} else {
|
||||
// online server only
|
||||
Player p = server.getPlayer(name).get();
|
||||
|
||||
String server = "";
|
||||
if (p != null && p.isActive()) {
|
||||
server = p.getCurrentServer().get().getServerInfo().getName();
|
||||
} else {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
if (config.getBlockedServers().contains(server)) {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
|
||||
sendServerMessageServer(server, "bungeevoteonline", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
sendServerMessage("BungeeUpdate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void status() {
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
if (s.getPlayersConnected().size() == 0) {
|
||||
getLogger().info("No players on server " + s + " to send test status message");
|
||||
} else {
|
||||
// send
|
||||
getLogger().info("Sending request for status message on " + s);
|
||||
sendPluginMessageServer(s, "Status", s.getServerInfo().getName());
|
||||
}
|
||||
} else {
|
||||
getLogger().info("Ignoring blocked server " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void vote(String player, String service, boolean realVote) {
|
||||
try {
|
||||
if (player == null || player.isEmpty()) {
|
||||
@@ -617,7 +670,7 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
uuid = u.toString();
|
||||
} else {
|
||||
logger.info("Ignoring vote from " + player);
|
||||
logger.info("Ignoring vote from " + player + " since player hasn't joined before");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -664,7 +717,10 @@ public class VotingPluginVelocity {
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
boolean forceCache = false;
|
||||
Player p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
Player p = null;
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
}
|
||||
if ((p == null || !p.isActive()) && getConfig().getWaitForUserOnline()) {
|
||||
forceCache = true;
|
||||
debug("Forcing vote to cache");
|
||||
@@ -708,6 +764,10 @@ public class VotingPluginVelocity {
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
@@ -716,49 +776,4 @@ public class VotingPluginVelocity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSocketVote(String name, String service, BungeeMessageData text) {
|
||||
String uuid = getUUID(name);
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
sendServerMessage("bungeevote", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
} else {
|
||||
// online server only
|
||||
Player p = server.getPlayer(name).get();
|
||||
|
||||
String server = "";
|
||||
if (p != null && p.isActive()) {
|
||||
server = p.getCurrentServer().get().getServerInfo().getName();
|
||||
} else {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
if (config.getBlockedServers().contains(server)) {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
|
||||
sendServerMessageServer(server, "bungeevoteonline", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
sendServerMessage("BungeeUpdate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendServerMessage(String... messageData) {
|
||||
for (ClientHandler h : clientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendServerMessageServer(String server, String... messageData) {
|
||||
if (clientHandles.containsKey(server)) {
|
||||
clientHandles.get(server).sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,6 @@ import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
@@ -724,28 +723,6 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "ConvertFromData", "(userstorage)" },
|
||||
"VotingPlugin.Commands.AdminVote.ConvertFromData",
|
||||
"Convert from selected user storage to current user storage") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cThis can not be done ingame"));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sender.sendMessage("Starting to convert");
|
||||
UserStorage prevStorage = UserStorage.valueOf(args[1].toUpperCase());
|
||||
plugin.convertDataStorage(prevStorage, VotingPluginMain.plugin.getStorageType());
|
||||
sender.sendMessage("Finished converting!");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "DAY", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVoteStreak.Day|" + adminPerm, "Set votestreak for player") {
|
||||
@@ -2177,20 +2154,25 @@ public class CommandLoader {
|
||||
if (plugin.getConfigFile().isAllowVotePointTransfers()) {
|
||||
VotingPluginUser cPlayer = UserManager.getInstance().getVotingPluginUser((Player) sender);
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
int pointsToGive = Integer.parseInt(args[2]);
|
||||
if (pointsToGive > 0) {
|
||||
if (cPlayer.getPoints() >= pointsToGive) {
|
||||
user.addPoints(pointsToGive);
|
||||
cPlayer.removePoints(pointsToGive);
|
||||
sendMessage(sender, "&c" + pointsToGive + " points given to " + user.getPlayerName());
|
||||
user.sendMessage(
|
||||
"&cYou received " + pointsToGive + " points from " + cPlayer.getPlayerName());
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
int pointsToGive = Integer.parseInt(args[2]);
|
||||
if (pointsToGive > 0) {
|
||||
if (cPlayer.getPoints() >= pointsToGive) {
|
||||
user.addPoints(pointsToGive);
|
||||
cPlayer.removePoints(pointsToGive);
|
||||
sendMessage(sender,
|
||||
"&c" + pointsToGive + " points given to " + user.getPlayerName());
|
||||
user.sendMessage("&cYou received " + pointsToGive + " points from "
|
||||
+ cPlayer.getPlayerName());
|
||||
} else {
|
||||
sendMessage(sender, "&cNot enough points");
|
||||
}
|
||||
} else {
|
||||
sendMessage(sender, "&cNot enough points");
|
||||
sendMessage(sender, "&cNumber of points needs to be greater than 0");
|
||||
}
|
||||
} else {
|
||||
sendMessage(sender, "&cNumber of points needs to be greater than 0");
|
||||
sendMessage(sender, "&c" + args[1] + " has not joined the server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,8 +16,8 @@ import com.bencodez.votingplugin.objects.VoteSite;
|
||||
|
||||
public class AdminVoteVotePlayer extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVotePlayer(VotingPluginMain plugin, CommandSender player, String playerName) {
|
||||
super(player);
|
||||
|
||||
@@ -43,7 +43,6 @@ public class VoteNext extends GUIHandler {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
|
||||
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
|
||||
|
||||
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%info%",
|
||||
@@ -63,12 +62,14 @@ public class VoteNext extends GUIHandler {
|
||||
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
.onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build());
|
||||
book.addLayout(nextLayout);
|
||||
if (!site.isHidden()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
.onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build());
|
||||
book.addLayout(nextLayout);
|
||||
}
|
||||
}
|
||||
book.addLine();
|
||||
|
||||
@@ -85,20 +86,24 @@ public class VoteNext extends GUIHandler {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandNextInfo(site))
|
||||
.setAmountNone(1).addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1)
|
||||
.addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteNextBackButton()) {
|
||||
|
||||
@@ -49,6 +49,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
|
||||
inv.dontClose();
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
|
||||
|
||||
@Override
|
||||
@@ -77,7 +78,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user);
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -52,10 +52,6 @@ public class BungeeSettings extends YMLFile {
|
||||
@ConfigDataString(path = "Server")
|
||||
@Getter
|
||||
private String server = "PleaseSet";
|
||||
|
||||
public String getServerNameStorage() {
|
||||
return getServer().replace("-", "_");
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "SpigotServer.Host")
|
||||
@Getter
|
||||
@@ -81,6 +77,10 @@ public class BungeeSettings extends YMLFile {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
}
|
||||
|
||||
public String getServerNameStorage() {
|
||||
return getServer().replace("-", "_");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
|
||||
@@ -85,14 +85,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean clearCacheOnVoteShopPurchase = true;
|
||||
|
||||
@ConfigDataInt(path = "ConvertAmount")
|
||||
@Getter
|
||||
private int convertAmount = 150;
|
||||
|
||||
@ConfigDataInt(path = "ConvertDelay", defaultValue = 30000)
|
||||
@Getter
|
||||
private int convertDelay;
|
||||
|
||||
@ConfigDataBoolean(path = "CountFakeVotes")
|
||||
@Getter
|
||||
private boolean countFakeVotes = true;
|
||||
@@ -341,6 +333,10 @@ public class Config extends YMLFile {
|
||||
return getData().getString("Format.Commands.Vote.Best.Title", "&3&l%player% Best Votes");
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteHelpHoverColor() {
|
||||
return getData().getString("Format.Commands.Vote.Help.HoverColor", "AQUA");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help line.
|
||||
*
|
||||
@@ -349,10 +345,6 @@ public class Config extends YMLFile {
|
||||
public String getFormatCommandsVoteHelpLine() {
|
||||
return getData().getString("Format.Commands.Vote.Help.Line", "&6%Command% - &6%HelpMessage%");
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteHelpHoverColor() {
|
||||
return getData().getString("Format.Commands.Vote.Help.HoverColor", "AQUA");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help require permission.
|
||||
|
||||
@@ -41,8 +41,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName
|
||||
+ " does not exist, creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
plugin.getLogger().warning("VoteSite " + siteName + " does not exist with the servicesite '" + org
|
||||
+ "', creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
setEnabled(siteName, true);
|
||||
setServiceSite(siteName, org);
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
@@ -192,7 +192,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
*/
|
||||
public ArrayList<VoteSite> getVoteSitesLoad() {
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames(true);
|
||||
if (voteSiteNames != null) {
|
||||
for (String site : voteSiteNames) {
|
||||
if (getVoteSiteEnabled(site) && !site.equalsIgnoreCase("null")) {
|
||||
@@ -225,12 +225,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote sites names.
|
||||
*
|
||||
* @return the vote sites names
|
||||
*/
|
||||
public ArrayList<String> getVoteSitesNames() {
|
||||
public ArrayList<String> getVoteSitesNames(boolean checkEnabled) {
|
||||
ArrayList<String> siteNames = new ArrayList<String>();
|
||||
if (getData().isConfigurationSection("VoteSites")) {
|
||||
siteNames = ArrayUtils.getInstance().convert(getData().getConfigurationSection("VoteSites").getKeys(false));
|
||||
@@ -242,8 +237,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
plugin.getLogger()
|
||||
.warning("VoteSites." + siteNames.get(i) + " is not a configuration section, please remove");
|
||||
siteNames.remove(i);
|
||||
} else if (siteNames.get(i).equalsIgnoreCase("null") || !getVoteSiteEnabled(siteNames.get(i))
|
||||
|| !siteCheck(siteNames.get(i))) {
|
||||
} else if (siteNames.get(i).equalsIgnoreCase("null")
|
||||
|| (!getVoteSiteEnabled(siteNames.get(i)) && checkEnabled) || !siteCheck(siteNames.get(i))) {
|
||||
// plugin.getLogger().info("Removed: " + siteNames.get(i));
|
||||
siteNames.remove(i);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
|
||||
@Getter
|
||||
private String firstVoteRewardsPath = "FirstVote";
|
||||
|
||||
|
||||
@Getter
|
||||
private String firstVoteTodayRewardsPath = "FirstVoteToday";
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bencodez.votingplugin.events;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, MILESTONE, VOTESTREAK, FIRSTVOTETODAY;
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@@ -87,6 +87,11 @@ public class PlayerVoteListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!voteSite.isEnabled()) {
|
||||
plugin.debug("Votesite: " + voteSite.getKey() + " is not enabled");
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser user = null;
|
||||
if (event.getVotingPluginUser() != null) {
|
||||
user = event.getVotingPluginUser();
|
||||
|
||||
@@ -77,12 +77,12 @@ public class VotiferEvent implements Listener {
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
|
||||
plugin.getLogger().severe(
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled");
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods");
|
||||
return;
|
||||
}
|
||||
String voteSiteName = plugin.getVoteSiteName(voteSite);
|
||||
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames();
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
|
||||
boolean createSite = false;
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteName)) {
|
||||
|
||||
@@ -250,6 +250,14 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Return true/false if player can vote on all sites"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVoteSites") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
return "" + user.getSitesNotVotedOn();
|
||||
}
|
||||
}.withDescription("Return number of votesites available"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_AnySite") {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -91,7 +91,7 @@ public class SignHandler {
|
||||
* Check skulls.
|
||||
*/
|
||||
public void checkSkulls() {
|
||||
if (playerName.equalsIgnoreCase("No Player") || playerName.equals("")) {
|
||||
if (noNameAvailable()) {
|
||||
return;
|
||||
}
|
||||
if (skullLocation != null) {
|
||||
@@ -151,6 +151,10 @@ public class SignHandler {
|
||||
return skullLocation != null;
|
||||
}
|
||||
|
||||
public boolean noNameAvailable() {
|
||||
return playerName.equalsIgnoreCase("No Player") || playerName.equals("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*/
|
||||
|
||||
@@ -224,9 +224,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
*/
|
||||
public boolean canVoteAll() {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (!canVote) {
|
||||
return false;
|
||||
if (!voteSite.isHidden()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (!canVote) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -234,7 +236,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public boolean canVoteAny() {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
if (!voteSite.isIgnoreCanVote()) {
|
||||
if (!voteSite.isIgnoreCanVote() && !voteSite.isHidden()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (canVote) {
|
||||
return true;
|
||||
@@ -1269,4 +1271,16 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return MiscUtils.getInstance().getTime(getDayVoteStreakLastUpdate()).getDayOfYear() == time.getDayOfYear();
|
||||
}
|
||||
|
||||
public int getSitesNotVotedOn() {
|
||||
int amount = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
if (canVoteSite(site)) {
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,11 @@
|
||||
package com.bencodez.votingplugin.votereminding;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -18,6 +20,8 @@ public class VoteReminding {
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private Timer timer;
|
||||
|
||||
public VoteReminding(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@@ -28,22 +32,13 @@ public class VoteReminding {
|
||||
* @param user the user
|
||||
*/
|
||||
public void checkRemind(VotingPluginUser user) {
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
if (PlayerUtils.getInstance().hasServerPermission(playerName, "VotingPlugin.Login.RemindVotes")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(playerName, "VotingPlugin.Player")) {
|
||||
if (user.canVoteAll() || (user.canVoteAny() && user.hasPermission("VotingPlugin.Login.RemindVotes.Any"))) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
if (!plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
} else if (!user.isReminded()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
}
|
||||
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
|
||||
if (shouldRemind(user)) {
|
||||
if (!plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
|
||||
runRemind(user);
|
||||
} else if (!user.isReminded()) {
|
||||
runRemind(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,23 +46,31 @@ public class VoteReminding {
|
||||
|
||||
private void giveReward(VotingPluginUser user) {
|
||||
new RewardBuilder(plugin.getConfigFile().getData(), plugin.getConfigFile().getVoteRemindingRewardsPath())
|
||||
.setGiveOffline(false).send(user);
|
||||
.withPlaceHolder("sitesavailable", "" + user.getSitesNotVotedOn()).setGiveOffline(false).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load remind checking.
|
||||
*/
|
||||
public void loadRemindChecking() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
}
|
||||
if (plugin.getConfigFile().getVoteRemindingRemindDelay() > 0) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
checkRemind(user);
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 10, plugin.getConfigFile().getVoteRemindingRemindDelay() * 20 * 60);
|
||||
}, 1000 * 30, plugin.getConfigFile().getVoteRemindingRemindDelay() * 1000 * 60);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,13 +83,25 @@ public class VoteReminding {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
if (user.canVoteAll() && user.shouldBeReminded()) {
|
||||
giveReward(user);
|
||||
if (user.getData().hasData()) {
|
||||
user.setReminded(true);
|
||||
giveReward(user);
|
||||
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
}
|
||||
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldRemind(VotingPluginUser user) {
|
||||
if (user.shouldBeReminded()) {
|
||||
boolean hasPermAll = user.hasPermission("VotingPlugin.Login.RemindVotes.All");
|
||||
if (hasPermAll) {
|
||||
return user.canVoteAll();
|
||||
} else {
|
||||
return user.canVoteAny();
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,9 +110,7 @@ public class VoteReminding {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
if ((!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || (user.canVoteAll()
|
||||
|| (user.canVoteAny() && user.hasPermission("VotingPlugin.Login.RemindVotes.Any"))))
|
||||
&& user.shouldBeReminded()) {
|
||||
if ((!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || shouldRemind(user))) {
|
||||
giveReward(user);
|
||||
if (user.getData().hasData()) {
|
||||
user.setReminded(true);
|
||||
|
||||
Reference in new issue
Block a user