Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe277d8bfd | ||
|
|
86cba23568 | ||
|
|
5a6140020f | ||
|
|
cb203edecf | ||
|
|
5510e3bb98 | ||
|
|
470c52e6e3 | ||
|
|
03e4c2165e | ||
|
|
45d617106b | ||
|
|
58869742bc | ||
|
|
a8841ca732 | ||
|
|
96ef82aef0 | ||
|
|
5a33b5b892 | ||
|
|
ed2fb77a7b | ||
|
|
8a1c820e42 | ||
|
|
43c5419453 | ||
|
|
4f2caf67d0 | ||
|
|
8b17e43ce0 | ||
|
|
05db0b189b | ||
|
|
93f91923bb | ||
|
|
6dca3ad152 | ||
|
|
637db5afdb | ||
|
|
029fa00e3a | ||
|
|
e1bb95c482 | ||
|
|
667b1b082d | ||
|
|
2097fc4b86 | ||
|
|
49d20c0bc8 | ||
|
|
fe2ac4f02c | ||
|
|
4859c37ef8 | ||
|
|
c818007426 | ||
|
|
c86f07aeb6 | ||
|
|
0a74e338c2 | ||
|
|
d1dc8b392f | ||
|
|
bd5234b479 | ||
|
|
cca9e3dc58 | ||
|
|
c3df294ce6 | ||
|
|
d81a113240 | ||
|
|
f2feafa45a | ||
|
|
f63a743c2c | ||
|
|
2d9c6482fc | ||
|
|
448a9eeea9 | ||
|
|
c8e32696af | ||
|
|
36eb6eafb3 | ||
|
|
040fafe33a | ||
|
|
040e467761 | ||
|
|
e0d28be260 | ||
|
|
1ef2440bf9 | ||
|
|
2a5d5d3bea | ||
|
|
419153d654 | ||
|
|
ed8c504c27 | ||
|
|
2c29f11a8b | ||
|
|
c442cd1deb | ||
|
|
770e3e866c | ||
|
|
4014046444 | ||
|
|
6f378297dd | ||
|
|
1c5c33be6a | ||
|
|
206665a40b | ||
|
|
159eb54e4e | ||
|
|
f63ab7b693 | ||
|
|
97e5f73774 | ||
|
|
9f85149776 | ||
|
|
d6fa68dead | ||
|
|
5e42fdbfbe | ||
|
|
9b20d1754b | ||
|
|
d310fa3688 | ||
|
|
7ab3e8040c | ||
|
|
5173c24546 | ||
|
|
0c1cccfdcd | ||
|
|
d36cd47597 | ||
|
|
6f34d11138 | ||
|
|
bf3f7bb6ad | ||
|
|
28f74aa50a | ||
|
|
dc3c605315 | ||
|
|
5abc8004c7 | ||
|
|
bf1e971edd | ||
|
|
37c767dc74 | ||
|
|
8257b4f7f6 | ||
|
|
0340f4512e | ||
|
|
c45ce0d090 | ||
|
|
add3dcaa26 | ||
|
|
4a88b10e61 | ||
|
|
7001d0f7fc | ||
|
|
fdf72b14eb | ||
|
|
830de0388a | ||
|
|
4a77c6bdd3 | ||
|
|
579844f193 | ||
|
|
4c6073c02a | ||
|
|
b1eb591e20 | ||
|
|
f5ee776586 |
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: BenCodez # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
#patreon: # Replace with a single Patreon username
|
||||
#open_collective: # Replace with a single Open Collective username
|
||||
#ko_fi: # Replace with a single Ko-fi username
|
||||
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
#liberapay: # Replace with a single Liberapay username
|
||||
#issuehunt: # Replace with a single IssueHunt username
|
||||
#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
||||
#polar: # Replace with a single Polar username
|
||||
#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username
|
||||
custom: ["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YQBX25RTXJ5DG"]
|
||||
File renamed without changes.
@@ -5,3 +5,4 @@
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.factorypath
|
||||
@@ -14,8 +14,19 @@ UseBungeecord: false
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
# REDIS (2nd Most Recommended)
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
|
||||
Redis:
|
||||
Host: localhost
|
||||
Port: 6379
|
||||
# To get the user name, run redis-cli, if you set a password, run "auth <your password>" and if the out put is "OK" run "ACL USERS"
|
||||
Username: 'default'
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using multi-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
# Enables more debug messages for communication between servers
|
||||
# Use /votingpluginbungee status for testing communication
|
||||
BungeeDebug: false
|
||||
|
||||
@@ -50,7 +50,7 @@ VoteReminding:
|
||||
# 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"
|
||||
# To remind if all votesites are available (rather than any) use the permission "VotingPlugin.Login.RemindVotes.All"
|
||||
Enabled: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
@@ -517,6 +517,12 @@ QueueVotesDuringTimeChange: false
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Experiemtental feature
|
||||
# Uses https://github.com/BenCodez/VotingPlugin/wiki/Minecraft-Server-Lists
|
||||
# Not all voting sites use the domain name as the service sites
|
||||
# This feature is an attempt to ease setup for new users by matching domain name to actual service site
|
||||
AdvancedServiceSiteHandling: false
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
@@ -71,7 +71,7 @@ CHEST:
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
# 'ExtraName' below is an identifier, can be whatever
|
||||
# 'ExtraItem' below is an identifier, can be whatever
|
||||
# ExtraItem:
|
||||
# Item:
|
||||
# Material: 'DIRT'
|
||||
@@ -335,6 +335,8 @@ CHEST:
|
||||
Cost: 3
|
||||
# Permission required, leave blank for no permission
|
||||
Permission: ''
|
||||
# Hide if player doesn't have permission (only if permission is set)
|
||||
HideOnNoPermission: true
|
||||
# Whether or not to keep GUI open after purchase
|
||||
CloseGUI: true
|
||||
# Require confirmation on purchase, overrides global option above
|
||||
|
||||
@@ -83,7 +83,9 @@ VoteParty:
|
||||
OnlyOncePerDay: false
|
||||
# If true, will give voteparty once per week only
|
||||
OnlyOncePerWeek: false
|
||||
# Reset extra votes
|
||||
# Reset extra votes weekly
|
||||
ResetExtraVotesWeekly: false
|
||||
# Reset extra votes monthly
|
||||
ResetExtraVotesMonthly: false
|
||||
# Count votes from /av vote?
|
||||
CountFakeVotes: true
|
||||
|
||||
@@ -38,6 +38,7 @@ VoteSites:
|
||||
VoteDelay: 24
|
||||
|
||||
# Use to have a minute votedelay
|
||||
# Must set a value on VoteDelay if you plan on only using this setting
|
||||
#VoteDelayMin: 30
|
||||
|
||||
# Require waiting until votedelay time has pasted in order to accept vote
|
||||
@@ -118,7 +119,7 @@ VoteSites:
|
||||
Messages:
|
||||
Player: 'You got unlucky'
|
||||
|
||||
# Give 1 diamond
|
||||
# Give 1 diamond regardless of above
|
||||
Items:
|
||||
item1:
|
||||
Material: DIAMOND
|
||||
|
||||
@@ -19,10 +19,6 @@ Prefix: ''
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# Online mode for UUIDS
|
||||
# Offline mode setups are not fully tested and are not supported currently
|
||||
OnlineMode: true
|
||||
|
||||
|
||||
####################################################################################
|
||||
# Global mysql data handle for between server commmunications
|
||||
@@ -86,8 +82,18 @@ WhiteListedServers: []
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
# REDIS
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
|
||||
Redis:
|
||||
Host: localhost
|
||||
Port: 6379
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using mutli-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
# If false, votes will be checked if user is a valid player that has joined to server
|
||||
# Works for PLUGINMESSAGING and SOCKETS methods only
|
||||
# This requires spigot servers AllowUnJoined to be set to true in Config.yml
|
||||
@@ -140,6 +146,9 @@ VoteParty:
|
||||
BungeeCommands: []
|
||||
Broadcast: '&aVote party has been reached!'
|
||||
|
||||
# Online mode for UUIDS
|
||||
# Offline mode setups are not fully tested and are not supported currently
|
||||
OnlineMode: true
|
||||
|
||||
##########################################
|
||||
# PLUGINMESSAGING Settings
|
||||
@@ -147,19 +156,19 @@ VoteParty:
|
||||
|
||||
# Applies to PLUGINMESSAGING only
|
||||
# Votes will be forwarded when specific player is online
|
||||
# If set to false, rewards should still reward when player logs in (by default)
|
||||
WaitForUserOnline: false
|
||||
|
||||
|
||||
##########################################
|
||||
# Multi-proxy setup
|
||||
# This is still a WIP, use with caution
|
||||
# Primary server needs votifier and config option enabled
|
||||
# Primary server needs votifier and config option enabled
|
||||
# Set socket host on each proxy and primary server set sub proxies
|
||||
# All servers should be on pluginmessaging or sockets setup
|
||||
##########################################
|
||||
|
||||
# Support for redis
|
||||
# experimental
|
||||
# Support for multiple proxies
|
||||
MultiProxySupport: false
|
||||
|
||||
# Enable on primary proxy server with votifier
|
||||
@@ -170,12 +179,46 @@ PrimaryServer: false
|
||||
# Must also disable sendtoallservers
|
||||
MultiProxyOneGlobalReward: false
|
||||
|
||||
# Multi-proxy available methods:
|
||||
# SOCKET
|
||||
# REDIS
|
||||
MultiProxyMethod: SOCKET
|
||||
|
||||
##########################################
|
||||
# REDIS Settings
|
||||
##########################################
|
||||
|
||||
# Set multiproxymethod to REDIS to use redis
|
||||
MultiProxyRedis:
|
||||
# If true the plugin will use the exsiting connection set above
|
||||
# Must be on REDIS method to use this setting
|
||||
UseExistingConnection: false
|
||||
Host: localhost
|
||||
Port: 6379
|
||||
Username: ''
|
||||
Password: ''
|
||||
|
||||
# Set each server it's own proxy name here (can be anything)
|
||||
ProxyServerName: proxy1
|
||||
|
||||
# Set names of other proxy servers
|
||||
# Must match what's set as the proxy server name above from other servers
|
||||
# On non primary proxy server just set the primary proxy server name here
|
||||
ProxyServers:
|
||||
- proxy2
|
||||
- proxy3
|
||||
|
||||
##########################################
|
||||
# SOCKET settings for mutli-proxy
|
||||
##########################################
|
||||
|
||||
# Set this for each proxy
|
||||
MultiProxySocketHost:
|
||||
Host: 0.0.0.0
|
||||
Port: 1234
|
||||
|
||||
# Set other sub proxies here
|
||||
# On non primary proxy only set primary proxy
|
||||
MultiProxyServers:
|
||||
secondproxy:
|
||||
Host: 0.0.0.0
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
name: ${project.name}
|
||||
version: "${project.version}"
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.VotingPluginMain
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
@@ -141,106 +141,106 @@ commands:
|
||||
adminvotegivereward:
|
||||
description: Command Alias
|
||||
aliases: avgivereward
|
||||
adminvoteConvertFromData:
|
||||
adminvoteconvertfromdata:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteConvertToData:
|
||||
aliases: avconvertfromdata
|
||||
adminvoteonverttodata:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
aliases: avconverttodata
|
||||
adminvotecleartotal:
|
||||
description: Command Alias
|
||||
adminvoteBackgroundUpdate:
|
||||
adminvotebackgroundupdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
aliases: avbackgroundupdate
|
||||
adminvoteclearcache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteServiceSites:
|
||||
aliases: avclearcache
|
||||
adminvoteservicesites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteVoteParty:
|
||||
aliases: avservicesites
|
||||
adminvotevoteparty:
|
||||
description: Command Alias
|
||||
aliases: avVoteParty
|
||||
adminvoteChoices:
|
||||
aliases: avvoteparty
|
||||
adminvotechoices:
|
||||
description: Command Alias
|
||||
aliases: avChoices
|
||||
adminvoteReloadAll:
|
||||
aliases: avchoices
|
||||
adminvotereloadall:
|
||||
description: Command Alias
|
||||
aliases: avReloadAll
|
||||
adminvotePermsPlayer:
|
||||
aliases: avreloadall
|
||||
adminvotepermsplayer:
|
||||
description: Command Alias
|
||||
aliases: avPermsPlayer
|
||||
adminvoteResyncMilestonesAlreadyGiven:
|
||||
aliases: avpermsplayer
|
||||
adminvoteresyncmilestonesalreadygiven:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestonesAlreadyGiven
|
||||
voteSetPrimaryAccount:
|
||||
aliases: avresyncmilestonesalreadygiven
|
||||
votesetprimaryaccount:
|
||||
description: Command Alias
|
||||
adminvoteClearOfflineVotes:
|
||||
adminvoteclearofflinevotes:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineVotes
|
||||
adminvoteGiveAll:
|
||||
aliases: avclearofflinevotes
|
||||
adminvotegiveall:
|
||||
description: Command Alias
|
||||
aliases: avGiveAll
|
||||
adminvoteGiveAllOnline:
|
||||
aliases: avgiveall
|
||||
adminvotegiveallonline:
|
||||
description: Command Alias
|
||||
aliases: avGiveAllOnline
|
||||
adminvoteForceTimeChanged:
|
||||
aliases: avgiveallonline
|
||||
adminvoteforcetimechanged:
|
||||
description: Command Alias
|
||||
aliases: avForceTimeChanged
|
||||
aliases: avforcetimechanged
|
||||
adminvoteplayername:
|
||||
description: Command Alias
|
||||
aliases: avplayername
|
||||
adminvoteResyncMilestones:
|
||||
adminvoteresyncmilestones:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestones
|
||||
adminvoteClearOfflineRewards:
|
||||
aliases: avresyncmilestones
|
||||
adminvoteclearofflinerewards:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineRewards
|
||||
adminvoteUserRemove:
|
||||
aliases: avclearofflinerewards
|
||||
adminvoteuserremove:
|
||||
description: Command Alias
|
||||
aliases: avUserRemove
|
||||
adminvotePurge:
|
||||
aliases: avuserremove
|
||||
adminvotepurge:
|
||||
description: Command Alias
|
||||
aliases: avPurge
|
||||
adminvoteJavascript:
|
||||
aliases: avpurge
|
||||
adminvotejavascript:
|
||||
description: Command Alias
|
||||
aliases: avJavascript
|
||||
adminvoteStatus:
|
||||
aliases: avjavascript
|
||||
adminvotestatus:
|
||||
description: Command Alias
|
||||
aliases: avStatus
|
||||
adminvoteTest:
|
||||
aliases: avstatus
|
||||
adminvotetest:
|
||||
description: Command Alias
|
||||
aliases: avTest
|
||||
adminvotePlaceholders:
|
||||
aliases: avtest
|
||||
adminvoteplaceholders:
|
||||
description: Command Alias
|
||||
aliases: avPlaceholders
|
||||
adminvoteDownloadJenkins:
|
||||
aliases: avplaceholders
|
||||
adminvotedownloadjenkins:
|
||||
description: Command Alias
|
||||
aliases: avDownloadJenkins
|
||||
adminvoteSetRequestMethod:
|
||||
aliases: avdownloadjenkins
|
||||
adminvotesetrequestmethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
adminvoteUser:
|
||||
aliases: avsetrequestmethod
|
||||
adminvoteuser:
|
||||
description: Command Alias
|
||||
aliases: avUser
|
||||
adminvoteCurrentPluginTime:
|
||||
aliases: avuser
|
||||
adminvotecurrentplugintime:
|
||||
description: Command Alias
|
||||
aliases: avCurrentPluginTime
|
||||
adminvoteResetPoints:
|
||||
aliases: avcurrentplugintime
|
||||
adminvoteresetpoints:
|
||||
description: Command Alias
|
||||
aliases: avResetPoints
|
||||
adminvoteRunCMD:
|
||||
aliases: avresetpoints
|
||||
adminvoteruncmd:
|
||||
description: Command Alias
|
||||
aliases: avRunCMD
|
||||
aliases: avruncmd
|
||||
adminvoteuseruuidremove:
|
||||
description: Command Alias
|
||||
aliases: avuseruuidremove
|
||||
adminvoteedit:
|
||||
description: Command Alias
|
||||
aliases: avedit
|
||||
adminvoteResetMilestoneCount:
|
||||
adminvoteresetmilestonecount:
|
||||
description: Command Alias
|
||||
aliases: avResetMilestoneCount
|
||||
aliases: avresetmilestonecount
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
@@ -257,6 +257,9 @@ permissions:
|
||||
VotingPlugin.NoRemind:
|
||||
description: Ignore vote reminding
|
||||
default: false
|
||||
VotingPlugin.BypassWaitUntilVoteDelay:
|
||||
description: Bypass WaitUntilVoteDelay
|
||||
default: false
|
||||
VotingPlugin.Sign.Create:
|
||||
description: Permission to create sign
|
||||
VotingPlugin.Admin.GenerateServiceSite:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>${version.art}</artifactId>
|
||||
<version>6.14.2</version>
|
||||
<version>6.16</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -59,7 +59,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.4.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -88,7 +88,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<version>3.5.3</version>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
@@ -221,19 +221,19 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<version>1.18.32</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.1</version>
|
||||
<version>1.20-R0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -415,7 +415,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.6.2</version>
|
||||
<version>3.6.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -465,7 +465,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.6.2</version>
|
||||
<version>3.6.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
@@ -22,9 +23,13 @@ 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;
|
||||
@@ -61,6 +66,14 @@ public class BungeeHandler implements Listener {
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
@Getter
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Getter
|
||||
private GlobalMessageHandler globalMessageHandler;
|
||||
|
||||
private Thread redisThread;
|
||||
|
||||
public BungeeHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@@ -261,9 +274,369 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
loadGlobalMysql();
|
||||
|
||||
globalMessageHandler = new GlobalMessageHandler() {
|
||||
|
||||
@Override
|
||||
public void sendMessage(String subChannel, String... messageData) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.getInstance().convert(messageData));
|
||||
sendData(ArrayUtils.getInstance().convert(list));
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.getInstance().convert(messageData));
|
||||
redisHandler.sendMessage(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
|
||||
ArrayUtils.getInstance().convert(list));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("Vote") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 8) {
|
||||
int bungeeVersion = Integer.parseInt(args.get(8));
|
||||
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers"
|
||||
+ bungeeVersion + ":" + BungeeVersion.getPluginMessageVersion());
|
||||
return;
|
||||
}
|
||||
|
||||
String player = args.get(0);
|
||||
String uuid = args.get(1);
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.cache();
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteOnline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 8) {
|
||||
int bungeeVersion = Integer.parseInt(args.get(8));
|
||||
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
return;
|
||||
}
|
||||
String player = args.get(0);
|
||||
String uuid = args.get(1);
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
plugin.debug("pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.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));
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteUpdate") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(player));
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
if (args.size() > 3 && plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(3));
|
||||
plugin.getSpecialRewards().checkMilestone(user, text, true);
|
||||
}
|
||||
|
||||
if (args.size() > 2) {
|
||||
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
|
||||
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("BungeeTimeChange") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteBroadcastOffline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String votes = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("Status") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String server = args.get(0);
|
||||
sendMessage(globalMessageHandler, "statusokay", server);
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("ServerName") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String server = args.get(0);
|
||||
if (!plugin.getOptions().getServer().equals(server)) {
|
||||
plugin.getLogger().warning("Server name doesn't match in BungeeSettings.yml, should be " + server);
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBungee") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String broadcast = args.get(0);
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
} 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.getInstance().makeStringList(ArrayUtils.getInstance().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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
redisThread = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.isEnabled()) {
|
||||
redisHandler.loadListener(
|
||||
new RedisListener(redisHandler, plugin.getBungeeSettings().getRedisPrefix()
|
||||
+ "VotingPlugin_" + plugin.getBungeeSettings().getServer()));
|
||||
}
|
||||
}
|
||||
});
|
||||
redisThread.start();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
@@ -274,279 +647,71 @@ public class BungeeHandler implements Listener {
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
if (args.size() > 8) {
|
||||
int bungeeVersion = Integer.parseInt(args.get(8));
|
||||
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
return;
|
||||
}
|
||||
|
||||
String player = args.get(0);
|
||||
String uuid = args.get(1);
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.cache();
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
}
|
||||
|
||||
globalMessageHandler.onMessage("Vote", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteOnline") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
if (args.size() > 8) {
|
||||
int bungeeVersion = Integer.parseInt(args.get(8));
|
||||
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
return;
|
||||
}
|
||||
String player = args.get(0);
|
||||
String uuid = args.get(1);
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
plugin.debug(
|
||||
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.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));
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
}
|
||||
globalMessageHandler.onMessage("VoteOnline", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteUpdate") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(player));
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
if (args.size() > 2) {
|
||||
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
|
||||
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
globalMessageHandler.onMessage("VoteUpdate", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("BungeeTimeChange") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
checkGlobalData();
|
||||
globalMessageHandler.onMessage("BungeeTimeChange", args);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
globalMessageHandler.onMessage("VoteBroadcast", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcastOffline") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String votes = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
globalMessageHandler.onMessage("VoteBroadcastOffline", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String server = args.get(0);
|
||||
plugin.getPluginMessaging().sendPluginMessage("statusokay", server);
|
||||
globalMessageHandler.onMessage("Status", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("ServerName") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("ServerName", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
globalMessageHandler.onMessage("VotePartyBungee", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String broadcast = args.get(0);
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
globalMessageHandler.onMessage("VotePartyBroadcast", args);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.placeholders.MVdWPlaceholders;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceHolders;
|
||||
import com.bencodez.votingplugin.placeholders.VotingPluginExpansion;
|
||||
import com.bencodez.votingplugin.servicesites.ServiceSiteHandler;
|
||||
import com.bencodez.votingplugin.signs.Signs;
|
||||
import com.bencodez.votingplugin.specialrewards.SpecialRewards;
|
||||
import com.bencodez.votingplugin.test.VoteTester;
|
||||
@@ -342,28 +343,41 @@ 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);
|
||||
|
||||
for (String url : urls) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
if (sites != null) {
|
||||
for (String siteName : sites) {
|
||||
String URL = getConfigVoteSites().getServiceSite(siteName);
|
||||
if (URL != null) {
|
||||
if (URL.equalsIgnoreCase(url)) {
|
||||
if (!url.isEmpty()) {
|
||||
if (sites != null) {
|
||||
for (String siteName : sites) {
|
||||
String URL = getConfigVoteSites().getServiceSite(siteName);
|
||||
if (URL != null) {
|
||||
if (URL.equalsIgnoreCase(url)) {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
if (siteName.equalsIgnoreCase(url)) {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
if (siteName.equalsIgnoreCase(url)) {
|
||||
return siteName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
for (String url : urls) {
|
||||
return url;
|
||||
}
|
||||
@@ -1057,6 +1071,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
checkUpdate.startUp();
|
||||
voteReminding = new VoteReminding(this);
|
||||
voteReminding.loadRemindChecking();
|
||||
voteReminding.loadReminds();
|
||||
specialRewards = new SpecialRewards(this);
|
||||
signs = new Signs(this);
|
||||
|
||||
@@ -1230,10 +1245,21 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
"Detected an issue with voting sites, check the server startup log for more details: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
|
||||
}
|
||||
}, 5);
|
||||
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
serviceSiteHandler = new ServiceSiteHandler(plugin);
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ServiceSiteHandler serviceSiteHandler;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
|
||||
@@ -161,7 +161,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getVoteSites().size();
|
||||
return "" + plugin.getVoteSitesEnabled().size();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards", new Callable<String>() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
public enum BungeeMethod {
|
||||
MYSQL, PLUGINMESSAGING, SOCKETS;
|
||||
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS;
|
||||
|
||||
public static BungeeMethod getByName(String str) {
|
||||
for (BungeeMethod method : values()) {
|
||||
@@ -9,6 +9,6 @@ public enum BungeeMethod {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return SOCKETS;
|
||||
return PLUGINMESSAGING;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,26 @@ 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 boolean getAllowUnJoined() {
|
||||
return getData().getBoolean("AllowUnJoined", false);
|
||||
}
|
||||
@@ -153,6 +173,22 @@ public class Config {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
public String getMultiProxyMethod() {
|
||||
return getData().getString("MultiProxyMethod", "SOCKET");
|
||||
}
|
||||
|
||||
public String getProxyServerName() {
|
||||
return getData().getString("ProxyServerName", "SOCKET");
|
||||
}
|
||||
|
||||
public List<String> getProxyServers() {
|
||||
return getData().getStringList("ProxyServers");
|
||||
}
|
||||
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getData().getBoolean("MultiProxyRedis.UseExistingConnection", false);
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
}
|
||||
@@ -161,6 +197,22 @@ public class Config {
|
||||
return getData().getStringList("VoteParty.BungeeCommands");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getData().getString("MultiProxyRedis.Host", "");
|
||||
}
|
||||
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getData().getInt("MultiProxyRedis.Port", 6379);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getData().getString("MultiProxyRedis.Username", "");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getData().getString("MultiProxyRedis.Password", "");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
|
||||
@@ -28,6 +28,13 @@ public class NonVotedPlayersCache {
|
||||
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() {
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@@ -44,10 +45,16 @@ import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConf
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.mysql.BungeeMySQL;
|
||||
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.advancedcore.bungeeapi.time.BungeeTimeChecker;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyHandler;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyMethod;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfiguration;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfigurationBungee;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -71,16 +78,12 @@ import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedVotes = new ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<String, ClientHandler> clientHandles;
|
||||
|
||||
private HashMap<String, ClientHandler> multiproxyClientHandles;
|
||||
|
||||
private SocketHandler multiproxySocketHandler;
|
||||
|
||||
@Getter
|
||||
private Config config;
|
||||
|
||||
@@ -110,6 +113,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
@Getter
|
||||
private GlobalDataHandlerProxy globalDataHandler;
|
||||
|
||||
@Getter
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
public synchronized void checkCachedVotes(String server) {
|
||||
if (getProxy().getServerInfo(server) != null) {
|
||||
if (!getProxy().getServerInfo(server).getPlayers().isEmpty()) {
|
||||
@@ -132,7 +138,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
}
|
||||
if (toSend) {
|
||||
sendPluginMessageServer(server, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
sendMessageServer(server, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
@@ -164,7 +170,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
int num = 1;
|
||||
int numberOfVotes = c.size();
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendPluginMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
sendMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num,
|
||||
@@ -173,7 +179,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
|
||||
sendMultiProxyServerMessage("ClearVote", player.getName(), uuid);
|
||||
multiProxyHandler.sendMultiProxyServerMessage("ClearVote", player.getName(), uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -552,6 +558,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
private VoteEventBungee voteEventBungee;
|
||||
|
||||
@Getter
|
||||
private MultiProxyHandler multiProxyHandler;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
enabled = true;
|
||||
@@ -798,6 +807,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
debug("Checking nonvotedplayers.yml...");
|
||||
nonVotedPlayersCache.check();
|
||||
}
|
||||
if (voteCacheFile != null) {
|
||||
voteCacheFile.save();
|
||||
}
|
||||
}
|
||||
}, 1l, 60l, TimeUnit.MINUTES);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
@@ -850,13 +862,54 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
encryptionHandler, config.getDebug()));
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
redisHandler = new RedisHandler(config.getRedisHost(), config.getRedisPort(), config.getRedisUsername(),
|
||||
config.getRedisPassword()) {
|
||||
|
||||
@Override
|
||||
protected void onMessage(String channel, String[] message) {
|
||||
if (message.length > 0) {
|
||||
if (message[0].equalsIgnoreCase("statusokay")) {
|
||||
String server = message[1];
|
||||
getLogger().info("Status okay for " + server);
|
||||
} else if (message[0].equalsIgnoreCase("login")) {
|
||||
String player = message[1];
|
||||
String uuid = message[2];
|
||||
String server = "";
|
||||
if (message.length > 3) {
|
||||
server = message[3];
|
||||
}
|
||||
debug("Login: " + player + "/" + uuid + " " + server);
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayerCheck(uuid, player);
|
||||
}
|
||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
||||
login(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
debug2(message);
|
||||
}
|
||||
};
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
redisHandler.loadListener(
|
||||
new RedisListener(redisHandler, getConfig().getRedisPrefix() + "VotingPlugin"));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
}
|
||||
|
||||
loadMultiProxySupport();
|
||||
loadMultiProxySupport();
|
||||
}
|
||||
|
||||
if (!votifierEnabled) {
|
||||
if (!(getConfig().getMultiProxySupport() && !getConfig().getPrimaryServer())) {
|
||||
@@ -905,63 +958,156 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
getLogger().info("Detected using dev build number: " + buildNumber);
|
||||
}
|
||||
sendServerNameMessage();
|
||||
|
||||
}
|
||||
|
||||
public void loadMultiProxySupport() {
|
||||
if (getConfig().getMultiProxySupport()) {
|
||||
if (encryptionHandler == null) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
}
|
||||
private void runAsyncNow(Runnable runnable) {
|
||||
getProxy().getScheduler().runAsync(this, runnable);
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(getDescription().getVersion(),
|
||||
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
|
||||
config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
multiproxySocketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 0) {
|
||||
if (data[0].equalsIgnoreCase("Status")) {
|
||||
getLogger().info("Multi-proxy status message received");
|
||||
} else if (data[0].equalsIgnoreCase("ClearVote")) {
|
||||
cachedOnlineVotes.remove(data[2]);
|
||||
} else if (data[0].equalsIgnoreCase("login")) {
|
||||
nonVotedPlayersCache.addPlayer(data[1], data[2]);
|
||||
}
|
||||
}
|
||||
if (data.length > 8) {
|
||||
if (data[0].equalsIgnoreCase("Vote")) {
|
||||
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
|
||||
data[1]);
|
||||
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
|
||||
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
|
||||
data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
multiproxyClientHandles = new HashMap<String, ClientHandler>();
|
||||
for (String s : config.getMultiProxyServers()) {
|
||||
Configuration d = config.getMultiProxyServersConfiguration(s);
|
||||
multiproxyClientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1234),
|
||||
encryptionHandler, config.getDebug()));
|
||||
}
|
||||
|
||||
getLogger().info("Loaded multi-proxy support");
|
||||
private void loadMultiProxySupport() {
|
||||
if (multiProxyHandler != null) {
|
||||
multiProxyHandler.close();
|
||||
}
|
||||
multiProxyHandler = new MultiProxyHandler() {
|
||||
|
||||
@Override
|
||||
public void triggerVote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
|
||||
BungeeMessageData text, String uuid) {
|
||||
vote(player, service, realVote, timeQueue, queueTime, text, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionHandler(EncryptionHandler encryptionHandler1) {
|
||||
encryptionHandler = encryptionHandler1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logInfo(String msg) {
|
||||
getLogger().info(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxySupportEnabled() {
|
||||
return config.getMultiProxySupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return config.getMultiProxySocketHostPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return config.getMultiProxySocketHostHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s) {
|
||||
return new MultiProxyServerSocketConfigurationBungee(s, config.getMultiProxyServersConfiguration(s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getMultiProxyServers() {
|
||||
return config.getMultiProxyServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EncryptionHandler getEncryptionHandler() {
|
||||
return encryptionHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDebug() {
|
||||
return config.getDebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getPluginDataFolder() {
|
||||
return getDataFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearVote(String string) {
|
||||
cachedOnlineVotes.remove(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNonVotedPlayerCache(String uuid, String player) {
|
||||
nonVotedPlayersCache.addPlayer(uuid, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPrimaryServer() {
|
||||
return config.getPrimaryServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getProxyServers() {
|
||||
return config.getProxyServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsnc(Runnable runnable) {
|
||||
runAsyncNow(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiProxyMethod getMultiProxyMethod() {
|
||||
return MultiProxyMethod.getByName(config.getMultiProxyMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisHandler getRedisHandler() {
|
||||
return redisHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return config.getMultiProxyRedisUseExistingConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyPassword() {
|
||||
return config.getMultiProxyRedisPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyUsername() {
|
||||
return config.getMultiProxyRedisUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxyRedisPort() {
|
||||
return config.getMultiProxyRedisPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisHost() {
|
||||
return config.getMultiProxyRedisHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyServerName() {
|
||||
return config.getProxyServerName();
|
||||
}
|
||||
};
|
||||
multiProxyHandler.loadMultiProxySupport();
|
||||
}
|
||||
|
||||
public void sendServerNameMessage() {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (String s : getAvailableAllServers()) {
|
||||
sendPluginMessageServer(s, "ServerName", s);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -997,7 +1143,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
if (isOnline(p)) {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(proxiedPlayer, proxiedPlayer.getUniqueId().toString(), server);
|
||||
multiProxyLogin(proxiedPlayer);
|
||||
multiProxyHandler.login(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
|
||||
}
|
||||
}
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
@@ -1005,18 +1151,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
}
|
||||
|
||||
public void multiProxyLogin(ProxiedPlayer p) {
|
||||
if (!config.getMultiProxySupport()) {
|
||||
return;
|
||||
}
|
||||
if (config.getPrimaryServer()) {
|
||||
return;
|
||||
}
|
||||
if (!config.getAllowUnJoined()) {
|
||||
sendMultiProxyServerMessage("Login", p.getUniqueId().toString(), p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent ev) {
|
||||
if (!ev.getTag().equals("vp:vp".toLowerCase())) {
|
||||
@@ -1110,6 +1244,22 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
loadMultiProxySupport();
|
||||
}
|
||||
|
||||
public void sendMessageServer(String server, String channel, String... messageData) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(server, channel, messageData);
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
sendRedisMessageServer(server, channel, messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendRedisMessageServer(String server, String channel, String... messageData) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(channel);
|
||||
list.addAll(ArrayUtils.getInstance().convert(messageData));
|
||||
redisHandler.sendMessage(getConfig().getRedisPrefix() + "VotingPlugin_" + server,
|
||||
ArrayUtils.getInstance().convert(list));
|
||||
}
|
||||
|
||||
public void sendPluginMessageServer(String server, String channel, String... messageData) {
|
||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||
@@ -1137,12 +1287,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMultiProxyServerMessage(String... messageData) {
|
||||
for (ClientHandler h : multiproxyClientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendServerMessageServer(String server, String... messageData) {
|
||||
if (clientHandles.containsKey(server)) {
|
||||
clientHandles.get(server).sendMessage(messageData);
|
||||
@@ -1185,7 +1329,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
public void status(CommandSender sender) {
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
|
||||
for (String s : getAvailableAllServers()) {
|
||||
ServerInfo info = getProxy().getServerInfo(s);
|
||||
if (info.getPlayers().isEmpty()) {
|
||||
@@ -1193,7 +1337,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
} else {
|
||||
// send
|
||||
getLogger().info("Sending request for status message on " + s);
|
||||
sendPluginMessageServer(s, "Status", s);
|
||||
sendMessageServer(s, "Status", s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1306,7 +1450,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
for (String s : getAvailableAllServers()) {
|
||||
@@ -1317,7 +1461,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
debug("Forcing vote to cache");
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
if (info.getPlayers().isEmpty() || forceCache) {
|
||||
// cache
|
||||
@@ -1332,21 +1476,20 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
} else {
|
||||
// send
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
sendMessageServer(s, "Vote", player, uuid, service, "" + time, Boolean.TRUE.toString(),
|
||||
"" + realVote, text.toString(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "1", "1");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (isOnline(p) && getAvailableAllServers().contains(p.getServer().getInfo().getName())) {
|
||||
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
|
||||
sendMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + config.getBroadcast(), "1", "1");
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
|
||||
sendMultiProxyServerMessage("ClearVote", player, uuid);
|
||||
multiProxyHandler.sendMultiProxyServerMessage("ClearVote", player, uuid);
|
||||
}
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
@@ -1362,10 +1505,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
for (String s : getAvailableAllServers()) {
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired);
|
||||
sendMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, text.toString());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1375,14 +1518,15 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getPrimaryServer()) {
|
||||
if (!getConfig().getMultiProxyOneGlobalReward()) {
|
||||
debug("Seending global proxy vote message");
|
||||
sendMultiProxyServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
|
||||
multiProxyHandler.sendMultiProxyServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
|
||||
} else {
|
||||
// check if reward should've already been given
|
||||
if (!(isOnline(p) && !config.getBlockedServers().contains(p.getServer().getInfo().getName()))) {
|
||||
debug("Sending global proxy voteonline message");
|
||||
sendMultiProxyServerMessage("VoteOnline", uuid, player, service, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
|
||||
multiProxyHandler.sendMultiProxyServerMessage("VoteOnline", uuid, player, service,
|
||||
"" + votePartyVotes, "" + currentVotePartyVotesRequired, "" + time, "" + realVote,
|
||||
text.toString());
|
||||
} else {
|
||||
debug("Not sending global proxy message for voteonline, player already got reward");
|
||||
}
|
||||
|
||||
@@ -49,14 +49,20 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
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 method, command unavailable"));
|
||||
new TextComponent("&aNot using socket/pluginmessage/redis method, command unavailable"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("multiproxystatus")) {
|
||||
bungee.sendMultiProxyServerMessage("Status");
|
||||
sender.sendMessage(new TextComponent("&aSending status message"));
|
||||
bungee.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
|
||||
sender.sendMessage(new TextComponent("Sending status message"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
TextComponent[] msg = new TextComponent[7];
|
||||
|
||||
+229
@@ -0,0 +1,229 @@
|
||||
package com.bencodez.votingplugin.bungee.global.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 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;
|
||||
|
||||
@Getter
|
||||
private RedisHandler multiProxyRedis;
|
||||
|
||||
public 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 List<String> getProxyServers();
|
||||
|
||||
public void close() {
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
if (multiProxyRedis != null && !getMultiProxyRedisUseExistingConnection()) {
|
||||
multiProxyRedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadMultiProxySupport() {
|
||||
if (getMultiProxySupportEnabled()) {
|
||||
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
|
||||
if (getEncryptionHandler() == null) {
|
||||
setEncryptionHandler(new EncryptionHandler(new File(getPluginDataFolder(), "secretkey.key")));
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(getVersion(), getMultiProxySocketHostHost(),
|
||||
getMultiProxySocketHostPort(), getEncryptionHandler(), getDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
logInfo(str);
|
||||
}
|
||||
};
|
||||
|
||||
multiproxySocketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 0) {
|
||||
if (data[0].equalsIgnoreCase("Status")) {
|
||||
logInfo("Multi-proxy status message received");
|
||||
} else if (data[0].equalsIgnoreCase("ClearVote")) {
|
||||
clearVote(data[2]);
|
||||
if (getPrimaryServer()) {
|
||||
sendMultiProxyServerMessage("ClearVotePrimary", data[1], data[2]);
|
||||
}
|
||||
} else if (data[0].equalsIgnoreCase("ClearVotePrimary")) {
|
||||
clearVote(data[2]);
|
||||
} else if (data[0].equalsIgnoreCase("login")) {
|
||||
addNonVotedPlayerCache(data[1], data[2]);
|
||||
// nonVotedPlayersCache.addPlayer(data[1], data[2]);
|
||||
}
|
||||
}
|
||||
if (data.length > 8) {
|
||||
if (data[0].equalsIgnoreCase("Vote")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
multiproxyClientHandles = new HashMap<String, ClientHandler>();
|
||||
for (String s : getMultiProxyServers()) {
|
||||
MultiProxyServerSocketConfiguration d = getMultiProxyServersConfiguration(s);
|
||||
multiproxyClientHandles.put(s,
|
||||
new ClientHandler(d.getHost(), d.getPort(), getEncryptionHandler(), getDebug()));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (getMultiProxyRedisUseExistingConnection() && getRedisHandler() != null) {
|
||||
multiProxyRedis = getRedisHandler();
|
||||
} else {
|
||||
multiProxyRedis = new RedisHandler(getMultiProxyRedisHost(), getMultiProxyRedisPort(),
|
||||
getMultiProxyUsername(), getMultiProxyPassword()) {
|
||||
|
||||
@Override
|
||||
public void onMessage(String channel, String[] data) {
|
||||
if (data.length > 0) {
|
||||
if (data[0].equalsIgnoreCase("Status")) {
|
||||
logInfo("Multi-proxy status message received");
|
||||
} else if (data[0].equalsIgnoreCase("ClearVote")) {
|
||||
clearVote(data[2]);
|
||||
if (getPrimaryServer()) {
|
||||
sendMultiProxyServerMessage("ClearVotePrimary", data[1], data[2]);
|
||||
}
|
||||
} else if (data[0].equalsIgnoreCase("ClearVotePrimary")) {
|
||||
clearVote(data[2]);
|
||||
} else if (data[0].equalsIgnoreCase("login")) {
|
||||
addNonVotedPlayerCache(data[1], data[2]);
|
||||
// nonVotedPlayersCache.addPlayer(data[1], data[2]);
|
||||
}
|
||||
}
|
||||
if (data.length > 8) {
|
||||
if (data[0].equalsIgnoreCase("Vote")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (getDebug()) {
|
||||
logInfo("MultiProxyRedis: " + message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
runAsnc(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
multiProxyRedis.loadListener(
|
||||
new RedisListener(multiProxyRedis, "VotingPluginProxy_" + getMultiProxyServerName()));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
logInfo("Loaded multi-proxy support: " + getMultiProxyMethod().toString());
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
return;
|
||||
}
|
||||
sendMultiProxyServerMessage("Login", uuid, playerName);
|
||||
}
|
||||
|
||||
public abstract int getMultiProxySocketHostPort();
|
||||
|
||||
public abstract String getMultiProxySocketHostHost();
|
||||
|
||||
public abstract MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s);
|
||||
|
||||
public abstract Collection<String> getMultiProxyServers();
|
||||
|
||||
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);
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
public enum MultiProxyMethod {
|
||||
SOCKETS, REDIS;
|
||||
|
||||
public static MultiProxyMethod getByName(String str) {
|
||||
for (MultiProxyMethod method : values()) {
|
||||
if (method.toString().equalsIgnoreCase(str)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return MultiProxyMethod.SOCKETS;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
public interface MultiProxyServerSocketConfiguration {
|
||||
String getServerName();
|
||||
|
||||
String getHost();
|
||||
|
||||
int getPort();
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class MultiProxyServerSocketConfigurationVelocity implements MultiProxyServerSocketConfiguration {
|
||||
|
||||
private String server;
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
public MultiProxyServerSocketConfigurationVelocity(String s, ConfigurationNode config) {
|
||||
server = s;
|
||||
host = config.getNode("Host").getString("0.0.0.0");
|
||||
port = config.getNode("Port").getInt(1298);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,6 +53,26 @@ public class Config extends VelocityYMLFile {
|
||||
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
|
||||
}
|
||||
|
||||
public String getRedisHost() {
|
||||
return getString(getNode("Redis", "Host"), "");
|
||||
}
|
||||
|
||||
public int getRedisPort() {
|
||||
return getInt(getNode("Redis", "Port"), 6379);
|
||||
}
|
||||
|
||||
public String getRedisUsername() {
|
||||
return getString(getNode("Redis", "Username"), "");
|
||||
}
|
||||
|
||||
public String getRedisPrefix() {
|
||||
return getString(getNode("Redis", "Prefix"), "");
|
||||
}
|
||||
|
||||
public String getRedisPassword() {
|
||||
return getString(getNode("Redis", "Password"), "");
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
@@ -165,4 +185,36 @@ public class Config extends VelocityYMLFile {
|
||||
return getInt(getNode("MultiProxySocketHost", "Port"), 1297);
|
||||
}
|
||||
|
||||
public String getMultiProxyMethod() {
|
||||
return getString(getNode("MultiProxyMethod"), "SOCKET");
|
||||
}
|
||||
|
||||
public String getProxyServerName() {
|
||||
return getString(getNode("ProxyServerName"), "SOCKET");
|
||||
}
|
||||
|
||||
public List<String> getProxyServers() {
|
||||
return getStringList(getNode("ProxyServers"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getBoolean(getNode("MultiProxyRedis", "UseExistingConnection"), false);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getString(getNode("MultiProxyRedis", "Host"), "");
|
||||
}
|
||||
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getInt(getNode("MultiProxyRedis", "Port"), 6379);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getString(getNode("MultiProxyRedis", "Username"), "");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getString(getNode("MultiProxyRedis", "Password"), "");
|
||||
}
|
||||
|
||||
}
|
||||
+7
-1
@@ -20,12 +20,18 @@ public class NonVotedPlayersCache extends VelocityJSONFile {
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayer(String uuid, String playerName) {
|
||||
public void addPlayer(String uuid, String playerName) {
|
||||
getNode("NonVotedPlayers", playerName, "UUID").setValue(uuid);
|
||||
getNode("NonVotedPlayers", playerName, "LastTime").setValue(System.currentTimeMillis());
|
||||
save();
|
||||
}
|
||||
|
||||
public void addPlayerCheck(String uuid, String playerName) {
|
||||
if (!plugin.getMysql().containsKeyQuery(uuid)) {
|
||||
addPlayer(uuid, playerName);
|
||||
}
|
||||
}
|
||||
|
||||
public void check() {
|
||||
for (String player : getKeys(getNode("NonVotedPlayers"))) {
|
||||
long time = getNode("NonVotedPlayers", player, "LastTime").getLong(0);
|
||||
|
||||
+259
-85
@@ -55,6 +55,8 @@ import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConf
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandlerProxy;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.mysql.VelocityMySQL;
|
||||
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;
|
||||
@@ -64,6 +66,10 @@ import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyHandler;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyMethod;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfiguration;
|
||||
import com.bencodez.votingplugin.bungee.global.multiproxy.MultiProxyServerSocketConfigurationVelocity;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.google.gson.JsonElement;
|
||||
@@ -93,8 +99,8 @@ import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
public class VotingPluginVelocity {
|
||||
|
||||
private static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.create("vp", "vp");
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
private HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>> cachedVotes = new HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>>();
|
||||
private ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new ConcurrentHashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
private ConcurrentHashMap<RegisteredServer, ArrayList<OfflineBungeeVote>> cachedVotes = new ConcurrentHashMap<RegisteredServer, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<String, ClientHandler> clientHandles;
|
||||
|
||||
@@ -134,9 +140,8 @@ public class VotingPluginVelocity {
|
||||
@Getter
|
||||
private GlobalDataHandlerProxy globalDataHandler;
|
||||
|
||||
private HashMap<String, ClientHandler> multiproxyClientHandles;
|
||||
|
||||
private SocketHandler multiproxySocketHandler;
|
||||
@Getter
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Inject
|
||||
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
|
||||
@@ -174,7 +179,7 @@ public class VotingPluginVelocity {
|
||||
|
||||
}
|
||||
if (toSend) {
|
||||
sendPluginMessageServer(serverToCheck, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
sendMessageServer(serverToCheck, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num,
|
||||
@@ -204,7 +209,7 @@ public class VotingPluginVelocity {
|
||||
int num = 1;
|
||||
int numberOfVotes = c.size();
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendPluginMessageServer(serverToCheck, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
sendMessageServer(serverToCheck, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num,
|
||||
@@ -213,7 +218,7 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
|
||||
sendMultiProxyServerMessage("ClearVote", player.getUsername(), uuid);
|
||||
getMultiProxyHandler().sendMultiProxyServerMessage("ClearVote", player.getUsername(), uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -507,6 +512,7 @@ public class VotingPluginVelocity {
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
|
||||
getMultiProxyHandler().login(p1.getUniqueId().toString(), p1.getUsername());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -876,6 +882,9 @@ public class VotingPluginVelocity {
|
||||
debug("Checking nonvotedplayerscache.yml...");
|
||||
nonVotedPlayersCache.check();
|
||||
}
|
||||
if (voteCacheFile != null) {
|
||||
voteCacheFile.save();
|
||||
}
|
||||
}).delay(1L, TimeUnit.MINUTES).repeat(60l, TimeUnit.MINUTES).schedule();
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
|
||||
@@ -928,6 +937,62 @@ public class VotingPluginVelocity {
|
||||
d.getNode("Port").getInt(1298), encryptionHandler, config.getDebug()));
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
redisHandler = new RedisHandler(config.getRedisHost(), config.getRedisPort(), config.getRedisUsername(),
|
||||
config.getRedisPassword()) {
|
||||
|
||||
@Override
|
||||
protected void onMessage(String channel, String[] message) {
|
||||
if (message.length > 0) {
|
||||
if (message[0].equalsIgnoreCase("statusokay")) {
|
||||
String server = message[1];
|
||||
getLogger().info("Status okay for " + server);
|
||||
} else if (message[0].equalsIgnoreCase("login")) {
|
||||
String player = message[1];
|
||||
String uuid = message[2];
|
||||
String serverName = "";
|
||||
if (message.length > 3) {
|
||||
serverName = message[3];
|
||||
}
|
||||
debug("Login: " + player + "/" + uuid + " " + serverName);
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayerCheck(uuid, player);
|
||||
}
|
||||
if (server.getPlayer(player).isPresent() && (getGlobalDataHandler() == null
|
||||
|| !getGlobalDataHandler().isTimeChangedHappened())) {
|
||||
Player p = server.getPlayer(player).get();
|
||||
if (p.getCurrentServer().isPresent()) {
|
||||
final RegisteredServer server = p.getCurrentServer().get().getServer();
|
||||
final Player p1 = p;
|
||||
timer.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
|
||||
getMultiProxyHandler().login(p1.getUniqueId().toString(),
|
||||
p1.getUsername());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
debug2(message);
|
||||
}
|
||||
};
|
||||
|
||||
server.getScheduler().buildTask(this, () -> {
|
||||
redisHandler.loadListener(
|
||||
new RedisListener(redisHandler, getConfig().getRedisPrefix() + "VotingPlugin"));
|
||||
}).schedule();
|
||||
|
||||
}
|
||||
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
@@ -987,64 +1052,162 @@ public class VotingPluginVelocity {
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
logger.info("Detected using dev build number: " + buildNumber);
|
||||
}
|
||||
sendServerNameMessage();
|
||||
}
|
||||
|
||||
public void loadMultiProxySupport() {
|
||||
if (getConfig().getMultiProxySupport()) {
|
||||
if (encryptionHandler == null) {
|
||||
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(
|
||||
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
|
||||
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
|
||||
config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
multiproxySocketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 0) {
|
||||
if (data[0].equalsIgnoreCase("Status")) {
|
||||
getLogger().info("Multi-proxy status message received");
|
||||
} else if (data[0].equalsIgnoreCase("ClearVote")) {
|
||||
cachedOnlineVotes.remove(data[2]);
|
||||
}
|
||||
}
|
||||
if (data.length > 8) {
|
||||
if (data[0].equalsIgnoreCase("Vote")) {
|
||||
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
|
||||
data[1]);
|
||||
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
|
||||
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
|
||||
data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
multiproxyClientHandles = new HashMap<String, ClientHandler>();
|
||||
|
||||
for (ConfigurationNode s : config.getMultiProxyServers()) {
|
||||
ConfigurationNode d = config.getMultiProxyServers(s.getKey().toString());
|
||||
multiproxyClientHandles.put(s.getKey().toString(),
|
||||
new ClientHandler(d.getNode("Host").getString("0.0.0.0"), d.getNode("Port").getInt(1298),
|
||||
encryptionHandler, config.getDebug()));
|
||||
}
|
||||
|
||||
getLogger().info("Loaded multi-proxy support");
|
||||
private void loadMultiProxySupport() {
|
||||
if (multiProxyHandler != null) {
|
||||
multiProxyHandler.close();
|
||||
}
|
||||
multiProxyHandler = new MultiProxyHandler() {
|
||||
|
||||
@Override
|
||||
public void triggerVote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
|
||||
BungeeMessageData text, String uuid) {
|
||||
vote(player, service, realVote, timeQueue, queueTime, text, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEncryptionHandler(EncryptionHandler encryptionHandler1) {
|
||||
encryptionHandler = encryptionHandler1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logInfo(String msg) {
|
||||
getLogger().info(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxySupportEnabled() {
|
||||
return config.getMultiProxySupport();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return config.getMultiProxySocketHostPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return config.getMultiProxySocketHostHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s) {
|
||||
return new MultiProxyServerSocketConfigurationVelocity(s, config.getMultiProxyServers(s));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getMultiProxyServers() {
|
||||
ArrayList<String> servers = new ArrayList<String>();
|
||||
for (ConfigurationNode s : config.getMultiProxyServers()) {
|
||||
servers.add(s.getKey().toString());
|
||||
}
|
||||
return servers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EncryptionHandler getEncryptionHandler() {
|
||||
return encryptionHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getDebug() {
|
||||
return config.getDebug();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getPluginDataFolder() {
|
||||
return dataDirectory.toFile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearVote(String string) {
|
||||
cachedOnlineVotes.remove(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addNonVotedPlayerCache(String uuid, String player) {
|
||||
nonVotedPlayersCache.addPlayer(uuid, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPrimaryServer() {
|
||||
return config.getPrimaryServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getProxyServers() {
|
||||
return config.getProxyServers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runAsnc(Runnable runnable) {
|
||||
runAsyncNow(runnable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiProxyMethod getMultiProxyMethod() {
|
||||
return MultiProxyMethod.getByName(config.getMultiProxyMethod());
|
||||
}
|
||||
|
||||
@Override
|
||||
public RedisHandler getRedisHandler() {
|
||||
return redisHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return config.getMultiProxyRedisUseExistingConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyPassword() {
|
||||
return config.getMultiProxyRedisPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyUsername() {
|
||||
return config.getMultiProxyRedisUsername();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultiProxyRedisPort() {
|
||||
return config.getMultiProxyRedisPort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyRedisHost() {
|
||||
return config.getMultiProxyRedisHost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMultiProxyServerName() {
|
||||
return config.getProxyServerName();
|
||||
}
|
||||
};
|
||||
multiProxyHandler.loadMultiProxySupport();
|
||||
}
|
||||
|
||||
private void runAsyncNow(Runnable runnable) {
|
||||
server.getScheduler().buildTask(this, runnable).schedule();
|
||||
}
|
||||
|
||||
@Getter
|
||||
private MultiProxyHandler multiProxyHandler;
|
||||
|
||||
public void sendServerNameMessage() {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
sendPluginMessageServer(s, "ServerName", s.getServerInfo().getName());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String version = "";
|
||||
@@ -1130,6 +1293,22 @@ public class VotingPluginVelocity {
|
||||
loadMultiProxySupport();
|
||||
}
|
||||
|
||||
public void sendMessageServer(RegisteredServer s, String channel, String... messageData) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(s, channel, messageData);
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
sendRedisMessageServer(s, channel, messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendRedisMessageServer(RegisteredServer s, String channel, String... messageData) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(channel);
|
||||
list.addAll(ArrayUtils.getInstance().convert(messageData));
|
||||
redisHandler.sendMessage(getConfig().getRedisPrefix() + "VotingPlugin_" + s.getServerInfo().getName(),
|
||||
ArrayUtils.getInstance().convert(list));
|
||||
}
|
||||
|
||||
public void sendPluginMessageServer(RegisteredServer s, String channel, String... messageData) {
|
||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||
@@ -1199,14 +1378,14 @@ public class VotingPluginVelocity {
|
||||
public void status() {
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
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());
|
||||
sendMessageServer(s, "Status", s.getServerInfo().getName());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1332,7 +1511,7 @@ public class VotingPluginVelocity {
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
}
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING) || method.equals(BungeeMethod.REDIS)) {
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
@@ -1355,9 +1534,8 @@ public class VotingPluginVelocity {
|
||||
|
||||
} else {
|
||||
// send
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
sendMessageServer(s, "Vote", player, uuid, service, "" + time, Boolean.TRUE.toString(),
|
||||
"" + realVote, text.toString(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "1", "1");
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
@@ -1367,12 +1545,12 @@ public class VotingPluginVelocity {
|
||||
} else {
|
||||
|
||||
if (isOnline(p) && isInAvailableServers(p.getCurrentServer().get().getServerInfo().getName())) {
|
||||
sendPluginMessageServer(p.getCurrentServer().get().getServer(), "VoteOnline", player, uuid,
|
||||
service, "" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
sendMessageServer(p.getCurrentServer().get().getServer(), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + config.getBroadcast(), "1", "1");
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getMultiProxyOneGlobalReward()) {
|
||||
sendMultiProxyServerMessage("ClearVote", player, uuid);
|
||||
getMultiProxyHandler().sendMultiProxyServerMessage("ClearVote", player, uuid);
|
||||
}
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
@@ -1388,10 +1566,10 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired);
|
||||
sendMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, text.toString());
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
sendMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1402,15 +1580,17 @@ public class VotingPluginVelocity {
|
||||
if (getConfig().getMultiProxySupport() && getConfig().getPrimaryServer()) {
|
||||
if (!getConfig().getMultiProxyOneGlobalReward()) {
|
||||
debug("Sending global proxy vote message");
|
||||
sendMultiProxyServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
|
||||
getMultiProxyHandler().sendMultiProxyServerMessage("Vote", uuid, player, service,
|
||||
"" + votePartyVotes, "" + currentVotePartyVotesRequired, "" + time, "" + realVote,
|
||||
text.toString());
|
||||
} else {
|
||||
// check if reward should've already been given
|
||||
if (!(isOnline(p) && !config.getBlockedServers()
|
||||
.contains(p.getCurrentServer().get().getServerInfo().getName()))) {
|
||||
debug("Seending global proxy voteonline message");
|
||||
sendMultiProxyServerMessage("VoteOnline", uuid, player, service, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
|
||||
getMultiProxyHandler().sendMultiProxyServerMessage("VoteOnline", uuid, player, service,
|
||||
"" + votePartyVotes, "" + currentVotePartyVotesRequired, "" + time, "" + realVote,
|
||||
text.toString());
|
||||
} else {
|
||||
debug("Not sending global proxy message for voteonline, player already got reward");
|
||||
}
|
||||
@@ -1458,12 +1638,6 @@ public class VotingPluginVelocity {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void sendMultiProxyServerMessage(String... messageData) {
|
||||
for (ClientHandler h : multiproxyClientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private int votePartyVotes = 0;
|
||||
@Getter
|
||||
|
||||
+9
-1
@@ -55,13 +55,21 @@ public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
.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.sendMultiProxyServerMessage("Status");
|
||||
plugin.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
|
||||
|
||||
source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
|
||||
@@ -5,7 +5,9 @@ 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;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -35,6 +37,7 @@ import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
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;
|
||||
@@ -515,6 +518,40 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "CorrectServiceSites" },
|
||||
"VotingPlugin.Commands.AdminVote.CorrectServiceSites|" + adminPerm,
|
||||
"Attempt to correct invalid services sites") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int invalid = 0;
|
||||
int fixed = 0;
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isVaidServiceSite()) {
|
||||
invalid++;
|
||||
if (plugin.getServiceSiteHandler().contains(site.getServiceSite())) {
|
||||
fixed++;
|
||||
plugin.getConfigVoteSites().setServiceSite(site.getKey(),
|
||||
plugin.getServiceSiteHandler().match(site.getServiceSite()));
|
||||
sendMessage(sender,
|
||||
"&aChanging '" + site.getServiceSite() + "' to '"
|
||||
+ plugin.getServiceSiteHandler().match(site.getServiceSite())
|
||||
+ "' on site '" + site.getKey() + "'");
|
||||
} else {
|
||||
sendMessage(sender, "&cCouldn't find an valid service site for '"
|
||||
+ site.getServiceSite() + "' on site '" + site.getKey() + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fixed > 0) {
|
||||
plugin.reload();
|
||||
}
|
||||
sendMessage(sender,
|
||||
"&aDetected " + invalid + " service sites possibly invalid, fixed " + fixed);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] { "Help&?", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.Help|" + adminPerm, "See this page") {
|
||||
|
||||
@@ -1021,7 +1058,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cTriggering vote for all voting sites...");
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -1134,7 +1171,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cTriggering vote for all voting sites...");
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(),
|
||||
false);
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
@@ -1270,7 +1307,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (site.isVoteDelayDaily()) {
|
||||
plugin.getCoolDownCheck().checkAllVoteSite(site);
|
||||
}
|
||||
@@ -1689,6 +1726,29 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "RemoveOfflineUUIDs" },
|
||||
"VotingPlugin.Commands.AdminVote.RemoveOfflineUUIDs|" + adminPerm,
|
||||
"Purges database of offline UUIDs, keeps online UUIDs", true, true) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!plugin.getOptions().isOnlineMode()) {
|
||||
sendMessage(sender, "&cNot in online mode!");
|
||||
return;
|
||||
}
|
||||
int amount = 0;
|
||||
for (String uuid : plugin.getUserManager().getAllUUIDs()) {
|
||||
if (uuid.charAt(14) == '3') {
|
||||
plugin.getUserManager().removeUUID(UUID.fromString(uuid));
|
||||
amount++;
|
||||
}
|
||||
|
||||
}
|
||||
sendMessage(sender, "&cOffline UUIDs purged: " + amount);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "Placeholders", "(player)" },
|
||||
"VotingPlugin.Commands.AdminVote.Placeholders.Players|" + adminPerm,
|
||||
@@ -1702,6 +1762,51 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(plugin, new String[] { "MergeDataFrom", "(UserStorage)" },
|
||||
"VotingPlugin.Commands.AdminVote.MergeDataFrom|" + adminPerm,
|
||||
"Merge player totals from other storage type", true, true) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
plugin.loadUserAPI(UserStorage.value(args[1]));
|
||||
|
||||
if (plugin.getMysql() != null) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
|
||||
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());
|
||||
ArrayList<String> uuids = plugin.getUserManager().getAllUUIDs();
|
||||
|
||||
while (players.size() > 0) {
|
||||
Entry<UUID, ArrayList<Column>> entry = players.poll();
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(entry.getKey(), false);
|
||||
user.dontCache();
|
||||
if (uuids.contains(entry.getKey().toString())) {
|
||||
user.mergeData(user.getData().convert(entry.getValue()));
|
||||
} else {
|
||||
user.getData().setValues(plugin.getStorageType(),
|
||||
user.getData().convert(entry.getValue()));
|
||||
}
|
||||
|
||||
sendMessage(sender, "Finished merge for " + user.getUUID() + ", " + players.size()
|
||||
+ " more left to go!");
|
||||
|
||||
if (players.size() % 50 == 0) {
|
||||
sendMessage(sender,
|
||||
"Working on converting data, about " + players.size() + " left to go!");
|
||||
}
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
sendMessage(sender, "Merge finished");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(plugin, new String[] {},
|
||||
"VotingPlugin.Commands.AdminVote|" + adminPerm, "Base command") {
|
||||
|
||||
@@ -1840,7 +1945,7 @@ public class CommandLoader {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
ArrayList<String> voteSites = new ArrayList<String>();
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
voteSites.add(voteSite.getKey());
|
||||
}
|
||||
new ValueRequest().requestString(player, "",
|
||||
@@ -1933,7 +2038,7 @@ public class CommandLoader {
|
||||
*/
|
||||
public void loadTabComplete() {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
sites.add(site.getKey());
|
||||
}
|
||||
|
||||
@@ -1942,7 +2047,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void reload() {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
sites.add(site.getKey());
|
||||
}
|
||||
setReplace(sites);
|
||||
@@ -2049,6 +2154,9 @@ public class CommandLoader {
|
||||
value = !plugin.getVoteReminding().getRemindersEnabled().get(p.getUniqueId());
|
||||
}
|
||||
plugin.getVoteReminding().getRemindersEnabled().put(p.getUniqueId(), value);
|
||||
plugin.getPlaceholders().onUpdate(
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(p.getUniqueId(), p.getName()), true);
|
||||
plugin.getVoteReminding().saveReminds();
|
||||
|
||||
if (value) {
|
||||
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleRemindersEnabled());
|
||||
|
||||
@@ -91,9 +91,11 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
sender.sendMessage(
|
||||
StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
} else {
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
sender.sendMessage(
|
||||
StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -242,7 +242,9 @@ public class AdminGUI {
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("Enabled: " + voteSite.isEnabled());
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
|
||||
lore.add("Name: " + voteSite.getDisplayName());
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ public class AdminVoteVotePlayer extends GUIHandler {
|
||||
EditGUI inv = new EditGUI("Trigger vote for " + playerName);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Vote|VotingPlugin.Admin");
|
||||
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -162,13 +162,19 @@ public class VoteGUI extends GUIHandler {
|
||||
} else {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, slot);
|
||||
}
|
||||
String prefix = "";
|
||||
if (event.getButton().getBuilder().isConditional()) {
|
||||
prefix = "Item.";
|
||||
}
|
||||
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui()
|
||||
.getChestVoteGUISlotRewardsPath(slot, event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(plugin.getVotingPluginUserManager().getVotingPluginUser(player),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
prefix + event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
event.getButton().getLastRewardsPath(player)),
|
||||
prefix + event.getButton().getLastRewardsPath(player)),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class VoteLast extends GUIHandler {
|
||||
msg.add(StringParser.getInstance().replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(),
|
||||
"%player%", playerName));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
msg.add(user.voteCommandLastLine(voteSite));
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class VoteLast extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteLastName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
|
||||
|
||||
@@ -43,7 +43,7 @@ public class VoteNext extends GUIHandler {
|
||||
msg.add(StringParser.getInstance().colorize(StringParser.getInstance()
|
||||
.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteNextTitle(), "%player%", playerName)));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
|
||||
|
||||
@@ -63,7 +63,7 @@ public class VoteNext extends GUIHandler {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
@@ -87,7 +87,7 @@ public class VoteNext extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
|
||||
@@ -86,7 +86,8 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
|
||||
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
|
||||
if (hasPerm && (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
|
||||
if ((hasPerm || !plugin.getGui().getChestVoteShopHideOnNoPermission(identifier))
|
||||
&& (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
@@ -147,13 +148,13 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
} else {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new VoteShopConfirm(plugin, player, user, identifier).open(GUIMethod.CHEST);
|
||||
new VoteShopConfirm(plugin, player, user, identifier)
|
||||
.open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class VoteURL extends GUIHandler {
|
||||
}
|
||||
if (plugin.getConfigFile().isFormatCommandsVoteAutoInputSites()) {
|
||||
int counter = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
counter++;
|
||||
String voteURL = voteSite.getVoteURL(json);
|
||||
@@ -117,13 +117,16 @@ public class VoteURL extends GUIHandler {
|
||||
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteItemSection());
|
||||
builder.setName(
|
||||
plugin.getGui().getChestVoteURLGUISiteNameCanVote().replace("%Name%", voteSite.getDisplayName()));
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteNameCanVote());
|
||||
} else {
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteName().replace("%Name%", voteSite.getDisplayName()));
|
||||
builder.addLoreLine(
|
||||
plugin.getGui().getChestVoteURLNextVote().replace("%Info%", user.voteCommandNextInfo(voteSite)));
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteName());
|
||||
builder.addLoreLine(plugin.getGui().getChestVoteURLNextVote());
|
||||
}
|
||||
builder.addPlaceholder("ServiceSite", voteSite.getServiceSite());
|
||||
builder.addPlaceholder("Name", voteSite.getDisplayName());
|
||||
builder.addPlaceholder("VoteDelay", "" + voteSite.getVoteDelay());
|
||||
builder.addPlaceholder("VoteHour", "" + voteSite.getVoteDelayDailyHour());
|
||||
builder.addPlaceholder("Info", user.voteCommandNextInfo(voteSite));
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -137,7 +140,7 @@ public class VoteURL extends GUIHandler {
|
||||
book.addLayout(layout);
|
||||
}
|
||||
int i = 1;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
|
||||
site.getDisplayName());
|
||||
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
|
||||
@@ -186,7 +189,7 @@ public class VoteURL extends GUIHandler {
|
||||
}
|
||||
|
||||
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
ItemBuilder builder = getItemVoteSite(voteSite);
|
||||
if (startSlot >= 0) {
|
||||
@@ -201,11 +204,14 @@ public class VoteURL extends GUIHandler {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance()
|
||||
.replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteURLURLText(), "voteurl", voteSite.getVoteURL()),
|
||||
"sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("voteurl", voteSite.getVoteURL());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("player", player.getName());
|
||||
placeholders.put("servicesite", voteSite.getServiceSite());
|
||||
placeholders.put("VoteDelay", "" + voteSite.getVoteDelay());
|
||||
placeholders.put("VoteHour", "" + voteSite.getVoteDelayDailyHour());
|
||||
user.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,26 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private String bungeeMethod = "PLUGINMESSAGING";
|
||||
|
||||
@ConfigDataString(path = "Redis.Host")
|
||||
@Getter
|
||||
private String RedisHost = "";
|
||||
|
||||
@ConfigDataString(path = "Redis.Username")
|
||||
@Getter
|
||||
private String RedisUsername = "";
|
||||
|
||||
@ConfigDataString(path = "Redis.Prefix")
|
||||
@Getter
|
||||
private String RedisPrefix = "";
|
||||
|
||||
@ConfigDataString(path = "Redis.Password")
|
||||
@Getter
|
||||
private String RedisPassword = "";
|
||||
|
||||
@ConfigDataInt(path = "Redis.Port")
|
||||
@Getter
|
||||
private int RedisPort = 6379;
|
||||
|
||||
@ConfigDataString(path = "BungeeServer.Host")
|
||||
@Getter
|
||||
private String bungeeServerHost = "";
|
||||
@@ -46,11 +66,10 @@ public class BungeeSettings extends YMLFile {
|
||||
@ConfigDataBoolean(path = "PerServerMilestones")
|
||||
@Getter
|
||||
private boolean perServerMilestones = false;
|
||||
|
||||
|
||||
@ConfigDataBoolean(path = "GiveExtraAllSitesRewards")
|
||||
@Getter
|
||||
private boolean giveExtraAllSitesRewards = false;
|
||||
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerRewards")
|
||||
@Getter
|
||||
|
||||
@@ -47,6 +47,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean queueVotesDuringTimeChange = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AdvancedServiceSiteHandling")
|
||||
@Getter
|
||||
private boolean advancedServiceSiteHandling = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
|
||||
@@ -48,7 +48,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
setServiceSite(siteName, org);
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
setVoteDelay(siteName, 24);
|
||||
set(siteName, "DisplayItem.Material", "GRASS");
|
||||
set(siteName, "DisplayItem.Material", "STONE");
|
||||
set(siteName, "DisplayItem.Amount", 1);
|
||||
set(siteName, "Rewards.Messages.Player", "&aThanks for voting on %ServiceSite%!");
|
||||
|
||||
|
||||
@@ -326,6 +326,10 @@ public class GUI extends YMLFile {
|
||||
public boolean getChestVoteShopCloseGUI(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".CloseGUI", true);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopHideOnNoPermission(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".HideOnNoPermission", true);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopEnabled")
|
||||
@Getter
|
||||
|
||||
@@ -66,6 +66,10 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesWeekly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesWeekly = false;
|
||||
|
||||
@ConfigDataString(path = "VoteParty.VoteReminderBroadcast")
|
||||
@Getter
|
||||
|
||||
@@ -53,33 +53,43 @@ public class CoolDownCheck implements Listener {
|
||||
}
|
||||
|
||||
public void check(UUID uuid) {
|
||||
check(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.dontCache();
|
||||
}
|
||||
check(user);
|
||||
}
|
||||
|
||||
public void checkPerSite(UUID uuid) {
|
||||
checkPerSite(plugin.getVotingPluginUserManager().getVotingPluginUser(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);
|
||||
schedule(user, true);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user);
|
||||
schedulePerSite(user, true);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void check(VotingPluginUser user) {
|
||||
boolean coolDownCheck = user.getCoolDownCheck();
|
||||
if (user.canVoteAll() && coolDownCheck) {
|
||||
user.setCoolDownCheck(false);
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
allSiteTasks.remove(user.getJavaUUID());
|
||||
} else if (!coolDownCheck) {
|
||||
schedule(user);
|
||||
if (coolDownCheck) {
|
||||
if (user.canVoteAll()) {
|
||||
user.setCoolDownCheck(false);
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
allSiteTasks.remove(user.getJavaUUID());
|
||||
} else {
|
||||
schedulePerSite(user, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +97,7 @@ public class CoolDownCheck implements Listener {
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
boolean changed = false;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!coolDownChecks.containsKey(site.getKey()) || !coolDownChecks.get(site.getKey()).booleanValue()) {
|
||||
if (user.canVoteSite(site)) {
|
||||
coolDownChecks.put(site.getKey(), Boolean.TRUE);
|
||||
@@ -101,65 +111,72 @@ public class CoolDownCheck implements Listener {
|
||||
if (changed) {
|
||||
user.setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
}
|
||||
|
||||
schedulePerSite(user);
|
||||
|
||||
}
|
||||
|
||||
public void schedulePerSite(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeFirstSiteAvailable();
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time + " seconds");
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
checkPerSite(uuid);
|
||||
}
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
perSiteTasks.put(uuid, scheduledFuture);
|
||||
schedulePerSite(user, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void schedule(VotingPluginUser user) {
|
||||
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() {
|
||||
public void schedulePerSite(VotingPluginUser user, boolean force) {
|
||||
if (user.getSitesVotedOn() > 0 || force) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeFirstSiteAvailable();
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time + " seconds");
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
check(uuid);
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
checkPerSite(uuid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, time+2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
perSiteTasks.put(uuid, scheduledFuture);
|
||||
} else {
|
||||
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 load() {
|
||||
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
user.dontCache();
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -72,6 +73,10 @@ public class ServerData {
|
||||
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)) {
|
||||
@@ -327,6 +332,15 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
for (UUID uuid : disabledReminders) {
|
||||
uuids.add(uuid.toString());
|
||||
}
|
||||
getData().set("DisabledReminders", uuids);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
|
||||
@@ -49,9 +49,10 @@ public class PlayerJoinEvent implements Listener {
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()
|
||||
&& plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("Login", user.getPlayerName(), user.getUUID(),
|
||||
plugin.getBungeeSettings().getServer());
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
|
||||
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("Login", user.getPlayerName(),
|
||||
user.getUUID(), plugin.getBungeeSettings().getServer());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ public class PlayerVoteListener implements Listener {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger()
|
||||
.warning("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
.warning("Currently set service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -115,8 +115,17 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
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 {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final String uuid = user.getUUID();
|
||||
@@ -218,8 +227,8 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
LocalDateTime cTime = plugin.getTimeChecker().getTime();
|
||||
int days = cTime.getDayOfMonth();
|
||||
if (value >= days * plugin.getVoteSites().size()) {
|
||||
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSites().size());
|
||||
if (value >= days * plugin.getVoteSitesEnabled().size()) {
|
||||
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSitesEnabled().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +247,7 @@ public class PlayerVoteListener implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteUpdate", uuid);
|
||||
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
|
||||
@@ -77,7 +77,14 @@ public class VotiferEvent implements Listener {
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
|
||||
return;
|
||||
}
|
||||
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite);
|
||||
String matchSite = "";
|
||||
if (plugin.getConfigFile().isAdvancedServiceSiteHandling()) {
|
||||
if (plugin.getServiceSiteHandler() != null) {
|
||||
matchSite = plugin.getServiceSiteHandler().matchReverse(voteSite);
|
||||
}
|
||||
}
|
||||
|
||||
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite, matchSite);
|
||||
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
|
||||
boolean createSite = false;
|
||||
@@ -89,6 +96,8 @@ public class VotiferEvent implements Listener {
|
||||
createSite = true;
|
||||
}
|
||||
|
||||
String serviceSite = voteSite;
|
||||
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
|
||||
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr
|
||||
+ "' does not exist, attempting to generate...");
|
||||
@@ -107,7 +116,7 @@ public class VotiferEvent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
String voteSiteName = plugin.getVoteSiteName(true, voteSite);
|
||||
String voteSiteName = plugin.getVoteSiteName(true, serviceSite, matchSite);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName, true),
|
||||
voteUsername, voteSite, true);
|
||||
|
||||
@@ -133,6 +133,8 @@ public class VoteSite {
|
||||
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
|
||||
placeholders.put("sitename", getDisplayName());
|
||||
placeholders.put("servicesite", getServiceSite());
|
||||
placeholders.put("votesrequired", "" + plugin.getVoteParty().getVotesRequired());
|
||||
placeholders.put("neededvotes", "" + plugin.getVoteParty().getNeededVotes());
|
||||
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.bencodez.votingplugin.placeholders;
|
||||
import java.text.NumberFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.TemporalField;
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -286,6 +288,20 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Returns true/false if user has broadcast disabled").updateDataKey("DisableBroadcast"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("DisableReminders") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
if (plugin.getVoteReminding().getRemindersEnabled().containsKey(user.getJavaUUID())) {
|
||||
if (!plugin.getVoteReminding().getRemindersEnabled().get(user.getJavaUUID()).booleanValue()) {
|
||||
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}.withDescription("Returns true/false if user has reminders disabled"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("MilestoneCount") {
|
||||
|
||||
@Override
|
||||
@@ -471,7 +487,7 @@ public class PlaceHolders {
|
||||
}
|
||||
long smallest = -1;
|
||||
HashMap<Long, VoteSite> times = new HashMap<Long, VoteSite>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
long t = user.voteNextDurationTime(site);
|
||||
if (smallest == -1) {
|
||||
smallest = t;
|
||||
@@ -491,7 +507,15 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("How long until user can vote on anysite").updateDataKey("LastVotes"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("SitesAvailable") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getSitesNotVotedOn();
|
||||
}
|
||||
}.withDescription("Get number of sites available to be voted on").updateDataKey("LastVotes"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
placeholders.add(new CalculatingPlaceholder<VotingPluginUser>("Next_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
@@ -608,6 +632,21 @@ public class PlaceHolders {
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_LastMonth_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getLastMonthTopVoter().entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.withDescription("Get user top voter position for lastmonth"));
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_LastMonth_") {
|
||||
|
||||
@Override
|
||||
@@ -642,6 +681,7 @@ public class PlaceHolders {
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in last month top voter"));
|
||||
|
||||
}
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Month_") {
|
||||
@@ -901,7 +941,7 @@ public class PlaceHolders {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0);
|
||||
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0)
|
||||
.withMinute(0);
|
||||
@@ -935,6 +975,82 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Time until plugin time day changes"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("TimeUntilWeekReset") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
LocalDateTime newWeek = plugin.getTimeChecker().getTime().withHour(0).withMinute(0);
|
||||
|
||||
TemporalField woy = WeekFields.of(Locale.getDefault()).weekOfWeekBasedYear();
|
||||
int weekNumber = newWeek.get(woy);
|
||||
int newWeekNumber = weekNumber;
|
||||
|
||||
while (weekNumber == newWeekNumber) {
|
||||
newWeek = newWeek.plusDays(1);
|
||||
newWeekNumber = newWeek.get(woy);
|
||||
}
|
||||
|
||||
String timeMsg = "%days% Days %hours% Hours %minutes% Minutes";
|
||||
Duration dur = Duration.between(now, newWeek);
|
||||
|
||||
int diffDays = (int) (dur.getSeconds() / (60 * 60 * 24));
|
||||
int diffHours = (int) (dur.getSeconds() / (60 * 60) - diffDays * 24);
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60 - diffDays * 24 * 60;
|
||||
|
||||
if (diffHours < 0) {
|
||||
diffHours = diffHours * -1;
|
||||
}
|
||||
if (diffHours >= 24) {
|
||||
diffHours = diffHours - 24;
|
||||
}
|
||||
if (diffMinutes < 0) {
|
||||
diffMinutes = diffMinutes * -1;
|
||||
}
|
||||
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%days%", Integer.toString(diffDays));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
return timeMsg;
|
||||
|
||||
}
|
||||
}.withDescription("Time until plugin time week changes"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("TimeUntilMonthReset") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
LocalDateTime newMonth = plugin.getTimeChecker().getTime().plusMonths(1).withDayOfMonth(1).withHour(0)
|
||||
.withMinute(0);
|
||||
|
||||
String timeMsg = "%days% Days %hours% Hours %minutes% Minutes";
|
||||
Duration dur = Duration.between(now, newMonth);
|
||||
|
||||
int diffDays = (int) (dur.getSeconds() / (60 * 60 * 24));
|
||||
int diffHours = (int) (dur.getSeconds() / (60 * 60) - diffDays * 24);
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60 - diffDays * 24 * 60;
|
||||
|
||||
if (diffHours < 0) {
|
||||
diffHours = diffHours * -1;
|
||||
}
|
||||
if (diffHours >= 24) {
|
||||
diffHours = diffHours - 24;
|
||||
}
|
||||
if (diffMinutes < 0) {
|
||||
diffMinutes = diffMinutes * -1;
|
||||
}
|
||||
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%days%", Integer.toString(diffDays));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
return timeMsg;
|
||||
|
||||
}
|
||||
}.withDescription("Time until plugin time month changes"));
|
||||
|
||||
Set<String> placeholdersSet = new HashSet<String>();
|
||||
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
|
||||
if (getCacheLevel().equals(PlaceholderCacheLevel.AUTO)) {
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.bencodez.votingplugin.servicesites;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class ServiceSiteHandler {
|
||||
@Getter
|
||||
private HashMap<String, String> serviceSites = new HashMap<String, String>();
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public String match(String service) {
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase(service)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
public String matchReverse(String service) {
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
if (entry.getValue().equalsIgnoreCase(service)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
public ServiceSiteHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
loadFromGithub();
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
plugin.extraDebug(entry.getKey() + " - " + entry.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void readFromWeb(String webURL) throws IOException {
|
||||
serviceSites.clear();
|
||||
URL url = new URL(webURL);
|
||||
InputStream is = url.openStream();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
|
||||
String line;
|
||||
boolean rawFound = false;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.contains("<ul>")) {
|
||||
rawFound = true;
|
||||
} else if (!line.contains(" - ")) {
|
||||
rawFound = false;
|
||||
} else if (rawFound) {
|
||||
String data = line.replaceAll("<li>", "").replaceAll("</li>", "");
|
||||
String[] split = data.split(" - ");
|
||||
if (split.length > 0) {
|
||||
serviceSites.put(split[0], split[1]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
plugin.debug(e);
|
||||
// e.printStackTrace();
|
||||
// throw new MalformedURLException("URL is malformed!!");
|
||||
} catch (IOException e) {
|
||||
plugin.debug(e);
|
||||
// e.printStackTrace();
|
||||
// throw new IOException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void loadFromGithub() {
|
||||
try {
|
||||
readFromWeb("https://github.com/BenCodez/VotingPlugin/wiki/Minecraft-Server-Lists");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(String service) {
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase(service)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class SpecialRewards {
|
||||
|
||||
public void bungeeAllSitesCheck(VotingPluginUser user, int numberOfVotes, int num) {
|
||||
if (plugin.getBungeeSettings().isGiveExtraAllSitesRewards()) {
|
||||
int numberOfSites = plugin.getVoteSites().size();
|
||||
int numberOfSites = plugin.getVoteSitesEnabled().size();
|
||||
if (numberOfVotes >= numberOfSites * 2) {
|
||||
if (num > numberOfSites) {
|
||||
if (num % numberOfSites == 0) {
|
||||
@@ -68,6 +68,7 @@ public class SpecialRewards {
|
||||
|
||||
public boolean checkAlmostAllSites(VotingPluginUser user, boolean forceBungee) {
|
||||
boolean checkAllVotes = user.checkAlmostAllVotes();
|
||||
plugin.extraDebug("Checking almostallsites reward: " + checkAllVotes + "/" + user.getSitesNotVotedOn());
|
||||
if (checkAllVotes) {
|
||||
int currentDay = LocalDateTime.now().getDayOfYear();
|
||||
int day = user.getGottenAlmostAllSitesDay();
|
||||
@@ -262,7 +263,9 @@ public class SpecialRewards {
|
||||
if (streak.contains("-")) {
|
||||
// multiple
|
||||
multiple = true;
|
||||
|
||||
}
|
||||
plugin.debug("Streak: " + streak + " multiple: " + multiple);
|
||||
if (StringParser.getInstance().isInt(s)) {
|
||||
int streakRequired = Integer.parseInt(s);
|
||||
if (streakRequired != 0) {
|
||||
@@ -287,8 +290,7 @@ public class SpecialRewards {
|
||||
}
|
||||
} else {
|
||||
if (curStreak != 0 && curStreak % streakRequired == 0) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, streakRequired + "-", curStreak,
|
||||
forceBungee);
|
||||
giveVoteStreakReward(user, user.isOnline(), type, streak, curStreak, forceBungee);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + "* for " + type);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class VoteTester {
|
||||
.info("Time to process votes (" + amount + "): " + time + " ms, average per vote "
|
||||
+ timePerVoteAvg + " ms. " + VotingPluginMain.plugin.getStorageType() + ", "
|
||||
+ plugin.getVotingPluginUserManager().getAllUUIDs().size() + " users. "
|
||||
+ VotingPluginMain.plugin.getVoteSites().size() + " votesites");
|
||||
+ plugin.getVoteSitesEnabled().size() + " votesites");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -462,7 +462,14 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
public void resetGottenMilestones() {
|
||||
plugin.getUserManager().removeAllKeyValues("GottenMileStones", DataType.STRING);
|
||||
plugin.getUserManager().removeAllKeyValues(getGottenMilestonesPath(), DataType.STRING);
|
||||
}
|
||||
|
||||
public String getGottenMilestonesPath() {
|
||||
if (plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
return plugin.getBungeeSettings().getServerNameStorage() + "_" + "GottenMilestones";
|
||||
}
|
||||
return "GottenMileStones";
|
||||
}
|
||||
|
||||
public void resetVoteShopLimit(String shopIdent) {
|
||||
|
||||
@@ -24,6 +24,8 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
@@ -223,7 +225,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canVoteAll() {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (!canVote) {
|
||||
@@ -235,7 +237,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public boolean canVoteAny() {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isIgnoreCanVote() && !voteSite.isHidden()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (canVote) {
|
||||
@@ -275,22 +277,21 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
LocalDateTime resetTime = plugin.getTimeChecker().getTime().withHour(voteSite.getVoteDelayDailyHour())
|
||||
.withMinute(0).withSecond(0);
|
||||
LocalDateTime resetTime = lastVote.withHour(voteSite.getVoteDelayDailyHour()).withMinute(0)
|
||||
.withSecond(0);
|
||||
LocalDateTime resetTimeTomorrow = resetTime.plusHours(24);
|
||||
|
||||
if (lastVote.isBefore(resetTimeTomorrow)) {
|
||||
if (lastVote.isBefore(resetTime)) {
|
||||
if (now.isAfter(resetTime)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
// if (ChronoUnit.HOURS.between(lastVote, resetTime) > 24) {
|
||||
if (lastVote.isBefore(resetTime)) {
|
||||
if (now.isAfter(resetTime)) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (now.isAfter(resetTimeTomorrow)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -300,7 +301,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public boolean checkAlmostAllVotes() {
|
||||
if (getSitesNotVotedOn() == 1) {
|
||||
if (getSitesNotVotedOn() <= 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -317,7 +318,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
ArrayList<Integer> months = new ArrayList<Integer>();
|
||||
ArrayList<Integer> days = new ArrayList<Integer>();
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (voteSite.isEnabled() && !voteSite.isHidden()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time != 0) {
|
||||
@@ -350,6 +351,10 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
if (!voteStreakUpdatedToday(LocalDateTime.now())) {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage() || hasPercentageTotal(
|
||||
TopVoter.Daily, plugin.getSpecialRewardsConfig().getVoteStreakRequirementDay(), null)) {
|
||||
plugin.extraDebug("Adding day vote streak to " + getUUID() + " "
|
||||
+ plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage() + " "
|
||||
+ hasPercentageTotal(TopVoter.Daily,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementDay(), null));
|
||||
addDayVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(this, "Day", forceBungee);
|
||||
setDayVoteStreakLastUpdate(System.currentTimeMillis());
|
||||
@@ -513,7 +518,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
public HashMap<VoteSite, Long> getLastVoteTimesSorted() {
|
||||
LinkedHashMap<VoteSite, Long> times = new LinkedHashMap<VoteSite, Long>();
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
times.put(voteSite, getTime(voteSite));
|
||||
}
|
||||
LinkedHashMap<VoteSite, Long> sorted = new LinkedHashMap<>(
|
||||
@@ -566,7 +571,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public int getSitesVotedOn() {
|
||||
int amount = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!canVoteSite(site)) {
|
||||
amount++;
|
||||
}
|
||||
@@ -681,11 +686,12 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
int total = getTotal(top);
|
||||
switch (top) {
|
||||
case Daily:
|
||||
return total / plugin.getVoteSites().size() * 100 > percentage;
|
||||
return (double) total / (double) plugin.getVoteSitesEnabled().size() * 100 > percentage;
|
||||
case Monthly:
|
||||
return total / (plugin.getVoteSites().size() * time.getMonth().length(false)) * 100 > percentage;
|
||||
return (double) total / ((double) plugin.getVoteSitesEnabled().size() * time.getMonth().length(false))
|
||||
* 100 > percentage;
|
||||
case Weekly:
|
||||
return total / (plugin.getVoteSites().size() * 7) * 100 > percentage;
|
||||
return (double) total / ((double) plugin.getVoteSitesEnabled().size() * 7) * 100 > percentage;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
@@ -1092,8 +1098,8 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
if (plugin.getConfigFile().isLimitMonthlyVotes()) {
|
||||
LocalDateTime time = plugin.getTimeChecker().getTime();
|
||||
int days = time.getDayOfMonth();
|
||||
if (value >= days * plugin.getVoteSites().size()) {
|
||||
value = days * plugin.getVoteSites().size();
|
||||
if (value >= days * plugin.getVoteSitesEnabled().size()) {
|
||||
value = days * plugin.getVoteSitesEnabled().size();
|
||||
}
|
||||
}
|
||||
getData().setInt("MonthTotal", value);
|
||||
@@ -1310,15 +1316,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LocalDateTime resetTime = plugin.getTimeChecker().getTime().withHour(voteSite.getVoteDelayDailyHour())
|
||||
.withMinute(0).withSecond(0);
|
||||
LocalDateTime resetTime = lastVote.withHour(voteSite.getVoteDelayDailyHour()).withMinute(0).withSecond(0);
|
||||
LocalDateTime resetTimeTomorrow = resetTime.plusHours(24);
|
||||
if (lastVote.isBefore(resetTime)) {
|
||||
if (now.isBefore(resetTime)) {
|
||||
Duration dur = Duration.between(now, resetTime);
|
||||
return dur.getSeconds();
|
||||
}
|
||||
} else if (lastVote.isBefore(resetTimeTomorrow)) {
|
||||
} else {
|
||||
if (now.isBefore(resetTimeTomorrow)) {
|
||||
Duration dur = Duration.between(now, resetTimeTomorrow);
|
||||
return dur.getSeconds();
|
||||
@@ -1335,7 +1340,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public int getSitesNotVotedOn() {
|
||||
int amount = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
if (canVoteSite(site)) {
|
||||
amount++;
|
||||
@@ -1351,7 +1356,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public long getNextTimeAllSitesAvailable() {
|
||||
long longest = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
long seconds = voteNextDurationTime(site);
|
||||
if (seconds > longest) {
|
||||
longest = seconds;
|
||||
@@ -1363,7 +1368,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public long getNextTimeFirstSiteAvailable() {
|
||||
long shortest = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!canVoteSite(site)) {
|
||||
long seconds = voteNextDurationTime(site);
|
||||
if (shortest == 0 || seconds < shortest) {
|
||||
@@ -1409,4 +1414,20 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
}
|
||||
|
||||
public void mergeData(HashMap<String, DataValue> toAdd) {
|
||||
HashMap<String, DataValue> currentData = getData().getValues();
|
||||
HashMap<String, DataValue> newData = new HashMap<String, DataValue>();
|
||||
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (toAdd.containsKey(top.getColumnName()) && currentData.containsKey(top.getColumnName())) {
|
||||
newData.put(top.getColumnName(), new DataValueInt(
|
||||
currentData.get(top.getColumnName()).getInt() + toAdd.get(top.getColumnName()).getInt()));
|
||||
}
|
||||
}
|
||||
|
||||
if (newData.size() > 0) {
|
||||
getData().setValues(newData);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -305,6 +305,10 @@ public class VoteParty implements Listener {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetWeekly()) {
|
||||
reset(true);
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetExtraVotesWeekly()) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(0);
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.bencodez.votingplugin.votereminding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
@@ -33,6 +36,35 @@ public class VoteReminding {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void loadReminds() {
|
||||
List<String> uuidsStr = plugin.getServerData().getDisabledReminders();
|
||||
|
||||
for (String str : uuidsStr) {
|
||||
remindersEnabled.put(UUID.fromString(str), Boolean.FALSE);
|
||||
}
|
||||
|
||||
plugin.getTimer().scheduleAtFixedRate(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
saveReminds();
|
||||
}
|
||||
}, 24, 24, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
public void saveReminds() {
|
||||
ArrayList<UUID> remindersDisabled = new ArrayList<UUID>();
|
||||
for (Entry<UUID, Boolean> entry : remindersEnabled.entrySet()) {
|
||||
if (remindersEnabled.containsKey(entry.getKey())) {
|
||||
if (!remindersEnabled.get(entry.getKey()).booleanValue()) {
|
||||
remindersDisabled.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getServerData().saveDisabledReminders(remindersDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check remind.
|
||||
*
|
||||
@@ -119,7 +151,7 @@ public class VoteReminding {
|
||||
return user.canVoteAny();
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getUUID() + " no need to remind because plaeyr has VotingPlugin.NoRemind");
|
||||
plugin.debug(user.getUUID() + " no need to remind because player has VotingPlugin.NoRemind");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user