Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6ca0c8121 | ||
|
|
f3e88859d3 | ||
|
|
7249159ec9 | ||
|
|
61c3eccb19 | ||
|
|
4ec800c83e | ||
|
|
20e42b0ae7 | ||
|
|
d95becce22 | ||
|
|
04fd38a10d | ||
|
|
a30b2319f5 | ||
|
|
a1b08f6dd0 | ||
|
|
614193716f | ||
|
|
b68ac4cdd5 | ||
|
|
3767ca2883 | ||
|
|
73b7abf3e6 | ||
|
|
285719ae28 | ||
|
|
22fd1ac1e4 | ||
|
|
6127a2ab23 | ||
|
|
0054b6e06f | ||
|
|
b0f1e0bcb6 | ||
|
|
ddd0dba728 | ||
|
|
9595164f69 | ||
|
|
66092ba3fd | ||
|
|
5c41c7f4c9 | ||
|
|
dfa772af4b | ||
|
|
78f33661aa | ||
|
|
45f2bb2c72 | ||
|
|
f20c7a58ac | ||
|
|
4d1b37c37b | ||
|
|
d323cd7691 | ||
|
|
67fc73b530 | ||
|
|
13872fd9d1 | ||
|
|
a76da52a0a | ||
|
|
36fabe10a6 | ||
|
|
eada7af420 | ||
|
|
63fc7d64be | ||
|
|
0ed5b12f8b | ||
|
|
504f9edbb2 | ||
|
|
8060ece2eb | ||
|
|
254442fa2e | ||
|
|
febead9d5a | ||
|
|
d8cd0c278d | ||
|
|
fe0d7cd671 | ||
|
|
c9d8878bb3 | ||
|
|
0f450e9b60 | ||
|
|
667d0b544e | ||
|
|
6e1e6bd928 | ||
|
|
1cfc447445 | ||
|
|
6d3e68e548 | ||
|
|
855dde196e | ||
|
|
d5a9e1012a | ||
|
|
f5d67833b2 | ||
|
|
a1eb2f63e5 | ||
|
|
a882b8d86f | ||
|
|
0a745ae4c0 | ||
|
|
d38a0549d3 | ||
|
|
6e6394f1fb | ||
|
|
ce58e12740 | ||
|
|
2411354a5f | ||
|
|
13efd0c482 | ||
|
|
8fce74f30d | ||
|
|
3f54c05f86 | ||
|
|
dd1cf02c49 | ||
|
|
b462373dfc | ||
|
|
c6e5d008d2 | ||
|
|
9a91561304 | ||
|
|
1c6981e538 | ||
|
|
b6e366ff9d | ||
|
|
ca0fbe7e3b | ||
|
|
27d8b3e718 | ||
|
|
8430609d0f | ||
|
|
8fe5e87999 | ||
|
|
6b985e19c2 | ||
|
|
4636cc78b2 | ||
|
|
8c66b50749 | ||
|
|
7f6e95d47e | ||
|
|
cd60ade45f | ||
|
|
f82945b97b | ||
|
|
a3e9651378 | ||
|
|
a764ca0ed7 | ||
|
|
d21464560a | ||
|
|
88c5dc7c86 | ||
|
|
b2b2c710c5 | ||
|
|
4175e2d36a | ||
|
|
a84adb367d | ||
|
|
7368158707 | ||
|
|
5d3c1cb553 | ||
|
|
cb1206db0b | ||
|
|
03396e447f | ||
|
|
6dec0826af | ||
|
|
f443f77dfe | ||
|
|
5c4636d8c2 | ||
|
|
51c6c4066b | ||
|
|
161fc6da95 | ||
|
|
aba23f355e | ||
|
|
ac78b4d350 | ||
|
|
0c01f8d3c1 | ||
|
|
77dc7d51f5 | ||
|
|
ee5c4db0c9 | ||
|
|
f9b47c5c63 | ||
|
|
d7dc82b1a7 | ||
|
|
c5041edd8a | ||
|
|
d52b7f85b3 | ||
|
|
3e4564578a | ||
|
|
65312cd2a1 | ||
|
|
b2db9675ca | ||
|
|
0a66c2dd7e | ||
|
|
7c02cb91f4 | ||
|
|
3a390659cd | ||
|
|
99bd32c8f5 | ||
|
|
de894a98b2 | ||
|
|
8c668289ce | ||
|
|
95e850cb84 | ||
|
|
d2134abc45 | ||
|
|
3316662889 | ||
|
|
5b3ced6ca9 | ||
|
|
50a5169543 | ||
|
|
c8d5e2f4b5 | ||
|
|
3dcd78e4f5 | ||
|
|
de570574c9 | ||
|
|
116eda2866 | ||
|
|
30f1576510 | ||
|
|
64e897615a | ||
|
|
2dfd8dcfa5 | ||
|
|
00791766f1 | ||
|
|
4d2c783d85 | ||
|
|
19f1664662 | ||
|
|
ca2e6fb530 | ||
|
|
eca7c6641a | ||
|
|
47fe6b57e2 | ||
|
|
911819c69b | ||
|
|
cda72b5c5b | ||
|
|
75a3da98fa | ||
|
|
ced74fdee3 | ||
|
|
b8460ff755 | ||
|
|
50bb1facc4 | ||
|
|
5ed21949e1 | ||
|
|
253e4937db | ||
|
|
192685ceec |
No files matched your search
@@ -9,7 +9,7 @@ UseBungeecord: false
|
||||
|
||||
# What type of bungee setup
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
@@ -62,8 +62,43 @@ Server: PleaseSet
|
||||
# Can edit via /av gui
|
||||
BungeeVotePartyRewards: {}
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# Global mysql data handle for between server commmunications
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
# This will create a different table then from users storing server info to process
|
||||
#
|
||||
# If you use this you need to enable this on BungeeSettings.yml on each server with votingplugin
|
||||
# Make sure server name is set correctly in BungeeSettings.yml or this will not work correctly
|
||||
#
|
||||
# Please use PLUGINMESSAGING for this, SOCKETS should work as well, but not fully tested
|
||||
#
|
||||
# This will make votes cache until time change has finished processing
|
||||
# In the event a server is offline or time change fails, the time change process
|
||||
# will continue after a set amount of time (in essense skipping a specific server)
|
||||
# This will also respect blocked servers in bungeeconfig.yml
|
||||
GlobalData:
|
||||
Enabled: false
|
||||
# Use existing mysql connection from config.yml
|
||||
UseMainMySQL: true
|
||||
# Mysql settings only used if above is false
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Must be the same on all servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# -----------------------------
|
||||
# For socket setup below only
|
||||
# -----------------------------
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
@@ -30,6 +30,8 @@ MySQL:
|
||||
#MaxLifeTime: -1
|
||||
#Additional info on connection string
|
||||
#Line: ''
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# --------------------
|
||||
# AllowUnJoined options
|
||||
@@ -107,7 +109,11 @@ Format:
|
||||
|
||||
# Broadcast vote message
|
||||
# Set to an empty message to disable
|
||||
# Use %NewLine% for a new line
|
||||
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
|
||||
# If true uses broadcast setting below for offline votes
|
||||
OnlyOneOfflineBroadcast: false
|
||||
OfflineBroadcast: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %numberofvotes% times!'
|
||||
|
||||
# Broadcast only when player is online
|
||||
BroadcastWhenOnline: false
|
||||
@@ -115,6 +121,8 @@ Format:
|
||||
# Broadcast every x number of minutes with number of players that voted
|
||||
AlternateBroadcast:
|
||||
Enabled: false
|
||||
# Use %players% for all players names
|
||||
# Use %numberofplayers% for number of players that voted
|
||||
Broadcast: '&6[&4Broadcast&6] &2%numberofplayers% voted in the last half hour! /vote'
|
||||
# Delay in minutes
|
||||
Delay: 30
|
||||
@@ -367,6 +375,10 @@ StoreTopVoters:
|
||||
# Most of these values can be left untouched for most setups
|
||||
# ------------------------------------------------
|
||||
|
||||
# Enable per site cooldown events, requires more resources to use
|
||||
# Requires restart
|
||||
PerSiteCoolDownEvents: false
|
||||
|
||||
# If true vanished players are treated as if they are offline
|
||||
TreatVanishAsOffline: false
|
||||
|
||||
@@ -376,8 +388,11 @@ DisableCoolDownCheck: false
|
||||
# If true, disable PlayerInteractEvent (for clicking signs and skulls)
|
||||
DisableInteractEvent: false
|
||||
|
||||
# If false plugin will use offline player UUIDs
|
||||
OnlineMode: true
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In ticks
|
||||
# In miliseconds, 1000 = 1 second
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
@@ -415,6 +430,10 @@ ClickSound:
|
||||
# case sensitive
|
||||
VotingBroadcastBlacklist: []
|
||||
|
||||
# Playernames to not be broadcasted when broadcast comes from reward file
|
||||
# case sensitive
|
||||
BroadcastBlacklist: []
|
||||
|
||||
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
@@ -431,31 +450,6 @@ PreventRepeatMilestones: false
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# When enabled the command /vote setprimaryaccount (playername)
|
||||
# will be shown (after restart)
|
||||
# Primary account will be used instead of the players account to get
|
||||
# placeholder and other data such as vote reminding
|
||||
# Mainly to be used for alts and such
|
||||
UsePrimaryAccountForPlaceholders: false
|
||||
|
||||
# Always force placeholders to return value if the value isn't cached
|
||||
# This should prevent server from crashing when pulling placeholders on main thread
|
||||
# Only affects placeholderapi placeholders
|
||||
AlwaysWaitForCachePlaceholders: false
|
||||
|
||||
# Enable auto caching placeholders
|
||||
AutoCachePlaceholders: true
|
||||
|
||||
# Set which placeholders to cache at all times
|
||||
# Use for placeholders to are pulled constantly or on the main thread
|
||||
# Mainly aimed for scoreboards
|
||||
# Placeholders may auto cache in certain conditions
|
||||
# Will use additional memory, but not a lot
|
||||
# Still in early stages, please report bugs
|
||||
# Please remove VotingPlugin_ from the placeholder listed here
|
||||
CachedPlaceholders: []
|
||||
#- Total_AllTime
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
@@ -477,6 +471,40 @@ CustomCommands:
|
||||
# Forces player to run this command
|
||||
Commands:
|
||||
- tokencommand
|
||||
|
||||
# ---------------------------------------
|
||||
# Placeholderapi placeholders settings
|
||||
# ---------------------------------------
|
||||
|
||||
# When enabled the command /vote setprimaryaccount (playername)
|
||||
# will be shown (after restart)
|
||||
# Primary account will be used instead of the players account to get
|
||||
# placeholder and other data such as vote reminding
|
||||
# Mainly to be used for alts and such
|
||||
UsePrimaryAccountForPlaceholders: false
|
||||
|
||||
# Always force placeholders to return value if the value isn't cached
|
||||
# This should prevent server from crashing when pulling placeholders on main thread
|
||||
# Only affects placeholderapi placeholders
|
||||
AlwaysWaitForCachePlaceholders: false
|
||||
|
||||
# Always force placeholders to be processed and return a proper value
|
||||
# This has small chance of crashing the server (mainly with mysql and using placeholders on main thread)
|
||||
AlwaysProcessPlaceholders: false
|
||||
|
||||
# Enable auto caching placeholders
|
||||
# Generally this works well, but if you need to cache placeholders manually set them below
|
||||
AutoCachePlaceholders: false
|
||||
|
||||
# Set which placeholders to cache at all times
|
||||
# Use for placeholders to are pulled constantly or on the main thread
|
||||
# Mainly aimed for scoreboards
|
||||
# Placeholders may auto cache in certain conditions
|
||||
# Will use additional memory, but not a lot
|
||||
# Still in early stages, please report bugs
|
||||
# Please remove VotingPlugin_ from the placeholder listed here
|
||||
CachedPlaceholders: []
|
||||
#- Total_AllTime
|
||||
|
||||
######################
|
||||
# Debug
|
||||
|
||||
@@ -138,6 +138,7 @@ CHEST:
|
||||
# %time% = time, using timeformat below
|
||||
# %timesince% = time since vote
|
||||
Line: '&6%timeSince%'
|
||||
ClickableLinks: true
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
|
||||
@@ -17,6 +17,12 @@ FirstVoteToday: {}
|
||||
AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
# Give a reward for voting on all sites minus 1
|
||||
# Similar to allsites
|
||||
#AlmostAllSites:
|
||||
# Messages:
|
||||
# Player: '&aYou almost voted on all sites in 1 day!'
|
||||
|
||||
|
||||
# If true only cumulative reward at a time can be given
|
||||
@@ -33,7 +39,7 @@ Cumulative:
|
||||
# Can have multiple listed here
|
||||
'20':
|
||||
Enabled: false
|
||||
# Wether or not votes must be made in same day/week
|
||||
# Whether or not votes must be made in same day/week
|
||||
# Useful if you want to require a certain number of voting sites to be voted on
|
||||
# for a daily/weekly reward instead of all of them
|
||||
# Valid options
|
||||
@@ -42,6 +48,11 @@ Cumulative:
|
||||
# Weekly
|
||||
# Daily
|
||||
TotalToUse: AllTime
|
||||
# Blacklist recurring votes
|
||||
#BlackList:
|
||||
#- 40
|
||||
# Whether or not to gives cumulative reward for every x number of votes, default: true
|
||||
#Recurring: true
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %cumulative% cumulative votes!'
|
||||
@@ -69,6 +80,8 @@ VoteParty:
|
||||
ResetMonthly: false
|
||||
# If true, will give voteparty only once per day
|
||||
OnlyOncePerDay: false
|
||||
# If true, will give voteparty once per week only
|
||||
OnlyOncePerWeek: false
|
||||
# Reset extra votes
|
||||
ResetExtraVotesMonthly: false
|
||||
# Count votes from /av vote?
|
||||
|
||||
@@ -60,6 +60,12 @@ VoteSites:
|
||||
DisplayItem:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Reward to run when cooldown ends for this votesite
|
||||
# Enable PerSiteCoolDownEvents in Config.yml to use this
|
||||
#CoolDownEndRewards:
|
||||
# Messages:
|
||||
# Player: '&aTime to go vote on site1'
|
||||
|
||||
# Rewards to give
|
||||
# https://github.com/BenCodez/AdvancedCore/wiki/Rewards
|
||||
|
||||
@@ -12,9 +12,57 @@ Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
# Don't use with PLUGINMESSAGING bungee setup
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#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
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
# This will create a different table then from users storing server info to process
|
||||
#
|
||||
# If you use this you need to enable this on BungeeSettings.yml on each server with votingplugin
|
||||
# Make sure server name is set correctly in BungeeSettings.yml or this will not work correctly
|
||||
#
|
||||
# Please use PLUGINMESSAGING for this, SOCKETS should work as well, but not fully tested
|
||||
#
|
||||
# This will make votes cache until time change has finished processing
|
||||
# In the event a server is offline or time change fails, the time change process
|
||||
# will continue after a set amount of time (in essense skipping a specific server)
|
||||
# This will also respect blocked servers
|
||||
GlobalData:
|
||||
Enabled: false
|
||||
# Use existing connection above
|
||||
UseMainMySQL: true
|
||||
# Mysql settings only used if above is false
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Must be the same on all servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# Time offset for time changes
|
||||
# Must match on all servers
|
||||
TimeHourOffSet: 0
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
Debug: false
|
||||
# Have a reward on each server
|
||||
@@ -48,14 +96,16 @@ PointsOnVote: 1
|
||||
# Recommened to leave true, setting to false setups are currently unsupported
|
||||
BungeeManageTotals: true
|
||||
|
||||
# Support for redis
|
||||
# experimental
|
||||
RedisSupport: false
|
||||
|
||||
# Tell servers to broadcast
|
||||
# Set DisableBroadcast to true on spigot servers (BungeeSettings.yml) as well
|
||||
Broadcast: true
|
||||
|
||||
# Geyser settings
|
||||
# This may or may not work
|
||||
# Does not work on velocity currently
|
||||
GeyserSupport: false
|
||||
GeyserPrefix: '.'
|
||||
|
||||
VoteParty:
|
||||
# If enabled, will trigger vote party reward
|
||||
# in BungeeSettings.yml under BungeeVotePartyReward
|
||||
@@ -88,4 +138,29 @@ WaitForUserOnline: false
|
||||
# ONLY for SOCKET method
|
||||
# ----------------------------
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# Redis setup
|
||||
# Experimental
|
||||
# Primary server for redis needs votifier
|
||||
# Set socket host on each proxy and redissockets on primary redis only
|
||||
# All servers on pluginmessaging
|
||||
# ----------------------------
|
||||
|
||||
# Support for redis
|
||||
# experimental
|
||||
RedisSupport: false
|
||||
|
||||
# Enable on primary server with votifier
|
||||
PrimaryServer: false
|
||||
|
||||
RedisSocketHost:
|
||||
Host: 0.0.0.0
|
||||
Port: 1234
|
||||
|
||||
RedisServers:
|
||||
secondproxy:
|
||||
Host: 0.0.0.0
|
||||
Port: 1235
|
||||
+271
-257
@@ -1,257 +1,271 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.VotingPluginMain
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: BenCodez
|
||||
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe]
|
||||
loadbefore: [MCPerks]
|
||||
api-version: 1.13
|
||||
libraries:
|
||||
- org.openjdk.nashorn:nashorn-core:15.3
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
adminvote:
|
||||
description: Admin commands for VotingPlugin
|
||||
av:
|
||||
description: Admin commands for VotingPlugin
|
||||
votehelp:
|
||||
description: See access to a list of commands, Formated in Format.yml
|
||||
aliases: vhelp
|
||||
votetotal:
|
||||
description: See totals of votes
|
||||
aliases: vtotal
|
||||
votelast:
|
||||
description: See the last time you voted
|
||||
aliases: vlast
|
||||
votenext:
|
||||
description: See when you can vote next
|
||||
aliases: vnext
|
||||
votetop:
|
||||
description: See top voters
|
||||
aliases: vtop
|
||||
votetoday:
|
||||
description: See who voted today
|
||||
aliases: vtoday
|
||||
votegui:
|
||||
description: Open VoteGUI
|
||||
aliases: vgui
|
||||
voteurl:
|
||||
description: Open VoteURL
|
||||
aliases: vurl
|
||||
votereward:
|
||||
description: Open VoteReward GUI
|
||||
aliases: vreward
|
||||
vote?:
|
||||
description: View Help
|
||||
aliases: v?
|
||||
voteparty:
|
||||
description: A command
|
||||
aliases: vparty
|
||||
voteshop:
|
||||
description: A command
|
||||
aliases: vshop
|
||||
votebest:
|
||||
description: A command
|
||||
aliases: vbest
|
||||
votestreak:
|
||||
description: A command
|
||||
aliases: vstreak
|
||||
votetogglebroadcast:
|
||||
description: A command
|
||||
aliases: vtogglebroadcast
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votetogglereminders:
|
||||
aliases: [vtogglereminder,vtoggle]
|
||||
votelist:
|
||||
description: A command
|
||||
aliases: vlist
|
||||
voteall:
|
||||
description: A command
|
||||
aliases: vall
|
||||
votechoices:
|
||||
description: A command
|
||||
alaises: vchoices
|
||||
votegivepoints:
|
||||
description: A command
|
||||
alaises: vgivepoints
|
||||
adminvotehelp:
|
||||
description: Open adminvote help
|
||||
aliases: avhelp
|
||||
adminvote?:
|
||||
description: Open adminvote help
|
||||
aliases: av?
|
||||
adminvotereport:
|
||||
description: Command Alias
|
||||
aliases: avreport
|
||||
adminvoteperms:
|
||||
description: Command Alias
|
||||
aliases: avperms
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
adminvotetestreward:
|
||||
description: Command Alias
|
||||
aliases: avtestreward
|
||||
adminvoteversion:
|
||||
description: Command Alias
|
||||
aliases: avversion
|
||||
adminvotesites:
|
||||
description: Command Alias
|
||||
aliases: avsites
|
||||
adminvoterewards:
|
||||
description: Command Alias
|
||||
aliases: avrewards
|
||||
adminvoteuuid:
|
||||
description: Command Alias
|
||||
aliases: avuuid
|
||||
adminvotevotesite:
|
||||
description: Command Alias
|
||||
aliases: avvotesite
|
||||
adminvoteconfig:
|
||||
description: Command Alias
|
||||
aliases: avconfig
|
||||
adminvoteupdatecheck:
|
||||
description: Command Alias
|
||||
aliases: avupdatecheck
|
||||
adminvotevote:
|
||||
description: Command Alias
|
||||
aliases: [avvote, fakevote]
|
||||
adminvotegui:
|
||||
description: Command Alias
|
||||
aliases: avgui
|
||||
adminvotegivereward:
|
||||
description: Command Alias
|
||||
aliases: avgivereward
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteConvertToData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteVoteParty:
|
||||
description: Command Alias
|
||||
aliases: avVoteParty
|
||||
adminvoteChoices:
|
||||
description: Command Alias
|
||||
aliases: avChoices
|
||||
adminvoteReloadAll:
|
||||
description: Command Alias
|
||||
aliases: avReloadAll
|
||||
adminvotePermsPlayer:
|
||||
description: Command Alias
|
||||
aliases: avPermsPlayer
|
||||
adminvoteResyncMilestonesAlreadyGiven:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestonesAlreadyGiven
|
||||
voteSetPrimaryAccount:
|
||||
description: Command Alias
|
||||
adminvoteClearOfflineVotes:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineVotes
|
||||
adminvoteGiveAll:
|
||||
description: Command Alias
|
||||
aliases: avGiveAll
|
||||
adminvoteGiveAllOnline:
|
||||
description: Command Alias
|
||||
aliases: avGiveAllOnline
|
||||
adminvoteForceTimeChanged:
|
||||
description: Command Alias
|
||||
aliases: avForceTimeChanged
|
||||
adminvoteplayername:
|
||||
description: Command Alias
|
||||
aliases: avplayername
|
||||
adminvoteResyncMilestones:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestones
|
||||
adminvoteClearOfflineRewards:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineRewards
|
||||
adminvoteUserRemove:
|
||||
description: Command Alias
|
||||
aliases: avUserRemove
|
||||
adminvotePurge:
|
||||
description: Command Alias
|
||||
aliases: avPurge
|
||||
adminvoteJavascript:
|
||||
description: Command Alias
|
||||
aliases: avJavascript
|
||||
adminvoteStatus:
|
||||
description: Command Alias
|
||||
aliases: avStatus
|
||||
adminvoteTest:
|
||||
description: Command Alias
|
||||
aliases: avTest
|
||||
adminvotePlaceholders:
|
||||
description: Command Alias
|
||||
aliases: avPlaceholders
|
||||
adminvoteDownloadJenkins:
|
||||
description: Command Alias
|
||||
aliases: avDownloadJenkins
|
||||
adminvoteSetRequestMethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
adminvoteUser:
|
||||
description: Command Alias
|
||||
aliases: avUser
|
||||
adminvoteCurrentPluginTime:
|
||||
description: Command Alias
|
||||
aliases: avCurrentPluginTime
|
||||
adminvoteResetPoints:
|
||||
description: Command Alias
|
||||
aliases: avResetPoints
|
||||
adminvoteRunCMD:
|
||||
description: Command Alias
|
||||
aliases: avRunCMD
|
||||
adminvoteuseruuidremove:
|
||||
description: Command Alias
|
||||
aliases: avuseruuidremove
|
||||
adminvoteedit:
|
||||
description: Command Alias
|
||||
aliases: avedit
|
||||
adminvoteResetMilestoneCount:
|
||||
description: Command Alias
|
||||
aliases: avResetMilestoneCount
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
VotingPlugin.Mod:
|
||||
description: Allows mod commands
|
||||
VotingPlugin.Admin:
|
||||
description: Allows admincommands
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Allows players to get remined on login if they can vote
|
||||
default: true
|
||||
VotingPlugin.Admin.Debug:
|
||||
description: Permission to view debug info ingame
|
||||
VotingPlugin.Signs.Create:
|
||||
description: Allows access to create signs
|
||||
VotingPlugin.TopVoter.Ignore:
|
||||
description: Allows you to be exempt from top voter
|
||||
VotingPlugin.NoRemind:
|
||||
description: Ignore vote reminding
|
||||
default: false
|
||||
VotingPlugin.Sign.Create:
|
||||
description: Permission to create sign
|
||||
VotingPlugin.Admin.GenerateServiceSite:
|
||||
description: Permission for generating votesite message
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Permission to allow timed reminders
|
||||
VotingPlugin.Login.RemindVotes.All:
|
||||
description: Remind if player can vote on all votesites, rather than any
|
||||
default: false
|
||||
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.VotingPluginMain
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: BenCodez
|
||||
softdepend:
|
||||
- MVdWPlaceholders
|
||||
- Votifier
|
||||
- VotifierPlus
|
||||
- NuVotifier
|
||||
- CMI
|
||||
- Vault
|
||||
- PlaceholderAPI
|
||||
- ProtocolLib
|
||||
- MVdWPlaceholderAPI
|
||||
- AuthMe
|
||||
- SuperVanish
|
||||
- PremiumVanish
|
||||
- DiscordSRV
|
||||
loadbefore:
|
||||
- MCPerks
|
||||
api-version: 1.13
|
||||
libraries:
|
||||
- org.openjdk.nashorn:nashorn-core:15.3
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
adminvote:
|
||||
description: Admin commands for VotingPlugin
|
||||
av:
|
||||
description: Admin commands for VotingPlugin
|
||||
votehelp:
|
||||
description: See access to a list of commands, Formated in Format.yml
|
||||
aliases: vhelp
|
||||
votetotal:
|
||||
description: See totals of votes
|
||||
aliases: vtotal
|
||||
votelast:
|
||||
description: See the last time you voted
|
||||
aliases: vlast
|
||||
votenext:
|
||||
description: See when you can vote next
|
||||
aliases: vnext
|
||||
votetop:
|
||||
description: See top voters
|
||||
aliases: vtop
|
||||
votetoday:
|
||||
description: See who voted today
|
||||
aliases: vtoday
|
||||
votegui:
|
||||
description: Open VoteGUI
|
||||
aliases: vgui
|
||||
voteurl:
|
||||
description: Open VoteURL
|
||||
aliases: vurl
|
||||
votereward:
|
||||
description: Open VoteReward GUI
|
||||
aliases: vreward
|
||||
vote?:
|
||||
description: View Help
|
||||
aliases: v?
|
||||
voteparty:
|
||||
description: A command
|
||||
aliases: vparty
|
||||
voteshop:
|
||||
description: A command
|
||||
aliases: vshop
|
||||
votebest:
|
||||
description: A command
|
||||
aliases: vbest
|
||||
votestreak:
|
||||
description: A command
|
||||
aliases: vstreak
|
||||
votetogglebroadcast:
|
||||
description: A command
|
||||
aliases: vtogglebroadcast
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votetogglereminders:
|
||||
aliases:
|
||||
- vtogglereminder
|
||||
- vtoggle
|
||||
votelist:
|
||||
description: A command
|
||||
aliases: vlist
|
||||
voteall:
|
||||
description: A command
|
||||
aliases: vall
|
||||
votechoices:
|
||||
description: A command
|
||||
alaises: vchoices
|
||||
votegivepoints:
|
||||
description: A command
|
||||
alaises: vgivepoints
|
||||
adminvotehelp:
|
||||
description: Open adminvote help
|
||||
aliases: avhelp
|
||||
adminvote?:
|
||||
description: Open adminvote help
|
||||
aliases: av?
|
||||
adminvotereport:
|
||||
description: Command Alias
|
||||
aliases: avreport
|
||||
adminvoteperms:
|
||||
description: Command Alias
|
||||
aliases: avperms
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
adminvotetestreward:
|
||||
description: Command Alias
|
||||
aliases: avtestreward
|
||||
adminvoteversion:
|
||||
description: Command Alias
|
||||
aliases: avversion
|
||||
adminvotesites:
|
||||
description: Command Alias
|
||||
aliases: avsites
|
||||
adminvoterewards:
|
||||
description: Command Alias
|
||||
aliases: avrewards
|
||||
adminvoteuuid:
|
||||
description: Command Alias
|
||||
aliases: avuuid
|
||||
adminvotevotesite:
|
||||
description: Command Alias
|
||||
aliases: avvotesite
|
||||
adminvoteconfig:
|
||||
description: Command Alias
|
||||
aliases: avconfig
|
||||
adminvoteupdatecheck:
|
||||
description: Command Alias
|
||||
aliases: avupdatecheck
|
||||
adminvotevote:
|
||||
description: Command Alias
|
||||
aliases:
|
||||
- avvote
|
||||
- fakevote
|
||||
adminvotegui:
|
||||
description: Command Alias
|
||||
aliases: avgui
|
||||
adminvotegivereward:
|
||||
description: Command Alias
|
||||
aliases: avgivereward
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteConvertToData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteVoteParty:
|
||||
description: Command Alias
|
||||
aliases: avVoteParty
|
||||
adminvoteChoices:
|
||||
description: Command Alias
|
||||
aliases: avChoices
|
||||
adminvoteReloadAll:
|
||||
description: Command Alias
|
||||
aliases: avReloadAll
|
||||
adminvotePermsPlayer:
|
||||
description: Command Alias
|
||||
aliases: avPermsPlayer
|
||||
adminvoteResyncMilestonesAlreadyGiven:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestonesAlreadyGiven
|
||||
voteSetPrimaryAccount:
|
||||
description: Command Alias
|
||||
adminvoteClearOfflineVotes:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineVotes
|
||||
adminvoteGiveAll:
|
||||
description: Command Alias
|
||||
aliases: avGiveAll
|
||||
adminvoteGiveAllOnline:
|
||||
description: Command Alias
|
||||
aliases: avGiveAllOnline
|
||||
adminvoteForceTimeChanged:
|
||||
description: Command Alias
|
||||
aliases: avForceTimeChanged
|
||||
adminvoteplayername:
|
||||
description: Command Alias
|
||||
aliases: avplayername
|
||||
adminvoteResyncMilestones:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestones
|
||||
adminvoteClearOfflineRewards:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineRewards
|
||||
adminvoteUserRemove:
|
||||
description: Command Alias
|
||||
aliases: avUserRemove
|
||||
adminvotePurge:
|
||||
description: Command Alias
|
||||
aliases: avPurge
|
||||
adminvoteJavascript:
|
||||
description: Command Alias
|
||||
aliases: avJavascript
|
||||
adminvoteStatus:
|
||||
description: Command Alias
|
||||
aliases: avStatus
|
||||
adminvoteTest:
|
||||
description: Command Alias
|
||||
aliases: avTest
|
||||
adminvotePlaceholders:
|
||||
description: Command Alias
|
||||
aliases: avPlaceholders
|
||||
adminvoteDownloadJenkins:
|
||||
description: Command Alias
|
||||
aliases: avDownloadJenkins
|
||||
adminvoteSetRequestMethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
adminvoteUser:
|
||||
description: Command Alias
|
||||
aliases: avUser
|
||||
adminvoteCurrentPluginTime:
|
||||
description: Command Alias
|
||||
aliases: avCurrentPluginTime
|
||||
adminvoteResetPoints:
|
||||
description: Command Alias
|
||||
aliases: avResetPoints
|
||||
adminvoteRunCMD:
|
||||
description: Command Alias
|
||||
aliases: avRunCMD
|
||||
adminvoteuseruuidremove:
|
||||
description: Command Alias
|
||||
aliases: avuseruuidremove
|
||||
adminvoteedit:
|
||||
description: Command Alias
|
||||
aliases: avedit
|
||||
adminvoteResetMilestoneCount:
|
||||
description: Command Alias
|
||||
aliases: avResetMilestoneCount
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
VotingPlugin.Mod:
|
||||
description: Allows mod commands
|
||||
VotingPlugin.Admin:
|
||||
description: Allows admincommands
|
||||
VotingPlugin.Admin.Debug:
|
||||
description: Permission to view debug info ingame
|
||||
VotingPlugin.Signs.Create:
|
||||
description: Allows access to create signs
|
||||
VotingPlugin.TopVoter.Ignore:
|
||||
description: Allows you to be exempt from top voter
|
||||
VotingPlugin.NoRemind:
|
||||
description: Ignore vote reminding
|
||||
default: false
|
||||
VotingPlugin.Sign.Create:
|
||||
description: Permission to create sign
|
||||
VotingPlugin.Admin.GenerateServiceSite:
|
||||
description: Permission for generating votesite message
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Permission to allow timed reminders
|
||||
VotingPlugin.Login.RemindVotes.All:
|
||||
description: Remind if player can vote on all votesites, rather than any
|
||||
default: false
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.8.1</version>
|
||||
<version>6.11</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -226,7 +226,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.19.3-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigSpigot;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
@@ -46,22 +57,199 @@ public class BungeeHandler implements Listener {
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private GlobalDataHandler globalDataHandler;
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
public BungeeHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
|
||||
}
|
||||
|
||||
public void close() {
|
||||
socketHandler.closeConnection();
|
||||
clientHandler.stopConnection();
|
||||
if (socketHandler != null) {
|
||||
socketHandler.closeConnection();
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDateChange(DateChangedEvent event) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("timeupdate", plugin.getServerDataFile().getPrevMonth() + "//"
|
||||
+ plugin.getServerDataFile().getPrevDay() + "//" + plugin.getServerDataFile().getPrevWeekDay());
|
||||
/*
|
||||
* @EventHandler public void onDateChange(DateChangedEvent event) { if
|
||||
* (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
* plugin.getPluginMessaging().sendPluginMessage("timeupdate",
|
||||
* plugin.getServerDataFile().getPrevMonth() + "//" +
|
||||
* plugin.getServerDataFile().getPrevDay() + "//" +
|
||||
* plugin.getServerDataFile().getPrevWeekDay()); } }
|
||||
*/
|
||||
|
||||
public void checkGlobalData() {
|
||||
HashMap<String, DataValue> data = globalDataHandler.getExact(plugin.getBungeeSettings().getServer());
|
||||
// plugin.debug(data.toString());
|
||||
|
||||
if (data.containsKey("ForceUpdate")) {
|
||||
boolean b = checkGlobalDataTimeValue(data.get("ForceUpdate"));
|
||||
if (b) {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "ForceUpdate", false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean forceUpdate = false;
|
||||
|
||||
if (checkGlobalDataTime(TimeType.MONTH, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.WEEK, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.DAY, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(true));
|
||||
dataToSet.put("Processing", new DataValueBoolean(false));
|
||||
globalDataHandler.setData(plugin.getBungeeSettings().getServer(), dataToSet);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
|
||||
public boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
|
||||
boolean isProcessing = false;
|
||||
if (data.containsKey(type.toString())) {
|
||||
|
||||
DataValue value = data.get(type.toString());
|
||||
boolean b = checkGlobalDataTimeValue(value);
|
||||
if (b) {
|
||||
long lastUpdated = Long.valueOf(data.get("LastUpdated").getString()).longValue();
|
||||
plugin.debug("LastUpdated: " + lastUpdated);
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastUpdated > 1000 * 60 * 60
|
||||
* 1) {
|
||||
plugin.getLogger().warning("Ignore bungee time change since it was more than 1 hour ago");
|
||||
return false;
|
||||
}
|
||||
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "Processing", true);
|
||||
isProcessing = true;
|
||||
|
||||
plugin.debug("Detected time change from bungee: " + type.toString());
|
||||
plugin.getTimeChecker().forceChanged(type, false, true, true);
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
}
|
||||
}
|
||||
return isProcessing;
|
||||
}
|
||||
|
||||
public void loadGlobalMysql() {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
if (timer != null) {
|
||||
timer.shutdown();
|
||||
try {
|
||||
timer.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
timer.shutdownNow();
|
||||
}
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkGlobalData();
|
||||
}
|
||||
}, 60, 10, TimeUnit.SECONDS);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
|
||||
}
|
||||
}, 1, 60, TimeUnit.MINUTES);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
|
||||
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
plugin.getTimeChecker().setProcessingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +260,8 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
plugin.getLogger().info("Using BungeeMethod: " + method.toString());
|
||||
|
||||
loadGlobalMysql();
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
@@ -107,6 +297,8 @@ public class BungeeHandler implements Listener {
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
@@ -119,6 +311,11 @@ public class BungeeHandler implements Listener {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
@@ -136,7 +333,7 @@ public class BungeeHandler implements Listener {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
@@ -169,6 +366,8 @@ public class BungeeHandler implements Listener {
|
||||
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);
|
||||
@@ -191,6 +390,11 @@ public class BungeeHandler implements Listener {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
@@ -209,7 +413,7 @@ public class BungeeHandler implements Listener {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
@@ -236,12 +440,21 @@ public class BungeeHandler implements Listener {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("BungeeTimeChange") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
@@ -260,6 +473,19 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
});
|
||||
|
||||
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 = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
args.get(1));
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
@@ -295,7 +521,13 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
socketHandler = new SocketHandler(plugin.getVersion(), plugin.getBungeeSettings().getSpigotServerHost(),
|
||||
plugin.getBungeeSettings().getSpigotServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug());
|
||||
plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
plugin.getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevote") {
|
||||
|
||||
@@ -322,6 +554,14 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeTimeChange") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevoteonline") {
|
||||
|
||||
@Override
|
||||
@@ -347,6 +587,19 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BroadcastOffline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
String votes = data[0];
|
||||
String p = data[1];
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeBroadcast") {
|
||||
|
||||
@Override
|
||||
@@ -364,6 +617,23 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("Broadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[2];
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("Status") {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.bencodez.votingplugin;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
|
||||
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -16,11 +15,11 @@ public class VotingPluginHooks {
|
||||
}
|
||||
|
||||
public void addCustomRequirement(RequirementInject inject) {
|
||||
RewardHandler.getInstance().addInjectedRequirements(inject);
|
||||
getMainClass().getRewardHandler().addInjectedRequirements(inject);
|
||||
}
|
||||
|
||||
public void addCustomReward(RewardInject inject) {
|
||||
RewardHandler.getInstance().addInjectedReward(inject);
|
||||
getMainClass().getRewardHandler().addInjectedReward(inject);
|
||||
}
|
||||
|
||||
public void backgroundUpdate(Player player) {
|
||||
|
||||
@@ -16,8 +16,10 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -44,7 +46,6 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
|
||||
import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardEditData;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardPlaceholderHandle;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection;
|
||||
@@ -80,6 +81,7 @@ import com.bencodez.votingplugin.placeholders.MVdWPlaceholders;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceHolders;
|
||||
import com.bencodez.votingplugin.signs.Signs;
|
||||
import com.bencodez.votingplugin.specialrewards.SpecialRewards;
|
||||
import com.bencodez.votingplugin.timequeue.TimeQueueHandler;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterHandler;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -208,11 +210,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Getter
|
||||
private boolean ymlError = false;
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService voteTimer = Executors.newScheduledThreadPool(1);
|
||||
|
||||
@Getter
|
||||
private UserManager votingPluginUserManager;
|
||||
|
||||
private void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
|
||||
RewardHandler.getInstance().addDirectlyDefined(directlyDefinedReward);
|
||||
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
|
||||
}
|
||||
|
||||
public void basicBungeeUpdate() {
|
||||
@@ -344,11 +349,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String siteName : sites) {
|
||||
if (siteName.equalsIgnoreCase(url)) {
|
||||
return siteName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return url;
|
||||
@@ -402,7 +406,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
public void loadDirectlyDefined() {
|
||||
RewardHandler.getInstance().getDirectlyDefinedRewards().clear();
|
||||
getRewardHandler().getDirectlyDefinedRewards().clear();
|
||||
// AllSites reward
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("AllSites") {
|
||||
|
||||
@@ -427,6 +431,29 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
});
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("AlmostAllSites") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
getSpecialRewardsConfig().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return getSpecialRewardsConfig().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getSpecialRewardsConfig().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
getSpecialRewardsConfig().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
// FirstVote
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("FirstVote") {
|
||||
|
||||
@@ -716,6 +743,29 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteSites." + site.getKey() + ".CoolDownEndRewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
getConfigVoteSites().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return getConfigVoteSites().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getConfigVoteSites().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// vote streaks
|
||||
@@ -879,29 +929,25 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
getTimer().schedule(new TimerTask() {
|
||||
getTimer().scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null) {
|
||||
update();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 1000, 1000 * 60 * configFile.getDelayBetweenUpdates());
|
||||
}, 1000, 1000 * 60 * configFile.getDelayBetweenUpdates(), TimeUnit.MILLISECONDS);
|
||||
|
||||
getTimer().schedule(new TimerTask() {
|
||||
getTimer().scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && configFile.isExtraBackgroundUpdate()) {
|
||||
basicBungeeUpdate();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 1000, 1000 * 30);
|
||||
}, 1000, 1000 * 30, TimeUnit.MILLISECONDS);
|
||||
|
||||
}
|
||||
}, 40L);
|
||||
@@ -952,9 +998,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
* Metrics.
|
||||
*/
|
||||
private void metrics() {
|
||||
new VotingPluginMetrics().load(this);
|
||||
new VotingPluginMetrics().load(plugin);
|
||||
}
|
||||
|
||||
@Getter
|
||||
private TimeQueueHandler timeQueueHandler;
|
||||
|
||||
@Override
|
||||
public void onPostLoad() {
|
||||
loadVersionFile();
|
||||
@@ -970,6 +1019,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
if (!bungeeSettings.isUseBungeecoord() || !bungeeSettings.isGloblalDataEnabled()) {
|
||||
this.timeQueueHandler = new TimeQueueHandler(this);
|
||||
}
|
||||
|
||||
registerCommands();
|
||||
checkVotifier();
|
||||
registerEvents();
|
||||
@@ -1017,7 +1070,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
topVoterHandler.register();
|
||||
|
||||
metrics();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
metrics();
|
||||
}
|
||||
});
|
||||
|
||||
// javascript api
|
||||
getJavascriptEngineRequests().add(new JavascriptPlaceholderRequest("User") {
|
||||
@@ -1041,15 +1100,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
// Add rewards
|
||||
RewardHandler.getInstance().addInjectedReward(new RewardInjectInt("Points", 0) {
|
||||
getRewardHandler().addInjectedReward(new RewardInjectInt("Points", 0) {
|
||||
|
||||
@Override
|
||||
public String onRewardRequest(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
|
||||
int num, HashMap<String, String> placeholders) {
|
||||
UserManager.getInstance().getVotingPluginUser(user).addPoints(num);
|
||||
return null;
|
||||
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
|
||||
String str = "" + vpUser.addPoints(num);
|
||||
debug("Setting points to " + str);
|
||||
return str;
|
||||
}
|
||||
}.synchronize().addEditButton(
|
||||
}.synchronize().asPlaceholder("newpoints").addEditButton(
|
||||
new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueNumber("Points", null) {
|
||||
|
||||
@Override
|
||||
@@ -1067,7 +1128,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}));
|
||||
|
||||
RewardHandler.getInstance().addInjectedReward(new RewardInjectConfigurationSection("VoteBossBar") {
|
||||
getRewardHandler().addInjectedReward(new RewardInjectConfigurationSection("VoteBossBar") {
|
||||
|
||||
@Override
|
||||
public String onRewardRequested(Reward arg0, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
|
||||
@@ -1086,7 +1147,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
});
|
||||
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
RewardHandler.getInstance().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
|
||||
getRewardHandler().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
|
||||
|
||||
@Override
|
||||
public String getValue(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
|
||||
@@ -1107,7 +1168,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
"Using dev build, this is not a stable build, use at your own risk. Build number: " + buildNumber);
|
||||
}
|
||||
|
||||
boolean hasRewards = RewardHandler.getInstance().hasRewards(getConfigVoteSites().getData(),
|
||||
boolean hasRewards = getRewardHandler().hasRewards(getConfigVoteSites().getData(),
|
||||
getConfigVoteSites().getEverySiteRewardPath());
|
||||
|
||||
boolean issues = true;
|
||||
@@ -1186,8 +1247,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onUnLoad() {
|
||||
getSigns().storeSigns();
|
||||
HandlerList.unregisterAll(plugin);
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
try {
|
||||
getBungeeHandler().close();
|
||||
@@ -1195,6 +1254,11 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
debug(e);
|
||||
}
|
||||
}
|
||||
if (timeQueueHandler != null) {
|
||||
timeQueueHandler.save();
|
||||
}
|
||||
getSigns().storeSigns();
|
||||
HandlerList.unregisterAll(plugin);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
@@ -1251,6 +1315,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
pm.registerEvents(new PlayerInteract(this), this);
|
||||
}
|
||||
|
||||
if (timeQueueHandler != null) {
|
||||
pm.registerEvents(timeQueueHandler, plugin);
|
||||
}
|
||||
|
||||
pm.registerEvents(new VotingPluginUpdateEvent(this), this);
|
||||
/*
|
||||
* if (!NMSManager.getInstance().isVersion("1.12")) { pm.registerEvents(new
|
||||
@@ -1288,10 +1356,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
gui.reloadData();
|
||||
|
||||
bungeeSettings.reloadData();
|
||||
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
getBungeeHandler().loadGlobalMysql();
|
||||
}
|
||||
checkYMLError();
|
||||
|
||||
if (broadcastHandler != null) {
|
||||
broadcastHandler.schelude(getConfigFile().getFormatAlternateBroadcastDelay());
|
||||
broadcastHandler.schedule(getConfigFile().getFormatAlternateBroadcastDelay());
|
||||
}
|
||||
|
||||
updateAdvancedCoreHook();
|
||||
@@ -1352,8 +1424,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
placeholders.onUpdate();
|
||||
|
||||
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
|
||||
try {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
@@ -1364,6 +1434,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
ArrayList<TopVoter> topVotersToCheck = new ArrayList<TopVoter>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (plugin == null) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getConfigFile().getLoadTopVoter(top)) {
|
||||
topVotersToCheck.add(top);
|
||||
tempTopVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
|
||||
@@ -1438,6 +1511,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
time1 = System.currentTimeMillis();
|
||||
|
||||
topVoterHandler.updateTopVoters(tempTopVoter);
|
||||
placeholders.onUpdate();
|
||||
setVoteToday(voteToday);
|
||||
serverData.updateValues();
|
||||
getSigns().updateSigns();
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
public class VotingPluginMetrics {
|
||||
@@ -15,7 +14,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
@@ -27,7 +26,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
@@ -39,7 +38,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
@@ -94,7 +93,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
@@ -109,7 +108,7 @@ public class VotingPluginMetrics {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Day")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Day", s)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Day", s))) {
|
||||
return "True";
|
||||
}
|
||||
@@ -126,7 +125,7 @@ public class VotingPluginMetrics {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Week")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Week", s)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Week", s))) {
|
||||
return "True";
|
||||
}
|
||||
@@ -143,7 +142,7 @@ public class VotingPluginMetrics {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Month")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Month", s)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Month", s))) {
|
||||
return "True";
|
||||
}
|
||||
@@ -163,7 +162,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + RewardHandler.getInstance().getRewards().size();
|
||||
return "" + plugin.getRewardHandler().getRewards().size();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites", new Callable<String>() {
|
||||
@@ -179,37 +178,29 @@ public class VotingPluginMetrics {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size();
|
||||
if (total < 1000) {
|
||||
return "<1000";
|
||||
if (total > 800000) {
|
||||
return ">800000";
|
||||
} else if (total > 700000) {
|
||||
return "700000-800000";
|
||||
} else if (total > 600000) {
|
||||
return "600000-700000";
|
||||
} else if (total > 500000) {
|
||||
return "500000-600000";
|
||||
} else if (total > 400000) {
|
||||
return "400000-500000";
|
||||
} else if (total > 300000) {
|
||||
return "300000-400000";
|
||||
} else if (total > 200000) {
|
||||
return "200000-300000";
|
||||
} else if (total > 100000) {
|
||||
return "100000-200000";
|
||||
} else if (total > 10000) {
|
||||
return ">10000";
|
||||
} else {
|
||||
return "1000-10000";
|
||||
return ">10000-100000";
|
||||
}
|
||||
return "<10000";
|
||||
}
|
||||
}));
|
||||
|
||||
int users = UserManager.getInstance().getAllUUIDs().size();
|
||||
if (users > 1000) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users_in_thousands", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
|
||||
return "" + total;
|
||||
}
|
||||
}));
|
||||
}
|
||||
if (users > 10000) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users_in_thousands_plus_10", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
|
||||
return "" + total;
|
||||
}
|
||||
}));
|
||||
}
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -300,8 +291,33 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getBungeeSettings().isTriggerVotifierEvent();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("globaldata_enabled", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isGloblalDataEnabled();
|
||||
}
|
||||
}));
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("globaldata_usemainmysql", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isGloblalDataUseMainMySQL();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("persitecooldownevents", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isPerSiteCoolDownEvents();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("geyserprefixsupport", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -330,7 +346,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + (!plugin.getConfigFile().isDisableCoolDownCheck() && RewardHandler.getInstance()
|
||||
return "" + (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward"));
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -2,9 +2,10 @@ package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -16,12 +17,12 @@ import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
public class BroadcastHandler {
|
||||
private VotingPluginMain plugin;
|
||||
private Timer timer;
|
||||
private ScheduledExecutorService timer;
|
||||
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
public BroadcastHandler(VotingPluginMain plugin, int delay) {
|
||||
this.plugin = plugin;
|
||||
schelude(delay);
|
||||
schedule(delay);
|
||||
}
|
||||
|
||||
public void check() {
|
||||
@@ -32,8 +33,16 @@ public class BroadcastHandler {
|
||||
}
|
||||
String bc = StringParser.getInstance()
|
||||
.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
|
||||
String playersText = "";
|
||||
while (!votedPlayers.isEmpty()) {
|
||||
playersText += votedPlayers.remove();
|
||||
if (!votedPlayers.isEmpty()) {
|
||||
playersText += ", ";
|
||||
}
|
||||
}
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("numberofplayers", "" + size);
|
||||
placeholders.put("players", playersText);
|
||||
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
@@ -50,19 +59,19 @@ public class BroadcastHandler {
|
||||
votedPlayers.add(player);
|
||||
}
|
||||
|
||||
public void schelude(int delay) {
|
||||
public void schedule(int delay) {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = new Timer();
|
||||
timer.shutdownNow();
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
} else {
|
||||
timer = new Timer();
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
timer.schedule(new TimerTask() {
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
check();
|
||||
}
|
||||
}, 1000 * 60, 1000 * 60 * delay);
|
||||
}, 60, 60 * delay, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,26 @@ public class Config {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public boolean getGeyserSupport() {
|
||||
return getData().getBoolean("GeyserSupport", false);
|
||||
}
|
||||
|
||||
public String getGeyserPrefix() {
|
||||
return getData().getString("GeyserPrefix", ".");
|
||||
}
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
return getData().getBoolean("OnlineMode", true);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getData().getBoolean("GlobalData.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getData().getBoolean("GlobalData.UseMainMySQL", true);
|
||||
}
|
||||
|
||||
public boolean getRedisSupport() {
|
||||
return getData().getBoolean("RedisSupport", false);
|
||||
}
|
||||
@@ -53,6 +73,14 @@ public class Config {
|
||||
return getData().getInt("BungeeServer.Port", 1297);
|
||||
}
|
||||
|
||||
public int getRedisSocketHostPort() {
|
||||
return getData().getInt("RedisSocketHost.Port", 1297);
|
||||
}
|
||||
|
||||
public String getRedisSocketHostHost() {
|
||||
return getData().getString("RedisSocketHost.Host", "");
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return getData().getBoolean("Debug", false);
|
||||
}
|
||||
@@ -73,6 +101,14 @@ public class Config {
|
||||
return getData().getSection("SpigotServers." + s);
|
||||
}
|
||||
|
||||
public Configuration getRedisServersConfiguration(String s) {
|
||||
return getData().getSection("RedisServers." + s);
|
||||
}
|
||||
|
||||
public Collection<String> getRedisServers() {
|
||||
return getData().getSection("RedisServers").getKeys();
|
||||
}
|
||||
|
||||
public Collection<String> getSpigotServers() {
|
||||
return getData().getSection("SpigotServers").getKeys();
|
||||
}
|
||||
@@ -81,6 +117,10 @@ public class Config {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
public boolean getPrimaryServer() {
|
||||
return getData().getBoolean("PrimaryServer", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled", false);
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
@Deprecated
|
||||
public class RedisBungee implements Listener {
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public abstract class TimeHandle {
|
||||
@Getter
|
||||
@Setter
|
||||
private String month;
|
||||
@Getter
|
||||
@Setter
|
||||
private int day;
|
||||
@Getter
|
||||
@Setter
|
||||
private int week;
|
||||
|
||||
public TimeHandle(String month, int day, int week) {
|
||||
this.month = month;
|
||||
this.day = day;
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public abstract void save();
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
@@ -52,6 +54,13 @@ public class VoteCache {
|
||||
section.set("Text", voteData.getText());
|
||||
}
|
||||
|
||||
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
|
||||
Configuration section = getData().getSection("TimedVoteCache." + num);
|
||||
section.set("Name", voteTimedQueue.getName());
|
||||
section.set("Service", voteTimedQueue.getService());
|
||||
section.set("Time", voteTimedQueue.getTime());
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
Configuration section = getData().getSection("OnlineCache." + player + "." + num);
|
||||
section.set("Name", voteData.getPlayerName());
|
||||
@@ -84,6 +93,14 @@ public class VoteCache {
|
||||
return getData().getSection("VoteCache").getKeys();
|
||||
}
|
||||
|
||||
public Configuration getTimedVoteCache(String key) {
|
||||
return getData().getSection("TimedVoteCache." + key);
|
||||
}
|
||||
|
||||
public Collection<String> getTimedVoteCache() {
|
||||
return getData().getSection("TimedVoteCache").getKeys();
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getData().getSection("VoteCache." + server).getKeys();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
|
||||
public void onVote(VotifierEvent event) {
|
||||
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
Vote vote = event.getVote();
|
||||
@@ -24,11 +25,13 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
|
||||
|
||||
if (serviceSite.isEmpty()) {
|
||||
serviceSite = "Empty";
|
||||
vote.setServiceName(serviceSite);
|
||||
}
|
||||
|
||||
plugin.vote(vote.getUsername(), serviceSite, true);
|
||||
plugin.vote(vote.getUsername(), serviceSite, true, true, 0, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,31 +11,43 @@ import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.CodeSource;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.misc.jsonparser.JsonParser;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigBungee;
|
||||
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.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.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
@@ -62,6 +74,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
private HashMap<String, ClientHandler> clientHandles;
|
||||
|
||||
private HashMap<String, ClientHandler> redisClientHandles;
|
||||
|
||||
@Getter
|
||||
private Config config;
|
||||
|
||||
@@ -77,15 +91,21 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private SocketHandler redisSocketHandler;
|
||||
|
||||
private VoteCache voteCacheFile;
|
||||
|
||||
private boolean votifierEnabled = true;
|
||||
|
||||
@Getter
|
||||
private RedisBungee redis;
|
||||
private ConcurrentHashMap<UUID, String> uuidPlayerNameCache = new ConcurrentHashMap<UUID, String>();
|
||||
|
||||
@Getter
|
||||
private TimeHandle timeHandle;
|
||||
private BungeeTimeChecker bungeeTimeChecker;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
@Getter
|
||||
private GlobalDataHandlerProxy globalDataHandler;
|
||||
|
||||
public synchronized void checkCachedVotes(String server) {
|
||||
if (getProxy().getServerInfo(server) != null) {
|
||||
@@ -94,6 +114,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
ArrayList<OfflineBungeeVote> c = cachedVotes.get(server);
|
||||
ArrayList<OfflineBungeeVote> newSet = new ArrayList<OfflineBungeeVote>();
|
||||
if (!c.isEmpty()) {
|
||||
int num = 1;
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
boolean toSend = true;
|
||||
if (getConfig().getWaitForUserOnline()) {
|
||||
@@ -111,7 +132,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(),
|
||||
"" + num);
|
||||
num++;
|
||||
} else {
|
||||
debug("Not sending vote because user isn't on server " + server + ": "
|
||||
+ cache.toString());
|
||||
@@ -134,11 +157,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
server = getProxy().getPlayer(UUID.fromString(uuid)).getServer().getInfo().getName();
|
||||
}
|
||||
if (!config.getBlockedServers().contains(server)) {
|
||||
int num = 1;
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendPluginMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num);
|
||||
num++;
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
@@ -152,7 +177,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void debug2(String msg) {
|
||||
debug(msg);
|
||||
}
|
||||
|
||||
public UUID fetchUUID(String playerName) throws Exception {
|
||||
if (playerName == null || playerName.equalsIgnoreCase("null")) {
|
||||
return null;
|
||||
}
|
||||
// Get response from Mojang API
|
||||
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
@@ -184,20 +216,34 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
ProxiedPlayer p = getProxy().getPlayer(playerName);
|
||||
if (p != null && p.isConnected()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
if (mysql != null) {
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
if (config.getOnlineMode()) {
|
||||
|
||||
ProxiedPlayer p = getProxy().getPlayer(playerName);
|
||||
if (p != null && p.isConnected()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
|
||||
for (Entry<UUID, String> entry : uuidPlayerNameCache.entrySet()) {
|
||||
if (entry.getValue().equalsIgnoreCase(playerName)) {
|
||||
return entry.getKey().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (mysql != null) {
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
|
||||
return "";
|
||||
} else {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(StandardCharsets.UTF_8)).toString();
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
private int getValue(ArrayList<Column> cols, String column, int toAdd) {
|
||||
@@ -220,6 +266,16 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private Queue<VoteTimeQueue> timeChangeQueue = new ConcurrentLinkedQueue<VoteTimeQueue>();
|
||||
|
||||
public void processQueue() {
|
||||
while (getTimeChangeQueue().size() > 0) {
|
||||
VoteTimeQueue vote = getTimeChangeQueue().remove();
|
||||
vote(vote.getName(), vote.getService(), true, false, vote.getTime(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
mysql = new BungeeMySQL(this, "VotingPlugin_Users", config.getData()) {
|
||||
|
||||
@@ -231,6 +287,131 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
};
|
||||
|
||||
ArrayList<String> servers = new ArrayList<String>();
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
servers.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getGlobalDataEnabled()) {
|
||||
if (config.getGlobalDataUseMainMySQL()) {
|
||||
globalDataHandler = new GlobalDataHandlerProxy(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
}, servers) {
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
}
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
getGlobalDataHandler().setBoolean(s, "ForceUpdate", true);
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage(s, "BungeeTimeChange");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processQueue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getGlobalDataHandler().setBoolean(server, type.toString(), false);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandlerProxy(new GlobalMySQL("VotingPlugin_GlobalData",
|
||||
new MysqlConfigBungee(config.getData().getSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
}, servers) {
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
}
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
getGlobalDataHandler().setBoolean(s, "ForceUpdate", true);
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage(s, "BungeeTimeChange");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processQueue();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getGlobalDataHandler().setBoolean(server, type.toString(), false);
|
||||
}
|
||||
};
|
||||
}
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
}
|
||||
|
||||
// column types
|
||||
getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
@@ -319,20 +500,27 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
timeHandle.save();
|
||||
if (!timeChangeQueue.isEmpty()) {
|
||||
int num = 0;
|
||||
for (VoteTimeQueue vote : timeChangeQueue) {
|
||||
voteCacheFile.addTimedVote(num, vote);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
voteCacheFile.save();
|
||||
nonVotedPlayersCache.save();
|
||||
if (mysql != null) {
|
||||
mysql.shutdown();
|
||||
}
|
||||
if (redis != null) {
|
||||
redis.destroy();
|
||||
}
|
||||
getLogger().info("VotingPlugin disabled");
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
private VoteEventBungee voteEventBungee;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
enabled = true;
|
||||
try {
|
||||
Class.forName("com.vexsoftware.votifier.bungee.events.VotifierEvent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
@@ -341,7 +529,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
if (votifierEnabled) {
|
||||
try {
|
||||
getProxy().getPluginManager().registerListener(this, new VoteEventBungee(this));
|
||||
voteEventBungee = new VoteEventBungee(this);
|
||||
getProxy().getPluginManager().registerListener(this, voteEventBungee);
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
@@ -350,12 +539,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
config = new Config(this);
|
||||
config.load();
|
||||
|
||||
try {
|
||||
redis = new RedisBungee(this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
|
||||
|
||||
boolean mysqlLoaded = true;
|
||||
@@ -376,25 +559,151 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
method = BungeeMethod.PLUGINMESSAGING;
|
||||
}
|
||||
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getData().getInt("TimeHourOffSet")) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timeChanged(TimeType type, boolean fake, boolean pre, boolean post) {
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
}
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
if (getGlobalDataHandler().getGlobalMysql().containsKey(s)) {
|
||||
String lastOnlineStr = getGlobalDataHandler().getString(s, "LastOnline");
|
||||
long lastOnline = 0;
|
||||
try {
|
||||
lastOnline = Long.valueOf(lastOnlineStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli()
|
||||
- lastOnline < 1000 * 60 * 60 * 12) {
|
||||
// server has been online within the 12 hours
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
|
||||
dataToSet.put("LastUpdated", new DataValueString(
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli()));
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(false));
|
||||
dataToSet.put(type.toString(), new DataValueBoolean(true));
|
||||
getGlobalDataHandler().setData(s, dataToSet);
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage(s, "BungeeTimeChange");
|
||||
}
|
||||
} else {
|
||||
getLogger().warning("Server " + s + " hasn't been online recently");
|
||||
}
|
||||
} else {
|
||||
getLogger().warning("Server " + s + " global data handler disabled?");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
globalDataHandler.onTimeChange(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrevWeek(int week) {
|
||||
voteCacheFile.getData().set("Time.Week", week);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrevMonth(String text) {
|
||||
voteCacheFile.getData().set("Time.Month", text);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrevDay(int day) {
|
||||
voteCacheFile.getData().set("Time.Day", day);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastUpdated() {
|
||||
voteCacheFile.getData().set("Time.LastUpdated", System.currentTimeMillis());
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreTime(boolean ignore) {
|
||||
voteCacheFile.getData().set("Time.IgnoreTime", ignore);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoreTime() {
|
||||
return voteCacheFile.getData().getBoolean("Time.IgnoreTime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevWeek() {
|
||||
return voteCacheFile.getData().getInt("Time.Week");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrevMonth() {
|
||||
return voteCacheFile.getData().getString("Time.Month");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevDay() {
|
||||
return voteCacheFile.getData().getInt("Time.Day");
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastUpdated() {
|
||||
return voteCacheFile.getData().getLong("Time.LastUpdated");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
};
|
||||
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
if (mysqlLoaded) {
|
||||
|
||||
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
|
||||
|
||||
voteCacheFile = new VoteCache(this);
|
||||
voteCacheFile.load();
|
||||
|
||||
bungeeTimeChecker.loadTimer();
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(this);
|
||||
nonVotedPlayersCache.load();
|
||||
|
||||
timeHandle = new TimeHandle(voteCacheFile.getData().getString("Time.Month", ""),
|
||||
voteCacheFile.getData().getInt("Time.Day"), voteCacheFile.getData().getInt("Time.Week")) {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
voteCacheFile.getData().set("Time.Month", timeHandle.getMonth());
|
||||
voteCacheFile.getData().set("Time.Day", timeHandle.getDay());
|
||||
voteCacheFile.getData().set("Time.Week", timeHandle.getWeek());
|
||||
try {
|
||||
for (String key : voteCacheFile.getTimedVoteCache()) {
|
||||
Configuration data = voteCacheFile.getTimedVoteCache(key);
|
||||
timeChangeQueue.add(
|
||||
new VoteTimeQueue(data.getString("Name"), data.getString("Service"), data.getLong("Time")));
|
||||
}
|
||||
};
|
||||
|
||||
processQueue();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
@@ -434,6 +743,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (String server : cachedVotes.keySet()) {
|
||||
checkCachedVotes(server);
|
||||
}
|
||||
@@ -458,7 +768,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
|
||||
socketHandler = new SocketHandler(getDescription().getVersion(), config.getBungeeHost(),
|
||||
config.getBungeePort(), encryptionHandler, config.getDebug());
|
||||
config.getBungeePort(), encryptionHandler, config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@@ -499,11 +815,51 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
}
|
||||
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
if (getConfig().getRedisSupport()) {
|
||||
if (encryptionHandler == null) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
}
|
||||
|
||||
redisSocketHandler = new SocketHandler(getDescription().getVersion(), config.getRedisSocketHostHost(),
|
||||
config.getRedisSocketHostPort(), encryptionHandler, config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
redisSocketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 8) {
|
||||
if (data[0].equalsIgnoreCase("Vote")) {
|
||||
// todo
|
||||
// sendRedisServerMessage("Vote", uuid, player, service, "" + votePartyVotes,""
|
||||
// + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
|
||||
vote(data[2], data[3], Boolean.valueOf(data[7]), true, 0, new BungeeMessageData(data[8]),
|
||||
data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clientHandles = new HashMap<String, ClientHandler>();
|
||||
for (
|
||||
|
||||
String s : config.getRedisServers()) {
|
||||
Configuration d = config.getRedisServersConfiguration(s);
|
||||
redisClientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1234),
|
||||
encryptionHandler, config.getDebug()));
|
||||
}
|
||||
}
|
||||
|
||||
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
|
||||
|
||||
@@ -525,6 +881,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("waitforuseronline", () -> "" + getConfig().getWaitForUserOnline()));
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("globaldata_enabled", () -> "" + getConfig().getGlobalDataEnabled()));
|
||||
if (getConfig().getGlobalDataEnabled()) {
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("globaldata_usemainmysql",
|
||||
() -> "" + getConfig().getGlobalDataUseMainMySQL()));
|
||||
}
|
||||
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("dev_build_number", () -> "" + buildNumber));
|
||||
}
|
||||
@@ -554,11 +917,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
public boolean isOnline(ProxiedPlayer p) {
|
||||
if (p != null) {
|
||||
if (redis != null && redis.isEnabled()) {
|
||||
return redis.isOnline(p);
|
||||
} else {
|
||||
return p.isConnected();
|
||||
}
|
||||
return p.isConnected();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -615,14 +974,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
||||
login(p);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("timeupdate")) {
|
||||
String str = in.readUTF();
|
||||
String[] data = str.split(Pattern.quote("//"));
|
||||
if (data.length == 3) {
|
||||
timeHandle.setMonth(data[0]);
|
||||
timeHandle.setDay(Integer.parseInt(data[1]));
|
||||
timeHandle.setWeek(Integer.parseInt(data[2]));
|
||||
}
|
||||
} else {
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
@@ -703,6 +1054,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendRedisServerMessage(String... messageData) {
|
||||
for (ClientHandler h : redisClientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendServerMessageServer(String server, String... messageData) {
|
||||
if (clientHandles.containsKey(server)) {
|
||||
clientHandles.get(server).sendMessage(messageData);
|
||||
@@ -763,20 +1120,47 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void vote(String player, String service, boolean realVote) {
|
||||
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
|
||||
BungeeMessageData text, String uuid) {
|
||||
try {
|
||||
if (player == null || player.isEmpty()) {
|
||||
getLogger().info("No name from vote on " + service);
|
||||
return;
|
||||
}
|
||||
|
||||
String uuid = getUUID(player);
|
||||
if (timeQueue) {
|
||||
if (getConfig().getGlobalDataEnabled()) {
|
||||
if (getGlobalDataHandler().isTimeChangedHappened()) {
|
||||
timeChangeQueue.add(new VoteTimeQueue(player, service,
|
||||
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
|
||||
getLogger().info("Cachcing vote from " + player + "/" + service
|
||||
+ " because time change is happening right now");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid == null || uuid.isEmpty()) {
|
||||
uuid = getUUID(player);
|
||||
}
|
||||
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getGeyserSupport()) {
|
||||
if (!player.startsWith(config.getGeyserPrefix())) {
|
||||
uuid = getUUID(config.getGeyserPrefix() + player);
|
||||
player = config.getGeyserPrefix() + player;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getAllowUnJoined()) {
|
||||
debug("Fetching UUID online, since allowunjoined is enabled");
|
||||
UUID u = null;
|
||||
try {
|
||||
u = fetchUUID(player);
|
||||
if (config.getOnlineMode()) {
|
||||
u = fetchUUID(player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
@@ -795,45 +1179,48 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
player = getProperName(uuid, player);
|
||||
|
||||
BungeeMessageData text = null;
|
||||
if (!getConfig().getPrimaryServer()) {
|
||||
addVoteParty();
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
addVoteParty();
|
||||
if (mysql == null) {
|
||||
getLogger().severe("Mysql is not loaded correctly, stopping vote processing");
|
||||
return;
|
||||
}
|
||||
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
// one time query to insert player
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", new DataValueString(player));
|
||||
}
|
||||
|
||||
if (mysql == null) {
|
||||
getLogger().severe("Mysql is not loaded correctly, stopping vote processing");
|
||||
return;
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", new DataValueString(uuid)));
|
||||
|
||||
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
|
||||
int monthTotal = getValue(data, "MonthTotal", 1);
|
||||
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
|
||||
int dailyTotal = getValue(data, "DailyTotal", 1);
|
||||
int points = getValue(data, "Points", getConfig().getPointsOnVote());
|
||||
int milestoneCount = getValue(data, "MilestoneCount", 1);
|
||||
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
|
||||
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
|
||||
ArrayList<Column> update = new ArrayList<Column>();
|
||||
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
|
||||
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
|
||||
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
|
||||
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
|
||||
update.add(new Column("Points", new DataValueInt(points)));
|
||||
update.add(new Column("MilestoneCount", new DataValueInt(milestoneCount)));
|
||||
debug("Setting totals " + text.toString());
|
||||
mysql.update(uuid, update);
|
||||
} else {
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
|
||||
}
|
||||
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", new DataValueString(player));
|
||||
}
|
||||
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", new DataValueString(uuid)));
|
||||
|
||||
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
|
||||
int monthTotal = getValue(data, "MonthTotal", 1);
|
||||
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
|
||||
int dailyTotal = getValue(data, "DailyTotal", 1);
|
||||
int points = getValue(data, "Points", getConfig().getPointsOnVote());
|
||||
int milestoneCount = getValue(data, "MilestoneCount", 1);
|
||||
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points, milestoneCount,
|
||||
votePartyVotes, currentVotePartyVotesRequired);
|
||||
ArrayList<Column> update = new ArrayList<Column>();
|
||||
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
|
||||
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
|
||||
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
|
||||
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
|
||||
update.add(new Column("Points", new DataValueInt(points)));
|
||||
update.add(new Column("MilestoneCount", new DataValueInt(milestoneCount)));
|
||||
debug("Setting totals " + text.toString());
|
||||
mysql.update(uuid, update);
|
||||
} else {
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
|
||||
}
|
||||
|
||||
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
if (queueTime != 0) {
|
||||
time = queueTime;
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
@@ -847,6 +1234,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
forceCache = true;
|
||||
debug("Forcing vote to cache");
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
if (info.getPlayers().isEmpty() || forceCache) {
|
||||
// cache
|
||||
if (!cachedVotes.containsKey(s)) {
|
||||
@@ -863,11 +1253,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "1");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -876,7 +1264,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + config.getBroadcast());
|
||||
"" + config.getBroadcast(), "1");
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
@@ -890,16 +1278,21 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired);
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired);
|
||||
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
}
|
||||
if (getConfig().getRedisSupport() && getConfig().getPrimaryServer()) {
|
||||
sendRedisServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@@ -18,20 +20,26 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
bungee.reload(false);
|
||||
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee"));
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
bungee.reload(true);
|
||||
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee with MySQL"));
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee with MySQL"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
bungee.vote(user, site, false);
|
||||
bungee.vote(user, site, false, true, 0, null, null);
|
||||
sender.sendMessage(new TextComponent("Sending vote"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("forcetimechange")) {
|
||||
if (args.length >= 2) {
|
||||
bungee.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
|
||||
sender.sendMessage(new TextComponent("Triggering time change: " + args[1]));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
|
||||
@@ -29,6 +29,18 @@ public class Config extends VelocityYMLFile {
|
||||
return getBoolean(getNode("Broadcast"), false);
|
||||
}
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
return getBoolean(getNode("OnlineMode"), true);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getBoolean(getNode("GlobalData", "Enabled"), false);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getBoolean(getNode("GlobalData", "UseMainMySQL"), true);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Collection;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
@@ -49,6 +50,13 @@ public class VoteCache extends VelocityYMLFile {
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
}
|
||||
|
||||
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
|
||||
String[] path = new String[] { "TimedVoteCache", "" + num };
|
||||
getNode(path, "Name").setValue(voteTimedQueue.getName());
|
||||
getNode(path, "Service").setValue(voteTimedQueue.getService());
|
||||
getNode(path, "Time").setValue(voteTimedQueue.getTime());
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
String[] path = new String[] { "OnlineCache", player, "" + num };
|
||||
|
||||
@@ -70,6 +78,10 @@ public class VoteCache extends VelocityYMLFile {
|
||||
return getKeys(getNode("OnlineCache", name));
|
||||
}
|
||||
|
||||
public ConfigurationNode getTimedVoteCache(String name) {
|
||||
return getNode("TimedVoteCache", name);
|
||||
}
|
||||
|
||||
public ConfigurationNode getOnlineVotes(String name, String num) {
|
||||
return getNode("OnlineCache", name, num);
|
||||
}
|
||||
@@ -82,6 +94,10 @@ public class VoteCache extends VelocityYMLFile {
|
||||
return getKeys(getNode("VoteCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getTimedVoteCache() {
|
||||
return getKeys(getNode("TimedVoteCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getKeys(getNode("OnlineCache", server));
|
||||
}
|
||||
|
||||
+392
-66
@@ -14,21 +14,25 @@ import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.security.CodeSource;
|
||||
import java.sql.SQLException;
|
||||
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.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.Queue;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -39,19 +43,26 @@ import org.slf4j.Logger;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.misc.jsonparser.JsonParser;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigVelocity;
|
||||
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.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.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.bungee.TimeHandle;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.inject.Inject;
|
||||
@@ -108,10 +119,17 @@ public class VotingPluginVelocity {
|
||||
|
||||
private VoteCache voteCacheFile;
|
||||
|
||||
private Timer timer;
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
private ConcurrentHashMap<UUID, String> uuidPlayerNameCache = new ConcurrentHashMap<UUID, String>();
|
||||
|
||||
@Getter
|
||||
private TimeHandle timeHandle;
|
||||
private BungeeTimeChecker bungeeTimeChecker;
|
||||
|
||||
private boolean enabled;
|
||||
|
||||
@Getter
|
||||
private GlobalDataHandlerProxy globalDataHandler;
|
||||
|
||||
@Inject
|
||||
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
|
||||
@@ -120,7 +138,7 @@ public class VotingPluginVelocity {
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
this.metricsFactory = metricsFactory;
|
||||
timer = new Timer();
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
public synchronized void checkCachedVotes(RegisteredServer serverToCheck) {
|
||||
@@ -130,6 +148,7 @@ public class VotingPluginVelocity {
|
||||
ArrayList<OfflineBungeeVote> c = cachedVotes.get(serverToCheck);
|
||||
ArrayList<OfflineBungeeVote> newSet = new ArrayList<OfflineBungeeVote>();
|
||||
if (!c.isEmpty()) {
|
||||
int num = 1;
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
boolean toSend = true;
|
||||
if (getConfig().getWaitForUserOnline()) {
|
||||
@@ -139,8 +158,9 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
if (p == null || !p.isActive()) {
|
||||
toSend = false;
|
||||
} else if (p != null && p.isActive() && !p.getCurrentServer().get().getServerInfo()
|
||||
.getName().equals(serverToCheck.getServerInfo().getName())) {
|
||||
} else if (p != null && p.isActive()
|
||||
&& (!p.getCurrentServer().isPresent() || !p.getCurrentServer().get().getServerInfo()
|
||||
.getName().equals(serverToCheck.getServerInfo().getName()))) {
|
||||
toSend = false;
|
||||
}
|
||||
|
||||
@@ -149,7 +169,8 @@ public class VotingPluginVelocity {
|
||||
sendPluginMessageServer(serverToCheck, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num);
|
||||
num++;
|
||||
} else {
|
||||
debug("Not sending vote because user isn't on server " + serverToCheck + ": "
|
||||
+ cache.toString());
|
||||
@@ -171,11 +192,13 @@ public class VotingPluginVelocity {
|
||||
serverToCheck = player.getCurrentServer().get().getServer();
|
||||
}
|
||||
if (!config.getBlockedServers().contains(serverToCheck.getServerInfo().getName())) {
|
||||
int num = 1;
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendPluginMessageServer(serverToCheck, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "" + num);
|
||||
num++;
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
@@ -189,6 +212,10 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
|
||||
public void debug2(String msg) {
|
||||
debug(msg);
|
||||
}
|
||||
|
||||
public UUID fetchUUID(String playerName) throws Exception {
|
||||
// Get response from Mojang API
|
||||
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName);
|
||||
@@ -223,22 +250,31 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
if (server.getPlayer(playerName).isPresent()) {
|
||||
Player p = server.getPlayer(playerName).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUniqueId().toString();
|
||||
if (config.getOnlineMode()) {
|
||||
if (server.getPlayer(playerName).isPresent()) {
|
||||
Player p = server.getPlayer(playerName).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mysql != null) {
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
for (Entry<UUID, String> entry : uuidPlayerNameCache.entrySet()) {
|
||||
if (entry.getValue().equalsIgnoreCase(playerName)) {
|
||||
return entry.getKey().toString();
|
||||
}
|
||||
}
|
||||
if (mysql != null) {
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
return "";
|
||||
} else {
|
||||
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + playerName).getBytes(StandardCharsets.UTF_8)).toString();
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private int getValue(ArrayList<Column> cols, String column, int toAdd) {
|
||||
@@ -276,6 +312,123 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
ArrayList<String> servers = new ArrayList<String>();
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
servers.add(s.getServerInfo().getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (config.getGlobalDataEnabled()) {
|
||||
if (config.getGlobalDataUseMainMySQL()) {
|
||||
globalDataHandler = new GlobalDataHandlerProxy(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
logger.warn(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
logger.error(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
}, servers) {
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage(s.getServerInfo().getName(), "BungeeTimeChange");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processQueue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getGlobalDataHandler().setBoolean(server, type.toString(), false);
|
||||
}
|
||||
};
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandlerProxy(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigVelocity("GlobalData", config)) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
logger.warn(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
logger.error(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
}, servers) {
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
getGlobalDataHandler().setBoolean(s.getServerInfo().getName(), "ForceUpdate", true);
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage(s.getServerInfo().getName(), "BungeeTimeChange");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processQueue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFailed(String server, TimeType type) {
|
||||
getGlobalDataHandler().setBoolean(server, type.toString(), false);
|
||||
}
|
||||
};
|
||||
}
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
getGlobalDataHandler().getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
}
|
||||
// column types
|
||||
getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
@@ -322,31 +475,23 @@ public class VotingPluginVelocity {
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
String player = in.readUTF();
|
||||
debug("Login: " + player);
|
||||
if (server.getPlayer(player).isPresent()) {
|
||||
if (server.getPlayer(player).isPresent() && !getGlobalDataHandler().isTimeChangedHappened()) {
|
||||
Player p = server.getPlayer(player).get();
|
||||
if (p.getCurrentServer().isPresent()) {
|
||||
final RegisteredServer server = p.getCurrentServer().get().getServer();
|
||||
final Player p1 = p;
|
||||
timer.schedule(new TimerTask() {
|
||||
timer.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(p1, p.getUniqueId().toString(), server);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("timeupdate")) {
|
||||
String str = in.readUTF();
|
||||
String[] data = str.split(Pattern.quote("//"));
|
||||
if (data.length == 3) {
|
||||
timeHandle.setMonth(data[0]);
|
||||
timeHandle.setDay(Integer.parseInt(data[1]));
|
||||
timeHandle.setWeek(Integer.parseInt(data[2]));
|
||||
}
|
||||
} else {
|
||||
|
||||
// reforward message
|
||||
@@ -389,17 +534,25 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
}
|
||||
timeHandle.save();
|
||||
if (!timeChangeQueue.isEmpty()) {
|
||||
int num = 0;
|
||||
for (VoteTimeQueue vote : timeChangeQueue) {
|
||||
voteCacheFile.addTimedVote(num, vote);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
voteCacheFile.save();
|
||||
nonVotedPlayersCache.save();
|
||||
if (mysql != null) {
|
||||
mysql.shutDown();
|
||||
}
|
||||
enabled = false;
|
||||
logger.info("VotingPlugin disabled");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
enabled = true;
|
||||
File configFile = new File(dataDirectory.toFile(), "bungeeconfig.yml");
|
||||
configFile.getParentFile().mkdirs();
|
||||
if (!configFile.exists()) {
|
||||
@@ -422,6 +575,7 @@ public class VotingPluginVelocity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
config = new Config(configFile);
|
||||
server.getChannelRegistrar().register(CHANNEL);
|
||||
method = BungeeMethod.getByName(config.getBungeeMethod());
|
||||
@@ -438,6 +592,127 @@ public class VotingPluginVelocity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getNode("TimeHourOffSet").getInt()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
logger.warn(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timeChanged(TimeType type, boolean fake, boolean pre, boolean post) {
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
return;
|
||||
}
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
|
||||
if (getGlobalDataHandler().getGlobalMysql().containsKey(s.getServerInfo().getName())) {
|
||||
String lastOnlineStr = getGlobalDataHandler().getString(s.getServerInfo().getName(),
|
||||
"LastOnline");
|
||||
long lastOnline = 0;
|
||||
try {
|
||||
lastOnline = Long.valueOf(lastOnlineStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli()
|
||||
- lastOnline < 1000 * 60 * 60 * 12) {
|
||||
// server has been online within the 12 hours
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
|
||||
dataToSet.put("LastUpdated", new DataValueString(
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli()));
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(false));
|
||||
dataToSet.put(type.toString(), new DataValueBoolean(true));
|
||||
getGlobalDataHandler().setData(s.getServerInfo().getName(), dataToSet);
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(s, "BungeeTimeChange", "");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessageServer(s.getServerInfo().getName(), "BungeeTimeChange");
|
||||
}
|
||||
} else {
|
||||
logger.warn("Server " + s + " hasn't been online recently");
|
||||
}
|
||||
} else {
|
||||
logger.warn("Server " + s + " global data handler disabled?");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrevWeek(int week) {
|
||||
voteCacheFile.getNode("Time", "Week").setValue(week);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrevMonth(String text) {
|
||||
voteCacheFile.getNode("Time", "Month").setValue(text);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrevDay(int day) {
|
||||
voteCacheFile.getNode("Time", "Day").setValue(day);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastUpdated() {
|
||||
voteCacheFile.getNode("Time", "LastUpdated").setValue(System.currentTimeMillis());
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreTime(boolean ignore) {
|
||||
voteCacheFile.getNode("Time", "IgnoreTime").setValue(ignore);
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIgnoreTime() {
|
||||
return voteCacheFile.getNode("Time", "IgnoreTime").getBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevWeek() {
|
||||
return voteCacheFile.getNode("Time", "Week").getInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrevMonth() {
|
||||
return voteCacheFile.getNode("Time", "Month").getString("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPrevDay() {
|
||||
return voteCacheFile.getNode("Time", "Day").getInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLastUpdated() {
|
||||
return voteCacheFile.getNode("Time", "LastUpdated").getLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
debug2(text);
|
||||
}
|
||||
};
|
||||
|
||||
CommandMeta meta = server.getCommandManager().metaBuilder("votingpluginbungee")
|
||||
// Specify other aliases (optional)
|
||||
.aliases("vpb").build();
|
||||
@@ -445,20 +720,26 @@ public class VotingPluginVelocity {
|
||||
server.getCommandManager().register(meta, new VotingPluginVelocityCommand(this));
|
||||
|
||||
if (mysqlLoaded) {
|
||||
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
|
||||
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
|
||||
|
||||
bungeeTimeChecker.loadTimer();
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(
|
||||
new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
|
||||
|
||||
timeHandle = new TimeHandle(voteCacheFile.getNode("Time", "Month").getString(""),
|
||||
voteCacheFile.getNode("Time", "Day").getInt(), voteCacheFile.getNode("Time", "Week").getInt()) {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
voteCacheFile.getNode("Time", "Month").setValue(timeHandle.getMonth());
|
||||
voteCacheFile.getNode("Time", "Day").setValue(timeHandle.getDay());
|
||||
voteCacheFile.getNode("Time", "Week").setValue(timeHandle.getWeek());
|
||||
try {
|
||||
for (String key : voteCacheFile.getTimedVoteCache()) {
|
||||
ConfigurationNode data = voteCacheFile.getTimedVoteCache(key);
|
||||
timeChangeQueue.add(new VoteTimeQueue(data.getNode("Name").getString(),
|
||||
data.getNode("Service").getString(), data.getNode("Time").getLong()));
|
||||
}
|
||||
};
|
||||
|
||||
processQueue();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
try {
|
||||
@@ -497,13 +778,15 @@ public class VotingPluginVelocity {
|
||||
voteCacheFile.clearData();
|
||||
|
||||
server.getScheduler().buildTask(this, () -> {
|
||||
for (RegisteredServer server : cachedVotes.keySet()) {
|
||||
checkCachedVotes(server);
|
||||
}
|
||||
if (!getGlobalDataHandler().isTimeChangedHappened()) {
|
||||
for (RegisteredServer server : cachedVotes.keySet()) {
|
||||
checkCachedVotes(server);
|
||||
}
|
||||
|
||||
for (String player : cachedOnlineVotes.keySet()) {
|
||||
if (server.getPlayer(UUID.fromString(player)).isPresent()) {
|
||||
checkOnlineVotes(server.getPlayer(UUID.fromString(player)).get(), player, null);
|
||||
for (String player : cachedOnlineVotes.keySet()) {
|
||||
if (server.getPlayer(UUID.fromString(player)).isPresent()) {
|
||||
checkOnlineVotes(server.getPlayer(UUID.fromString(player)).get(), player, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}).delay(15L, TimeUnit.SECONDS).repeat(30l, TimeUnit.SECONDS).schedule();
|
||||
@@ -519,7 +802,13 @@ public class VotingPluginVelocity {
|
||||
|
||||
socketHandler = new SocketHandler(
|
||||
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
|
||||
config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug());
|
||||
config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@@ -560,11 +849,11 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
}
|
||||
|
||||
try {
|
||||
getVersionFile();
|
||||
@@ -592,6 +881,12 @@ public class VotingPluginVelocity {
|
||||
|
||||
metrics.addCustomChart(new SimplePie("plugin_version", () -> "" + version));
|
||||
|
||||
metrics.addCustomChart(new SimplePie("globaldata_enabled", () -> "" + getConfig().getGlobalDataEnabled()));
|
||||
if (getConfig().getGlobalDataEnabled()) {
|
||||
metrics.addCustomChart(
|
||||
new SimplePie("globaldata_usemainmysql", () -> "" + getConfig().getGlobalDataUseMainMySQL()));
|
||||
}
|
||||
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
metrics.addCustomChart(new SimplePie("dev_build_number", () -> "" + buildNumber));
|
||||
}
|
||||
@@ -658,7 +953,7 @@ public class VotingPluginVelocity {
|
||||
public void onVotifierEvent(VotifierEvent event) {
|
||||
final String serviceSiteVote = event.getVote().getServiceName();
|
||||
final String name = event.getVote().getUsername();
|
||||
timer.schedule(new TimerTask() {
|
||||
timer.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -667,9 +962,10 @@ public class VotingPluginVelocity {
|
||||
if (serviceSite.isEmpty()) {
|
||||
serviceSite = "Empty";
|
||||
}
|
||||
vote(name, serviceSite, true);
|
||||
|
||||
vote(name, serviceSite, true, false, 0);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@@ -796,20 +1092,44 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void vote(String player, String service, boolean realVote) {
|
||||
@Getter
|
||||
private Queue<VoteTimeQueue> timeChangeQueue = new ConcurrentLinkedQueue<VoteTimeQueue>();
|
||||
|
||||
public void processQueue() {
|
||||
while (getTimeChangeQueue().size() > 0) {
|
||||
VoteTimeQueue vote = getTimeChangeQueue().remove();
|
||||
vote(vote.getName(), vote.getService(), true, false, vote.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void vote(String player, String service, boolean realVote, boolean timeQueue, long queuedTime) {
|
||||
try {
|
||||
if (player == null || player.isEmpty()) {
|
||||
logger.info("No name from vote on " + service);
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeQueue) {
|
||||
if (getConfig().getGlobalDataEnabled()) {
|
||||
if (getGlobalDataHandler().isTimeChangedHappened()) {
|
||||
timeChangeQueue.add(new VoteTimeQueue(player, service,
|
||||
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
|
||||
getLogger().info("Cachcing vote from " + player + "/" + service
|
||||
+ " because time change is happening right now");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String uuid = getUUID(player);
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getAllowUnJoined()) {
|
||||
debug("Fetching UUID online, since allowunjoined is enabled");
|
||||
UUID u = null;
|
||||
try {
|
||||
u = fetchUUID(player);
|
||||
if (config.getOnlineMode()) {
|
||||
u = fetchUUID(player);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
@@ -875,6 +1195,9 @@ public class VotingPluginVelocity {
|
||||
*/
|
||||
|
||||
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
if (queuedTime != 0) {
|
||||
time = queuedTime;
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
@@ -886,7 +1209,8 @@ public class VotingPluginVelocity {
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
}
|
||||
if ((p == null || !p.isActive()) && getConfig().getWaitForUserOnline()) {
|
||||
if (((p == null || !p.isActive()) && getConfig().getWaitForUserOnline())
|
||||
|| getGlobalDataHandler().isTimeChangedHappened()) {
|
||||
forceCache = true;
|
||||
debug("Forcing vote to cache");
|
||||
}
|
||||
@@ -906,7 +1230,7 @@ public class VotingPluginVelocity {
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast(), "1");
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
@@ -918,12 +1242,14 @@ public class VotingPluginVelocity {
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
}
|
||||
if (p != null && p.isActive() && !config.getBlockedServers()
|
||||
.contains(p.getCurrentServer().get().getServerInfo().getName())) {
|
||||
if (p != null && p.isActive()
|
||||
&& !config.getBlockedServers()
|
||||
.contains(p.getCurrentServer().get().getServerInfo().getName())
|
||||
&& !getGlobalDataHandler().isTimeChangedHappened()) {
|
||||
sendPluginMessageServer(p.getCurrentServer().get().getServer(), "VoteOnline", player, uuid,
|
||||
service, "" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + config.getBroadcast());
|
||||
"" + config.getBroadcast(), "1");
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
|
||||
+8
-1
@@ -1,5 +1,6 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
@@ -33,10 +34,16 @@ public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
plugin.vote(user, site, false);
|
||||
plugin.vote(user, site, false, true, 0);
|
||||
source.sendMessage(Component.text("Sending vote").color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("forcetimechange")) {
|
||||
if (args.length >= 2) {
|
||||
plugin.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
|
||||
source.sendMessage(Component.text("Triggering time change: " + args[1]).color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (plugin.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
source.sendMessage(
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
@@ -372,13 +371,14 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.clearCache();
|
||||
synchronized (pointLock) {
|
||||
user.addPoints(Integer.parseInt(args[3]));
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.cache();
|
||||
int newTotal = 0;
|
||||
newTotal = user.addPoints(Integer.parseInt(args[3]));
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3]
|
||||
+ " points" + ", " + args[1] + " now has " + newTotal + " points"));
|
||||
}
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3]
|
||||
+ " points" + ", " + args[1] + " now has " + user.getPoints() + " points"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -389,7 +389,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
user.removePoints(Integer.parseInt(args[3]));
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cRemoved " + args[3] + " points from "
|
||||
+ args[1] + ", " + args[1] + " now has " + user.getPoints() + " points"));
|
||||
@@ -439,7 +439,6 @@ public class CommandLoader {
|
||||
int page = Integer.parseInt(args[1]);
|
||||
new AdminVoteHelp(plugin, sender, page).open();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -910,6 +909,32 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "VoteExact", "(PlayerExact)", "(Sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteExact|" + adminPerm,
|
||||
"Trigger manual vote with exact player name") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1],
|
||||
args[2], false);
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
sendMessage(sender,
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
}
|
||||
}
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (plugin.isYmlError()) {
|
||||
sendMessage(sender, "&3Detected yml error, please check server log for details");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", },
|
||||
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote via GUI", false) {
|
||||
|
||||
@@ -974,6 +999,21 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(Player)", "ForceCoolDownEndRewards", "(Sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.ForceCoolDownEndRewards|" + adminPerm,
|
||||
"Trigger CoolDownEndRewards manually") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getVoteSite(args[3], true).getSiteData(),
|
||||
"CoolDownEndRewards", new RewardOptions());
|
||||
sendMessage(sender, "&cCoolDownEndRewards forced on votesite " + args[3]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteSite", "(sitename)", "Create" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit|" + adminPerm, "Create VoteSite") {
|
||||
|
||||
@@ -1255,8 +1295,8 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(Integer.parseInt(args[1]));
|
||||
sendMessage(sender, "&cSet VotePartyExtraRequired to " + args[1]);
|
||||
plugin.getServerData().setVotePartyExtraRequired(Integer.parseInt(args[2]));
|
||||
sendMessage(sender, "&cSet VotePartyExtraRequired to " + args[2]);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1267,7 +1307,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getConfigFile().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getConfigFile().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(args[3]), new RewardOptions());
|
||||
sendMessage(sender, "&cVoteShop " + args[3] + " forced");
|
||||
}
|
||||
@@ -1373,6 +1413,18 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceAlmostAllSites" },
|
||||
"VotingPlugin.Commands.AdminVote.ForceAllSites|" + adminPerm, "Force a almostallsites reward") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
plugin.getSpecialRewards().giveAlmostAllSitesRewards(user, user.isOnline(),
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
sendMessage(sender, "&cAlmostAllSites forced");
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceFirstVote" },
|
||||
"VotingPlugin.Commands.AdminVote.ForceFirstVote|" + adminPerm, "Force a firstvote reward") {
|
||||
|
||||
@@ -1828,7 +1880,7 @@ public class CommandLoader {
|
||||
|
||||
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
|
||||
if (hasPerm) {
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
|
||||
@@ -1839,7 +1891,7 @@ public class CommandLoader {
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
@@ -2011,7 +2063,7 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
if (plugin.getGui().isLastMonthGUI() || plugin.getOptions().getDebug().equals(DebugLevel.DEV)) {
|
||||
plugin.getVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "LastMonthTop" },
|
||||
"VotingPlugin.Commands.Vote.LastMonthTop|" + playerPerm,
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueSt
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
|
||||
@@ -66,6 +65,7 @@ public class AdminGUI {
|
||||
plugin.getConfigVoteSites().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
openAdminGUIVoteSiteSite(player, plugin.getVoteSite(value, true));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -110,7 +110,7 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("FirstVote"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("FirstVote"));
|
||||
}
|
||||
});
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit FirstVoteToday reward")) {
|
||||
@@ -118,7 +118,7 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("FirstVoteToday"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("FirstVoteToday"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -127,7 +127,16 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("AllSites"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("AllSites"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AlmostAllSites reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("AlmostAllSites"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,7 +145,7 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("AnySiteRewards"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("AnySiteRewards"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -145,7 +154,7 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("EverySiteReward"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("EverySiteReward"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -154,7 +163,7 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("BungeeVotePartyRewards"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("BungeeVotePartyRewards"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -364,12 +373,35 @@ public class AdminGUI {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), RewardHandler.getInstance()
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler()
|
||||
.getDirectlyDefined("VoteSites." + voteSite.getKey() + ".Rewards"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (voteSite.getSiteData().isList("CoolDownEndRewards")) {
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueList("CoolDownEndRewards",
|
||||
voteSite.getSiteData().getStringList("CoolDownEndRewards")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player p, ArrayList<String> rewards) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().set(voteSite.getKey(), "CoolDownEndRewards", rewards);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cCoolDownEndRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler()
|
||||
.getDirectlyDefined("VoteSites." + voteSite.getKey() + ".CoolDownEndRewards"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -17,7 +17,6 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueLi
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
@@ -212,7 +211,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("VoteParty.Rewards"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("VoteParty.Rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
|
||||
@@ -68,7 +67,7 @@ public class AdminVoteCumulative extends GUIHandler {
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance()
|
||||
plugin.getRewardHandler()
|
||||
.getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
|
||||
|
||||
+1
-2
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
|
||||
@@ -68,7 +67,7 @@ public class AdminVoteMilestones extends GUIHandler {
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance()
|
||||
plugin.getRewardHandler()
|
||||
.getDirectlyDefined("MileStones." + value.intValue() + ".Rewards"));
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
|
||||
|
||||
+2
-3
@@ -17,7 +17,6 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueLi
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
@@ -86,7 +85,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
|
||||
// display item
|
||||
ConfigurationSection displayItemData = plugin.getGui().getChestShopIdentifierSection(identifier);
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.valueOf(displayItemData.getString("Material")), 1),
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(displayItemData.getString("Material")).setAmount(1),
|
||||
new EditGUIValueString("Material", displayItemData.getString("Material")) {
|
||||
|
||||
@Override
|
||||
@@ -115,7 +114,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
@@ -184,9 +183,9 @@ public class VoteGUI extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getGui().getData(),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
|
||||
RewardHandler.getInstance().giveReward(UserManager.getInstance().getVotingPluginUser(player),
|
||||
plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@@ -63,6 +64,28 @@ public class VoteHelp extends GUIHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"),
|
||||
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
msg.add(unsorted.get(cmd));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
|
||||
@@ -86,7 +109,12 @@ public class VoteHelp extends GUIHandler {
|
||||
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> text = helpText(sender);
|
||||
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
|
||||
if (NMSManager.getInstance().isVersion("1.12")) {
|
||||
text = helpTextLegacy(sender);
|
||||
} else {
|
||||
text = helpText(sender);
|
||||
}
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
if ((text.size() % pagesize) != 0) {
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteLast extends GUIHandler {
|
||||
@@ -67,8 +68,24 @@ public class VoteLast extends GUIHandler {
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
public void onClick(ClickEvent event) {
|
||||
if (plugin.getGui().isChestVoteLastClickableLinks()) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(
|
||||
StringParser.getInstance()
|
||||
.replacePlaceHolder(
|
||||
StringParser.getInstance().replacePlaceHolder(
|
||||
StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getGui()
|
||||
.getChestVoteURLURLText(),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"sitename", site.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -65,7 +64,11 @@ public class VoteShop extends GUIHandler {
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
if (perm.startsWith("!")) {
|
||||
hasPerm = !player.hasPermission(perm.substring(1));
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
}
|
||||
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
@@ -95,7 +98,7 @@ public class VoteShop extends GUIHandler {
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
event.closeInventory();
|
||||
}
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
@@ -117,7 +120,7 @@ public class VoteShop extends GUIHandler {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/"
|
||||
+ user.getUUID() + " bought " + identifier + " for " + points);
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -65,7 +64,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought "
|
||||
+ identifier + " for " + points);
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
|
||||
@@ -81,6 +81,14 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private boolean disableBroadcast = false;
|
||||
|
||||
@ConfigDataBoolean(path = "GlobalData.UseMainMySQL")
|
||||
@Getter
|
||||
private boolean globlalDataUseMainMySQL = true;
|
||||
|
||||
@ConfigDataBoolean(path = "GlobalData.Enabled")
|
||||
@Getter
|
||||
private boolean globlalDataEnabled = false;
|
||||
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@ConfigDataBoolean(path = "PerSiteCoolDownEvents")
|
||||
@Getter
|
||||
private boolean perSiteCoolDownEvents = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
@@ -73,6 +77,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean alwaysWaitForCachePlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysProcessPlaceholders")
|
||||
@Getter
|
||||
private boolean alwaysProcessPlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
@@ -89,10 +97,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private int delayBetweenUpdates = 3;
|
||||
|
||||
@ConfigDataInt(path = "DelayLoginEvent")
|
||||
@Getter
|
||||
private int delayLoginEvent = 0;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableAdvancedTab")
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
@@ -149,6 +153,14 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean formatAlternateBroadcastEnabled = false;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.OnlyOneOfflineBroadcast")
|
||||
@Getter
|
||||
private boolean formatOnlyOneOfflineBroadcast = false;
|
||||
|
||||
@ConfigDataString(path = "Format.OfflineBroadcast")
|
||||
@Getter
|
||||
private String formatOfflineBroadcast = "&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %numberofvotes% times!";
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteForceLinks = true;
|
||||
|
||||
@@ -130,12 +130,12 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @param siteName the site name
|
||||
* @return the vote delay
|
||||
*/
|
||||
public int getVoteDelay(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelay", 24);
|
||||
public double getVoteDelay(String siteName) {
|
||||
return getData(siteName).getDouble("VoteDelay", 24);
|
||||
}
|
||||
|
||||
public int getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayMin", 0);
|
||||
public double getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getDouble("VoteDelayMin", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +199,9 @@ public class ConfigVoteSites extends YMLFile {
|
||||
if (!siteCheck(site)) {
|
||||
plugin.getLogger().warning("Failed to load site " + site + ", see above");
|
||||
} else {
|
||||
voteSites.add(new VoteSite(plugin, site));
|
||||
VoteSite voteSite = new VoteSite(plugin, site);
|
||||
plugin.debug(voteSite.loadingDebug());
|
||||
voteSites.add(voteSite);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,7 +395,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @param siteName the site name
|
||||
* @param voteDelay the vote delay
|
||||
*/
|
||||
public void setVoteDelay(String siteName, int voteDelay) {
|
||||
public void setVoteDelay(String siteName, double voteDelay) {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
|
||||
@@ -146,6 +146,10 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private boolean lastMonthGUI = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteLast.ClickableLinks")
|
||||
@Getter
|
||||
private boolean chestVoteLastClickableLinks = true;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.config;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
@@ -18,6 +19,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
|
||||
@Getter
|
||||
private String allSitesRewardPath = "AllSites";
|
||||
|
||||
@Getter
|
||||
private String almostAllSitesRewardPath = "AlmostAllSites";
|
||||
|
||||
@Getter
|
||||
private String anySiteRewardsPath = "AnySiteRewards";
|
||||
@@ -91,6 +95,14 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return "Cumulative." + cumulative + ".Rewards";
|
||||
}
|
||||
|
||||
public List<Integer> getCumulativeBlackList(int cumulative) {
|
||||
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
|
||||
}
|
||||
|
||||
public boolean getCumulativeRecurring(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative votes.
|
||||
*
|
||||
@@ -262,6 +274,10 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.OnlyOncePerDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyOnlyOncePerWeek() {
|
||||
return getData().getBoolean("VoteParty.OnlyOncePerWeek");
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
@@ -353,8 +369,8 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
}
|
||||
|
||||
public void setMilestone(int intValue) {
|
||||
getData().set("Milestones." + intValue + ".Enabled", true);
|
||||
getData().set("Milestones." + intValue + ".Rewards.Messages.Player", "&aYou got %milestone% milestone votes!");
|
||||
getData().set("MileStones." + intValue + ".Enabled", true);
|
||||
getData().set("MileStones." + intValue + ".Rewards.Messages.Player", "&aYou got %milestone% milestone votes!");
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,44 @@
|
||||
package com.bencodez.votingplugin.cooldown;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private Set<UUID> uuids = new HashSet<UUID>();
|
||||
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = new Timer();
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
private Timer timer;
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
private boolean cooldownCheckEnabled = false;
|
||||
|
||||
public void checkEnabled() {
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && RewardHandler.getInstance()
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
|
||||
cooldownCheckEnabled = true;
|
||||
} else {
|
||||
@@ -46,12 +50,18 @@ public class CoolDownCheck implements Listener {
|
||||
check(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user) {
|
||||
public void checkPerSite(UUID uuid) {
|
||||
checkPerSite(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
UUID uuid = UUID.fromString(user.getUUID());
|
||||
if (!uuids.contains(uuid)) {
|
||||
schedule(user);
|
||||
}
|
||||
schedule(user);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,10 +71,53 @@ public class CoolDownCheck implements Listener {
|
||||
user.setCoolDownCheck(false);
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
uuids.remove(UUID.fromString(user.getUUID()));
|
||||
allSiteTasks.remove(user.getJavaUUID());
|
||||
} else if (!coolDownCheck) {
|
||||
schedule(user);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void checkPerSite(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
boolean changed = false;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (user.canVoteSite(site)) {
|
||||
if (!coolDownChecks.containsKey(site) || !coolDownChecks.get(site).booleanValue()) {
|
||||
coolDownChecks.put(site, Boolean.TRUE);
|
||||
changed = true;
|
||||
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
user.setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
}
|
||||
|
||||
schedulePerSite(user);
|
||||
|
||||
}
|
||||
|
||||
public void schedulePerSite(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeFirstSiteAvailable();
|
||||
if (time > 0) {
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time);
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkPerSite(uuid);
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
perSiteTasks.put(uuid, scheduledFuture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -73,44 +126,59 @@ public class CoolDownCheck implements Listener {
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
uuids.add(uuid);
|
||||
timer.schedule(new TimerTask() {
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
check(uuid);
|
||||
}
|
||||
}, time * 1000 + 1500);
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (cooldownCheckEnabled) {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
checkPerSite(user);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
RewardHandler.getInstance().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward", new RewardOptions());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
|
||||
new RewardOptions());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.bencodez.votingplugin.data;
|
||||
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -12,6 +14,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -157,7 +160,16 @@ public class ServerData {
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
if (num == plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameWeek() {
|
||||
int num = getData().getInt("LastVotePartyWeek", -1);
|
||||
if (num == plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear())
|
||||
&& num != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -264,6 +276,12 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void updateLastVotePartyWeek() {
|
||||
getData().set("LastVotePartyWeek",
|
||||
plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear()));
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
@@ -288,4 +306,28 @@ public class ServerData {
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
|
||||
public void addTimeVoted(int num, VoteTimeQueue vote) {
|
||||
getData().set("TimedVoteCache." + num + ".Name", vote.getName());
|
||||
getData().set("TimedVoteCache." + num + ".Service", vote.getService());
|
||||
getData().set("TimedVoteCache." + num + ".Time", vote.getTime());
|
||||
saveData();
|
||||
}
|
||||
|
||||
public Set<String> getTimedVoteCacheKeys() {
|
||||
if (getData().isConfigurationSection("TimedVoteCache")) {
|
||||
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
|
||||
} else {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getTimedVoteCacheSection(String num) {
|
||||
return getData().getConfigurationSection("TimedVoteCache." + num);
|
||||
}
|
||||
|
||||
public void clearTimedVoteCache() {
|
||||
getData().set("TimedVoteCache", null);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,10 @@ public class PlayerVoteEvent extends Event {
|
||||
@Setter
|
||||
private boolean broadcast = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int voteNumber = 1;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
this.player = voteUsername;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteSiteCoolDownEndEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite site;
|
||||
|
||||
public PlayerVoteSiteCoolDownEndEvent(VotingPluginUser user, VoteSite site) {
|
||||
super(true);
|
||||
player = user;
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.bencodez.votingplugin.events;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK;
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK, ALMOSTALLSITES;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.bencodez.votingplugin.signs.SignHandler;
|
||||
public class BlockBreak implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static VotingPluginMain plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new block break.
|
||||
@@ -26,7 +26,7 @@ public class BlockBreak implements Listener {
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public BlockBreak(VotingPluginMain plugin) {
|
||||
BlockBreak.plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.bencodez.votingplugin.user.UserManager;
|
||||
public class PlayerInteract implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static VotingPluginMain plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player interact.
|
||||
@@ -29,7 +29,7 @@ public class PlayerInteract implements Listener {
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public PlayerInteract(VotingPluginMain plugin) {
|
||||
PlayerInteract.plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
@@ -21,7 +19,7 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static VotingPluginMain plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
@@ -29,7 +27,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(VotingPluginMain plugin) {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private void login(Player player) {
|
||||
@@ -62,43 +60,29 @@ public class PlayerJoinEvent implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(AdvancedCoreLoginEvent event) {
|
||||
if (event.getPlayer() == null || (VotingPluginMain.plugin.getStorageType().equals(UserStorage.MYSQL)
|
||||
&& VotingPluginMain.plugin.getMysql() == null)) {
|
||||
if (event.getPlayer() == null || !plugin.isMySQLOkay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int delay = plugin.getConfigFile().getDelayLoginEvent();
|
||||
if (delay <= 0) {
|
||||
login(event.getPlayer());
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
login(event.getPlayer());
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
login(event.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin.getConfigFile().isDisableAdvancedTab()) {
|
||||
return;
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
plugin.getLoginTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
}
|
||||
});
|
||||
}
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,8 @@ package com.bencodez.votingplugin.listeners;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -145,13 +147,11 @@ public class PlayerVoteListener implements Listener {
|
||||
} else {
|
||||
user.setTime(voteSite);
|
||||
}
|
||||
plugin.getCoolDownCheck().vote(user);
|
||||
|
||||
// try logging to file
|
||||
if (plugin.getConfigFile().isLogVotesToFile()) {
|
||||
try {
|
||||
VotingPluginMain.plugin.logVote(
|
||||
LocalDateTime.now().atZone(ZoneId.systemDefault()).toLocalDateTime(), playerName,
|
||||
plugin.logVote(LocalDateTime.now().atZone(ZoneId.systemDefault()).toLocalDateTime(), playerName,
|
||||
voteSite.getKey());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -167,15 +167,16 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
|
||||
if (((user.isOnline() || voteSite.isGiveOffline())
|
||||
&& VotingPluginMain.plugin.getOptions().isProcessRewards()) || event.isBungee()) {
|
||||
if (((user.isOnline() || voteSite.isGiveOffline()) && plugin.getOptions().isProcessRewards())
|
||||
|| event.isBungee()) {
|
||||
boolean online = true;
|
||||
if (event.isBungee()) {
|
||||
online = event.isWasOnline();
|
||||
}
|
||||
user.playerVote(voteSite, online, false, event.isForceBungee());
|
||||
user.sendVoteEffects(online);
|
||||
if (event.getVoteNumber() == 1) {
|
||||
user.sendVoteEffects(online);
|
||||
}
|
||||
if (plugin.getConfigFile().isCloseInventoryOnVote()) {
|
||||
user.closeInv();
|
||||
}
|
||||
@@ -194,17 +195,19 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
|
||||
user.checkDayVoteStreak(event.isForceBungee());
|
||||
|
||||
// other rewards
|
||||
plugin.getSpecialRewards().checkAllSites(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkAlmostAllSites(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkCumualativeVotes(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkMilestone(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
plugin.getCoolDownCheck().vote(user, voteSite);
|
||||
|
||||
final String uuid = user.getUUID();
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
|
||||
final String uuid = user.getUUID();
|
||||
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -216,14 +219,24 @@ public class PlayerVoteListener implements Listener {
|
||||
}, 40);
|
||||
}
|
||||
}
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
|
||||
event.isForceBungee());
|
||||
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
|
||||
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
|
||||
event.isForceBungee());
|
||||
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
|
||||
|
||||
plugin.getTimer().schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
public class SignChange implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static VotingPluginMain plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new sign change.
|
||||
@@ -24,7 +24,7 @@ public class SignChange implements Listener {
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public SignChange(VotingPluginMain plugin) {
|
||||
SignChange.plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -65,7 +64,7 @@ public class VotiferEvent implements Listener {
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
plugin.debug("IP: " + IP);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getVoteTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -82,7 +81,7 @@ public class VotiferEvent implements Listener {
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
|
||||
boolean createSite = false;
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteNameStr)) {
|
||||
if (!ArrayUtils.getInstance().containsIgnoreCase(sites, voteSiteNameStr)) {
|
||||
createSite = true;
|
||||
}
|
||||
} else {
|
||||
@@ -91,13 +90,21 @@ public class VotiferEvent implements Listener {
|
||||
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
|
||||
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr
|
||||
+ "' does not exist, attempting to generaterate...");
|
||||
+ "' does not exist, attempting to generate...");
|
||||
plugin.getConfigVoteSites().generateVoteSite(voteSiteNameStr);
|
||||
|
||||
plugin.getLogger().info("Current known service sites: "
|
||||
+ ArrayUtils.getInstance().makeStringList(plugin.getServerData().getServiceSites()));
|
||||
}
|
||||
|
||||
if (plugin.getTimeChecker().isProcessing()) {
|
||||
// time change in progress
|
||||
plugin.debug("Adding vote to time queue " + voteUsername + "/" + voteSite);
|
||||
plugin.getTimeQueueHandler().addVote(voteUsername, voteSite);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
String voteSiteName = plugin.getVoteSiteName(true, voteSite);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName, true), voteUsername,
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
public class VotingPluginUpdateEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static VotingPluginMain plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new advanced core update event.
|
||||
@@ -22,7 +22,7 @@ public class VotingPluginUpdateEvent implements Listener {
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public VotingPluginUpdateEvent(VotingPluginMain plugin) {
|
||||
VotingPluginUpdateEvent.plugin = plugin;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -108,6 +107,11 @@ public class VoteSite {
|
||||
return;
|
||||
}
|
||||
if (!user.isVanished()) {
|
||||
String playerName = user.getPlayerName();
|
||||
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
|
||||
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
|
||||
return;
|
||||
}
|
||||
if (checkBungee && plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
@@ -123,11 +127,6 @@ public class VoteSite {
|
||||
}
|
||||
|
||||
} else {
|
||||
String playerName = user.getPlayerName();
|
||||
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
|
||||
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
|
||||
return;
|
||||
}
|
||||
String bc = StringParser.getInstance().colorize(plugin.getConfigFile().getFormatBroadCastMsg());
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("player", playerName);
|
||||
@@ -209,7 +208,7 @@ public class VoteSite {
|
||||
}
|
||||
|
||||
public boolean hasRewards() {
|
||||
return RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
return plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
plugin.getConfigVoteSites().getRewardsPath(key));
|
||||
}
|
||||
|
||||
@@ -240,4 +239,19 @@ public class VoteSite {
|
||||
return ArrayUtils.getInstance().containsIgnoreCase(plugin.getServerData().getServiceSites(), getServiceSite());
|
||||
}
|
||||
|
||||
public String loadingDebug() {
|
||||
String str = "Loading votesite key: " + key;
|
||||
str += ", Displayname: " + displayName;
|
||||
str += ", VoteDelay: " + getVoteDelay();
|
||||
str += ", VoteDelayMin: " + getVoteDelayMin();
|
||||
str += ", VoteDelayDaily: " + isVoteDelayDaily();
|
||||
str += ", IsWaitUntilVoteDelay: " + isWaitUntilVoteDelay();
|
||||
str += ", ServiceSite: " + getServiceSite();
|
||||
str += ", TimeOffSet:" + getTimeOffSet();
|
||||
str += ", Url: " + getVoteURL();
|
||||
str += ", IgnoreCanVote: " + isIgnoreCanVote();
|
||||
str += ", Hidden: " + isHidden();
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -85,7 +85,9 @@ public class PlaceHolders {
|
||||
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
}
|
||||
return "..";
|
||||
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +105,11 @@ public class PlaceHolders {
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
} else {
|
||||
return "....";
|
||||
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
|
||||
return "....";
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
@@ -111,7 +117,7 @@ public class PlaceHolders {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.debug(e);
|
||||
return "...";
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -762,10 +768,11 @@ public class PlaceHolders {
|
||||
for (String key : keys) {
|
||||
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
|
||||
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
|
||||
vpUser.dontCache();
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(),
|
||||
placeholder.placeholderRequest(vpUser, ident));
|
||||
plugin.devDebug("Updated cache for " + vpUser.getUUID() + " on " + key);
|
||||
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on " + key);
|
||||
|
||||
}
|
||||
|
||||
@@ -804,19 +811,15 @@ public class PlaceHolders {
|
||||
public void onUpdate(VotingPluginUser user) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (!placeholder.getIdentifier().startsWith("Top_") || placeholder.getCache().isEmpty()
|
||||
|| placeholder.getUpdateDataKey().isEmpty()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
}
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll();
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
@@ -851,24 +854,6 @@ public class PlaceHolders {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String uuid : uuids) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("Top_")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
if (ident != null) {
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
} else {
|
||||
plugin.debug("ident null: " + placeholder.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,13 @@ package com.bencodez.votingplugin.specialrewards;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
@@ -49,6 +49,22 @@ public class SpecialRewards {
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public boolean checkAlmostAllSites(VotingPluginUser user, boolean forceBungee) {
|
||||
boolean checkAllVotes = user.checkAlmostAllVotes();
|
||||
if (checkAllVotes) {
|
||||
int currentDay = LocalDateTime.now().getDayOfYear();
|
||||
int day = user.getGottenAlmostAllSitesDay();
|
||||
if (currentDay == day) {
|
||||
checkAllVotes = false;
|
||||
plugin.debug("Not giving almostallsites, already gotten today");
|
||||
} else {
|
||||
user.setGottenAlmostAllSitesDay(currentDay);
|
||||
giveAlmostAllSitesRewards(user, user.isOnline(), forceBungee);
|
||||
}
|
||||
}
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public boolean checkCumualativeVotes(VotingPluginUser user, BungeeMessageData bungeeMessageData,
|
||||
boolean forceBungee) {
|
||||
boolean gotCumulativeAny = false;
|
||||
@@ -58,7 +74,7 @@ public class SpecialRewards {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(votesRequired))) {
|
||||
boolean gotCumulative = false;
|
||||
int total = 0;
|
||||
@@ -87,8 +103,25 @@ public class SpecialRewards {
|
||||
}
|
||||
}
|
||||
|
||||
if (total != 0 && total >= votesRequired) {
|
||||
if ((total % votesRequired) == 0) {
|
||||
List<Integer> blackList = plugin.getSpecialRewardsConfig()
|
||||
.getCumulativeBlackList(votesRequired);
|
||||
boolean blackListed = false;
|
||||
for (Integer num : blackList) {
|
||||
if (num.intValue() == total) {
|
||||
blackListed = true;
|
||||
plugin.extraDebug("Not giving cumulative " + votesRequired + " to "
|
||||
+ user.getPlayerName() + " due to blacklist");
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRecurring(votesRequired)) {
|
||||
if (total != 0 && total >= votesRequired) {
|
||||
if ((total % votesRequired) == 0 && !blackListed) {
|
||||
gotCumulative = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (total == votesRequired) {
|
||||
gotCumulative = true;
|
||||
}
|
||||
}
|
||||
@@ -116,7 +149,7 @@ public class SpecialRewards {
|
||||
}
|
||||
|
||||
public boolean checkFirstVote(VotingPluginUser user, boolean forceBungee) {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVote()) {
|
||||
giveFirstVoteRewards(user, user.isOnline(), forceBungee);
|
||||
@@ -128,7 +161,7 @@ public class SpecialRewards {
|
||||
}
|
||||
|
||||
public boolean checkFirstVoteToday(VotingPluginUser user, boolean forceBungee) {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVoteToday()) {
|
||||
giveFirstVoteTodayRewards(user, user.isOnline(), forceBungee);
|
||||
@@ -181,7 +214,7 @@ public class SpecialRewards {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMilestoneRewardsPath(votesRequired))) {
|
||||
|
||||
int userVotesTotal = milestoneCount;
|
||||
@@ -217,7 +250,7 @@ public class SpecialRewards {
|
||||
int streakRequired = Integer.parseInt(s);
|
||||
if (streakRequired != 0) {
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled(type, streak)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath(type, "" + streak))) {
|
||||
int curStreak = 0;
|
||||
if (type.equalsIgnoreCase("day")) {
|
||||
@@ -261,11 +294,23 @@ public class SpecialRewards {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveAlmostAllSitesRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.ALMOSTALLSITES);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAlmostAllSitesRewardPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveCumulativeVoteReward(VotingPluginUser user, boolean online, int cumulative, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.CUMMULATIVE.setAmount(cumulative));
|
||||
@@ -277,7 +322,7 @@ public class SpecialRewards {
|
||||
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(cumulative)).setServer(forceBungee)
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
}
|
||||
|
||||
public void giveFirstVoteRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
@@ -287,7 +332,7 @@ public class SpecialRewards {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
@@ -299,7 +344,7 @@ public class SpecialRewards {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteTodayRewardsPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
@@ -314,7 +359,7 @@ public class SpecialRewards {
|
||||
}
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMilestoneRewardsPath(milestone)).setOnline(online)
|
||||
.withPlaceHolder("Milestone", "" + milestone).setServer(forceBungee).send(user);
|
||||
.withPlaceHolder("Milestone", "" + milestone).setServer(forceBungee).send(user);
|
||||
}
|
||||
|
||||
public void giveVoteStreakReward(VotingPluginUser user, boolean online, String type, String string, int votes,
|
||||
@@ -328,8 +373,7 @@ public class SpecialRewards {
|
||||
}
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath(type, string)).setOnline(online)
|
||||
.withPlaceHolder("Type", type).setServer(forceBungee).withPlaceHolder("Streak", "" + votes)
|
||||
.send(user);
|
||||
.withPlaceHolder("Type", type).setServer(forceBungee).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin.test;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
@@ -24,13 +23,13 @@ public class VoteTester {
|
||||
long time1 = System.currentTimeMillis();
|
||||
ArrayList<Long> timesPerReward = new ArrayList<Long>();
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
Reward reward = RewardHandler.getInstance().getReward(rewardName);
|
||||
Reward reward = plugin.getRewardHandler().getReward(rewardName);
|
||||
int rewardsGiven = 0;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long start1 = System.currentTimeMillis();
|
||||
if (reward.canGiveReward(user, new RewardOptions())) {
|
||||
rewardsGiven++;
|
||||
RewardHandler.getInstance().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
|
||||
plugin.getRewardHandler().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
|
||||
}
|
||||
long start2 = System.currentTimeMillis();
|
||||
timesPerReward.add(start2 - start1);
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.bencodez.votingplugin.timequeue;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class TimeQueueHandler implements Listener {
|
||||
@Getter
|
||||
private Queue<VoteTimeQueue> timeChangeQueue = new ConcurrentLinkedQueue<VoteTimeQueue>();
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public TimeQueueHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
load();
|
||||
}
|
||||
|
||||
public void processQueue() {
|
||||
while (getTimeChangeQueue().size() > 0) {
|
||||
VoteTimeQueue vote = getTimeChangeQueue().remove();
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(plugin.getVoteSiteName(true, vote.getService()), true), vote.getName(),
|
||||
vote.getService(), true);
|
||||
voteEvent.setTime(voteEvent.getTime());
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addVote(String voteUsername, String voteSiteName) {
|
||||
timeChangeQueue.add(new VoteTimeQueue(voteUsername, voteSiteName,
|
||||
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void postTimeChange(DateChangedEvent event) {
|
||||
plugin.getVoteTimer().schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
processQueue();
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
for (String str : plugin.getServerData().getTimedVoteCacheKeys()) {
|
||||
ConfigurationSection data = plugin.getServerData().getTimedVoteCacheSection(str);
|
||||
timeChangeQueue
|
||||
.add(new VoteTimeQueue(data.getString("Name"), data.getString("Service"), data.getLong("Time")));
|
||||
}
|
||||
plugin.getServerData().clearTimedVoteCache();
|
||||
plugin.getVoteTimer().schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
processQueue();
|
||||
}
|
||||
}, 120, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!timeChangeQueue.isEmpty()) {
|
||||
int num = 0;
|
||||
for (VoteTimeQueue vote : timeChangeQueue) {
|
||||
plugin.getServerData().addTimeVoted(num, vote);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
timeChangeQueue.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.bencodez.votingplugin.timequeue;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class VoteTimeQueue {
|
||||
@Getter
|
||||
@Setter
|
||||
private String name;
|
||||
@Getter
|
||||
@Setter
|
||||
private String service;
|
||||
@Getter
|
||||
@Setter
|
||||
private long time;
|
||||
|
||||
public VoteTimeQueue(String name, String service, long time) {
|
||||
this.name = name;
|
||||
this.service = service;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.bencodez.votingplugin.topvoter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public enum TopVoter {
|
||||
@@ -107,4 +108,17 @@ public enum TopVoter {
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
public static TopVoter of(TimeType type) {
|
||||
switch (type) {
|
||||
case DAY:
|
||||
return Daily;
|
||||
case MONTH:
|
||||
return Monthly;
|
||||
case WEEK:
|
||||
return Weekly;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,6 +120,11 @@ public class TopVoterHandler implements Listener {
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
if (plugin.getConfigFile().getStoreTopVotersDaily()) {
|
||||
plugin.getLogger().info("Saving TopVoters Daily");
|
||||
storeTopVoters(TopVoter.Daily);
|
||||
}
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
@@ -141,11 +146,6 @@ public class TopVoterHandler implements Listener {
|
||||
user.clearTempCache();
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().getStoreTopVotersDaily()) {
|
||||
plugin.getLogger().info("Saving TopVoters Daily");
|
||||
storeTopVoters(TopVoter.Daily);
|
||||
}
|
||||
|
||||
try {
|
||||
if (plugin.getSpecialRewardsConfig().isEnableDailyRewards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(
|
||||
@@ -182,8 +182,25 @@ public class TopVoterHandler implements Listener {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
resetTotals(TopVoter.Daily);
|
||||
// give time for other servers to catch up
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!bungeeHandleResets()) {
|
||||
resetTotals(TopVoter.Daily);
|
||||
}
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
@@ -274,7 +291,19 @@ public class TopVoterHandler implements Listener {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
resetTotals(TopVoter.Monthly);
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!bungeeHandleResets()) {
|
||||
resetTotals(TopVoter.Monthly);
|
||||
}
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
@@ -295,6 +324,11 @@ public class TopVoterHandler implements Listener {
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
if (plugin.getConfigFile().getStoreTopVotersWeekly()) {
|
||||
plugin.getLogger().info("Saving TopVoters Weekly");
|
||||
storeTopVoters(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
@@ -322,11 +356,6 @@ public class TopVoterHandler implements Listener {
|
||||
user.clearTempCache();
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().getStoreTopVotersWeekly()) {
|
||||
plugin.getLogger().info("Saving TopVoters Weekly");
|
||||
storeTopVoters(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
try {
|
||||
if (plugin.getSpecialRewardsConfig().isEnableWeeklyAwards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(
|
||||
@@ -335,7 +364,7 @@ public class TopVoterHandler implements Listener {
|
||||
int lastTotal = -1;
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Monthly).clone();
|
||||
.getTopVoter(TopVoter.Weekly).clone();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
@@ -363,7 +392,19 @@ public class TopVoterHandler implements Listener {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
resetTotals(TopVoter.Weekly);
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!bungeeHandleResets()) {
|
||||
resetTotals(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
@@ -395,6 +436,16 @@ public class TopVoterHandler implements Listener {
|
||||
plugin.getUserManager().removeAllKeyValues(topVoter.getColumnName(), DataType.INTEGER);
|
||||
}
|
||||
|
||||
public boolean bungeeHandleResets() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public LinkedHashMap<TopVoterPlayer, Integer> sortByValues(LinkedHashMap<TopVoterPlayer, Integer> map,
|
||||
final boolean order) {
|
||||
|
||||
@@ -405,9 +456,17 @@ public class TopVoterHandler implements Listener {
|
||||
@Override
|
||||
public int compare(Entry<TopVoterPlayer, Integer> o1, Entry<TopVoterPlayer, Integer> o2) {
|
||||
if (order) {
|
||||
return o1.getValue().compareTo(o2.getValue());
|
||||
int result = (o1.getValue()).compareTo(o2.getValue());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return o2.getKey().getLastVoteTime().compareTo(o1.getKey().getLastVoteTime());
|
||||
} else {
|
||||
return o2.getValue().compareTo(o1.getValue());
|
||||
int result = (o2.getValue()).compareTo(o1.getValue());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return o1.getKey().getLastVoteTime().compareTo(o2.getKey().getLastVoteTime());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,14 @@ public class TopVoterPlayer {
|
||||
@Setter
|
||||
private String playerName;
|
||||
|
||||
public TopVoterPlayer(UUID uuid, String playerName) {
|
||||
@Getter
|
||||
@Setter
|
||||
private Long lastVoteTime;
|
||||
|
||||
public TopVoterPlayer(UUID uuid, String playerName, Long lastVoteTime) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
this.lastVoteTime = lastVoteTime;
|
||||
}
|
||||
|
||||
public ItemStack getPlayerHead() {
|
||||
|
||||
@@ -45,7 +45,7 @@ public class UserManager {
|
||||
manager.addKey(new UserDataKeyInt("DayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("BestDayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyString("DayVoteStreakLastUpdate").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("LONGTEXT"));
|
||||
manager.addKey(new UserDataKeyString("Reminded").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyString("DisableBroadcast").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyInt("WeekVoteStreak"));
|
||||
@@ -72,6 +72,13 @@ public class UserManager {
|
||||
return "AllSitesLast";
|
||||
}
|
||||
|
||||
public String getGottenAlmostAllSitesDayPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "AlmostAllSitesLast_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
}
|
||||
return "AlmostAllSitesLast";
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllUUIDs() {
|
||||
return plugin.getUserManager().getAllUUIDs();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.bukkit.entity.Player;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
@@ -114,15 +113,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* Adds the points.
|
||||
*
|
||||
* @param value the value
|
||||
* @return current total points
|
||||
*/
|
||||
public void addPoints(int value) {
|
||||
public synchronized int addPoints(int value) {
|
||||
PlayerReceivePointsEvent event = new PlayerReceivePointsEvent(this, value);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
return getPoints();
|
||||
}
|
||||
setPoints(getPoints() + event.getPoints());
|
||||
int newTotal = getPoints() + event.getPoints();
|
||||
setPoints(newTotal);
|
||||
return newTotal;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,13 +170,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setAddTotals(setTotals);
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
voteEvent.setVotingPluginUser(this);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,18 +185,12 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setAddTotals(setTotals);
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
voteEvent.setVotingPluginUser(this);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
}
|
||||
|
||||
public void bungeeVotePluginMessaging(String service, long time, BungeeMessageData text, boolean setTotals,
|
||||
boolean wasOnline, boolean broadcast) {
|
||||
boolean wasOnline, boolean broadcast, int num) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
|
||||
|
||||
@@ -214,13 +204,8 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
voteEvent.setWasOnline(wasOnline);
|
||||
voteEvent.setBroadcast(broadcast);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
voteEvent.setVoteNumber(num);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,6 +279,13 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
}
|
||||
|
||||
public boolean checkAlmostAllVotes() {
|
||||
if (getSitesNotVotedOn() == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all votes.
|
||||
*
|
||||
@@ -387,7 +379,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
if (str == null || str.isEmpty() || str.equals("null")) {
|
||||
return 0;
|
||||
}
|
||||
return Long.parseLong(str);
|
||||
try {
|
||||
return Long.parseLong(str);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getDisableBroadcast() {
|
||||
@@ -398,6 +394,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return getData().getInt(plugin.getVotingPluginUserManager().getGottenAllSitesDayPath(), 0, isWaitForCache());
|
||||
}
|
||||
|
||||
public int getGottenAlmostAllSitesDay() {
|
||||
return getData().getInt(plugin.getVotingPluginUserManager().getGottenAlmostAllSitesDayPath(), 0,
|
||||
isWaitForCache());
|
||||
}
|
||||
|
||||
public HashMap<String, Boolean> getHasGottenMilestone() {
|
||||
HashMap<String, Boolean> hasGottenMilestone = new HashMap<String, Boolean>();
|
||||
ArrayList<String> milestoneList = getUserData().getStringList(getGottenMilestonesPath());
|
||||
@@ -427,6 +428,31 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return getData().getInt("LastMonthTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Boolean> getCoolDownCheckSiteList() {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = new HashMap<VoteSite, Boolean>();
|
||||
ArrayList<String> coolDownCheck = getData().getStringList(getCoolDownCheckSitePath(), isCacheData(),
|
||||
isWaitForCache());
|
||||
for (String str : coolDownCheck) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1 && plugin.hasVoteSite(data[0])) {
|
||||
VoteSite site = plugin.getVoteSite(data[0], true);
|
||||
if (site != null) {
|
||||
Boolean b = Boolean.valueOf(data[1]);
|
||||
coolDownChecks.put(site, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
return coolDownChecks;
|
||||
}
|
||||
|
||||
public boolean getCoolDownCheckSite(VoteSite site) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
if (coolDownChecks.containsKey(site)) {
|
||||
return coolDownChecks.get(site).booleanValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Long> getLastVotes() {
|
||||
HashMap<VoteSite, Long> lastVotes = new HashMap<VoteSite, Long>();
|
||||
ArrayList<String> LastVotesList = getUserData().getStringList("LastVotes");
|
||||
@@ -449,6 +475,16 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return lastVotes;
|
||||
}
|
||||
|
||||
public Long getLastVoteTime() {
|
||||
Long time = Long.valueOf(0);
|
||||
for (Long value : getLastVotes().values()) {
|
||||
if (value.longValue() > time) {
|
||||
time = value;
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last vote times sorted.
|
||||
*
|
||||
@@ -568,22 +604,22 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
public void giveDailyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getDailyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
.withPlaceHolder("topvoter", "Daily").withPlaceHolder("votes", "" + getTotal(TopVoter.Daily))
|
||||
.setOnline(isOnline()).send(this);
|
||||
.withPlaceHolder("topvoter", "Daily").withPlaceHolder("votes", "" + getTotal(TopVoter.Daily))
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
public void giveMonthlyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMonthlyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
.withPlaceHolder("topvoter", "Monthly")
|
||||
.withPlaceHolder("votes", "" + getTotal(TopVoter.Monthly)).setOnline(isOnline()).send(this);
|
||||
.withPlaceHolder("topvoter", "Monthly").withPlaceHolder("votes", "" + getTotal(TopVoter.Monthly))
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
public void giveWeeklyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getWeeklyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
.withPlaceHolder("topvoter", "Weekly").withPlaceHolder("votes", "" + getTotal(TopVoter.Weekly))
|
||||
.setOnline(isOnline()).send(this);
|
||||
.withPlaceHolder("topvoter", "Weekly").withPlaceHolder("votes", "" + getTotal(TopVoter.Weekly))
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -682,16 +718,23 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
setTopVoterIgnore(topVoterIngorePerm);
|
||||
}
|
||||
ArrayList<String> offlineVotes = getOfflineVotes();
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(offlineVotes));
|
||||
// plugin.debug("Offvotes: " +
|
||||
// ArrayUtils.getInstance().makeStringList(offlineVotes));
|
||||
if (offlineVotes.size() > 0) {
|
||||
sendVoteEffects(false);
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
}
|
||||
|
||||
boolean offlineBroadcast = plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast();
|
||||
|
||||
if (offlineBroadcast && offlineVotes.size() > 0) {
|
||||
offlineBroadcast(this, plugin.getBungeeSettings().isUseBungeecoord(), offlineVotes.size());
|
||||
}
|
||||
|
||||
for (int i = 0; i < offlineVotes.size(); i++) {
|
||||
if (plugin.hasVoteSite(offlineVotes.get(i))) {
|
||||
plugin.debug("Giving offline site reward: " + offlineVotes.get(i));
|
||||
playerVote(plugin.getVoteSite(offlineVotes.get(i), true), false, true, false);
|
||||
playerVote(plugin.getVoteSite(offlineVotes.get(i), true), false, !offlineBroadcast, false);
|
||||
} else {
|
||||
plugin.debug("Site doesn't exist: " + offlineVotes.get(i));
|
||||
}
|
||||
@@ -699,6 +742,52 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
|
||||
public void offlineBroadcast(VotingPluginUser user, boolean checkBungee, int numberOfVotes) {
|
||||
if (plugin.getConfigFile().isFormatAlternateBroadcastEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (!user.isVanished()) {
|
||||
String playerName = user.getPlayerName();
|
||||
if (plugin.getConfigFile().getVotingBroadcastBlacklist().contains(playerName)) {
|
||||
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
|
||||
return;
|
||||
}
|
||||
if (checkBungee && plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
plugin.getBungeeHandler().sendData("BroadcastOffline", "" + numberOfVotes, user.getPlayerName());
|
||||
} else if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
String uuid = user.getUUID();
|
||||
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteBroadcastOffline", uuid, "" + numberOfVotes);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
String bc = StringParser.getInstance().colorize(plugin.getConfigFile().getFormatOfflineBroadcast());
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("player", playerName);
|
||||
placeholders.put("nickname",
|
||||
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
|
||||
placeholders.put("numberofvotes", "" + numberOfVotes);
|
||||
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
MiscUtils.getInstance().broadcast(bc, players);
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getPlayerName() + " is vanished, not broadcasting");
|
||||
}
|
||||
}
|
||||
|
||||
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast, boolean bungee) {
|
||||
if (plugin.getConfigFile().getFormatBroadcastWhenOnline() && plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& broadcast && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
@@ -731,7 +820,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* @param online the online
|
||||
*/
|
||||
public void sendVoteEffects(boolean online) {
|
||||
RewardHandler.getInstance().giveReward(this, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getRewardHandler().giveReward(this, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath(), new RewardOptions().setOnline(online));
|
||||
}
|
||||
|
||||
@@ -776,6 +865,10 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
getData().setInt(plugin.getVotingPluginUserManager().getGottenAllSitesDayPath(), day);
|
||||
}
|
||||
|
||||
public void setGottenAlmostAllSitesDay(int day) {
|
||||
getData().setInt(plugin.getVotingPluginUserManager().getGottenAlmostAllSitesDayPath(), day);
|
||||
}
|
||||
|
||||
public void setHasGotteMilestone(int votesRequired, boolean b) {
|
||||
HashMap<String, Boolean> hasGottenMilestone = getHasGottenMilestone();
|
||||
hasGottenMilestone.put("" + votesRequired, b);
|
||||
@@ -793,7 +886,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public String getGottenMilestonesPath() {
|
||||
if (plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
return plugin.getOptions().getServer() + "_" + "GottenMilestones";
|
||||
return plugin.getBungeeSettings().getServerNameStorage() + "_" + "GottenMilestones";
|
||||
}
|
||||
return "GottenMileStones";
|
||||
}
|
||||
@@ -823,18 +916,41 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
getUserData().setStringList("LastVotes", data);
|
||||
}
|
||||
|
||||
public void setCoolDownCheckSite(HashMap<VoteSite, Boolean> coolDownChecks) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<VoteSite, Boolean> entry : coolDownChecks.entrySet()) {
|
||||
String str = entry.getKey().getKey() + "//" + entry.getValue().toString();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList(getCoolDownCheckSitePath(), data);
|
||||
}
|
||||
|
||||
public void setCoolDownCheckSite(VoteSite site, boolean value) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
coolDownChecks.put(site, Boolean.valueOf(value));
|
||||
setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
|
||||
public void setMilestoneCount(int value) {
|
||||
getData().setInt("MilestoneCount", value);
|
||||
}
|
||||
|
||||
public String getCoolDownCheckPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServer();
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
} else {
|
||||
return "CoolDownCheck";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCoolDownCheckSitePath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage() + "_Sites";
|
||||
} else {
|
||||
return "CoolDownCheck" + "_Sites";
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoolDownCheck(boolean coolDownCheck) {
|
||||
getData().setBoolean(getCoolDownCheckPath(), coolDownCheck);
|
||||
}
|
||||
@@ -865,7 +981,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* @param value the new points
|
||||
*/
|
||||
public void setPoints(int value) {
|
||||
getUserData().setInt(getPointsPath(), value, !plugin.getBungeeSettings().isUseBungeecoord());
|
||||
getUserData().setInt(getPointsPath(), value, false);
|
||||
}
|
||||
|
||||
public void setPrimaryAccount(java.util.UUID uuid) {
|
||||
@@ -1227,7 +1343,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public TopVoterPlayer getTopVoterPlayer() {
|
||||
return new TopVoterPlayer(UUID.fromString(getUUID()), getPlayerName());
|
||||
return new TopVoterPlayer(UUID.fromString(getUUID()), getPlayerName(), getLastOnline());
|
||||
}
|
||||
|
||||
public long getNextTimeAllSitesAvailable() {
|
||||
@@ -1242,4 +1358,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return longest;
|
||||
}
|
||||
|
||||
public long getNextTimeFirstSiteAvailable() {
|
||||
long shortest = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!canVoteSite(site)) {
|
||||
long seconds = voteNextDurationTime(site);
|
||||
if (shortest == 0 || seconds < shortest) {
|
||||
shortest = seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return shortest;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -60,29 +60,40 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
|
||||
public void check(boolean forceBungee) {
|
||||
if (getTotalVotes() >= getVotesRequired() && ((plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
|
||||
&& plugin.getServerData().isLastVotePartySameDay())
|
||||
|| !plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay())) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
}
|
||||
if (getTotalVotes() < getVotesRequired()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
|
||||
&& plugin.getServerData().isLastVotePartySameDay()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerWeek()
|
||||
&& plugin.getServerData().isLastVotePartySameWeek()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
}
|
||||
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
giveRewards(forceBungee);
|
||||
giveRewards(forceBungee);
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired() > 0) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
|
||||
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired() > 0) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
|
||||
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
|
||||
plugin.getServerData().updateLastVoteParty();
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
|
||||
plugin.getServerData().updateLastVoteParty();
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerWeek()) {
|
||||
plugin.getServerData().updateLastVotePartyWeek();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -103,7 +114,13 @@ public class VoteParty implements Listener {
|
||||
placeholders.put("neededvotes", "" + neededVotes);
|
||||
placeholders.put("votes", "" + votes);
|
||||
msg = ArrayUtils.getInstance().colorize(ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders));
|
||||
sender.sendMessage(ArrayUtils.getInstance().convert(msg));
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
sender.sendMessage(
|
||||
ArrayUtils.getInstance().convert(ArrayUtils.getInstance().replacePlaceHolders(msg, p)));
|
||||
} else {
|
||||
sender.sendMessage(ArrayUtils.getInstance().convert(msg));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cVoteParty not enabled"));
|
||||
}
|
||||
@@ -164,11 +181,9 @@ public class VoteParty implements Listener {
|
||||
|
||||
public void giveReward(VotingPluginUser user, boolean online, boolean useBungee) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVotePartyRewardsPath())
|
||||
.setOnline(online)
|
||||
.withPlaceHolder("VotesRequired",
|
||||
"" + plugin.getSpecialRewardsConfig().getVotePartyVotesRequired())
|
||||
.setServer(useBungee).send(user);
|
||||
plugin.getSpecialRewardsConfig().getVotePartyRewardsPath()).setOnline(online)
|
||||
.withPlaceHolder("VotesRequired", "" + plugin.getSpecialRewardsConfig().getVotePartyVotesRequired())
|
||||
.setServer(useBungee).send(user);
|
||||
}
|
||||
|
||||
public void giveRewards(boolean forceBungee) {
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package com.bencodez.votingplugin.votereminding;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -24,7 +25,7 @@ public class VoteReminding {
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private Timer timer;
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
@Getter
|
||||
private ConcurrentHashMap<UUID, Boolean> remindersEnabled = new ConcurrentHashMap<UUID, Boolean>();
|
||||
@@ -61,11 +62,11 @@ public class VoteReminding {
|
||||
*/
|
||||
public void loadRemindChecking() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer.shutdownNow();
|
||||
}
|
||||
if (plugin.getConfigFile().getVoteRemindingRemindDelay() > 0) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -75,10 +76,10 @@ public class VoteReminding {
|
||||
checkRemind(user);
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
timer.shutdown();
|
||||
}
|
||||
}
|
||||
}, 1000 * 30, plugin.getConfigFile().getVoteRemindingRemindDelay() * 1000 * 60);
|
||||
}, 30, plugin.getConfigFile().getVoteRemindingRemindDelay() * 60, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +105,7 @@ public class VoteReminding {
|
||||
public boolean shouldRemind(VotingPluginUser user) {
|
||||
if (remindersEnabled.containsKey(user.getJavaUUID())) {
|
||||
if (!remindersEnabled.get(user.getJavaUUID()).booleanValue()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -115,6 +117,7 @@ public class VoteReminding {
|
||||
return user.canVoteAny();
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getUUID() + " no need to remind because plaeyr has VotingPlugin.NoRemind");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -132,7 +135,11 @@ public class VoteReminding {
|
||||
}
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
} else {
|
||||
plugin.debug("Not reminding for " + user.getUUID());
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getUUID() + " has no permission for reminders");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user