Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
16de063e51 | ||
|
|
1d3ce9ed64 | ||
|
|
d357c927c8 | ||
|
|
1143595238 | ||
|
|
0917c36889 | ||
|
|
c113214ae0 | ||
|
|
b2c444d125 | ||
|
|
78fdce0eab | ||
|
|
feff09eccb | ||
|
|
d0646472bf | ||
|
|
8471f50402 | ||
|
|
621450dae4 | ||
|
|
84e415e4bc | ||
|
|
54bbc8c740 | ||
|
|
7b1ab7e833 | ||
|
|
acb8f8a43f | ||
|
|
279759b52f | ||
|
|
02ca0b1fc8 | ||
|
|
d57e3d1006 | ||
|
|
d54769eb82 | ||
|
|
35f6a3df15 | ||
|
|
46b66466ba | ||
|
|
53fbe4e5e2 | ||
|
|
53ef7a7086 | ||
|
|
b0e08721fa | ||
|
|
29dad6ca25 | ||
|
|
7c3e5eb09b | ||
|
|
a7776ec97c | ||
|
|
d598082c0a | ||
|
|
4539b5b22a | ||
|
|
02fe645d1e | ||
|
|
ee8af6a314 | ||
|
|
a4b78c7d16 | ||
|
|
d22fe462e5 | ||
|
|
c19182a2b4 | ||
|
|
6905c3988b | ||
|
|
23be120adc | ||
|
|
dae863f88f | ||
|
|
d12f73d2fa | ||
|
|
316ee90713 | ||
|
|
1495fad96f | ||
|
|
8e0de1709b | ||
|
|
ad22802e10 | ||
|
|
6de0345f06 | ||
|
|
7338a7d8ba | ||
|
|
3ca12f2c91 | ||
|
|
262e7c48c7 | ||
|
|
0b62d99f9d | ||
|
|
ea30de47d1 | ||
|
|
a76daf3aba | ||
|
|
e1ff13f4bf | ||
|
|
12f941cf83 | ||
|
|
243377a76a | ||
|
|
d7eab03860 | ||
|
|
ddd1f473f1 | ||
|
|
3e52bb0936 | ||
|
|
eb60220b1e | ||
|
|
00902bd597 | ||
|
|
d3606088cd | ||
|
|
ef2512e4e2 | ||
|
|
7f95a1c7c3 | ||
|
|
68a2fe27ff | ||
|
|
b05317c460 | ||
|
|
62fee6f347 | ||
|
|
ef7d4254e1 | ||
|
|
b6720ccc1f | ||
|
|
69d3d33008 | ||
|
|
7a193c87a9 | ||
|
|
f2cf2fb734 | ||
|
|
836079b5ea | ||
|
|
a7f6456480 | ||
|
|
82f25c3899 | ||
|
|
cb2cdbd4fc | ||
|
|
40d2b651a8 | ||
|
|
a999d9e9bb | ||
|
|
b144f2db9c | ||
|
|
24060a10ed | ||
|
|
4c8919804f |
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
|
||||
@@ -39,6 +39,11 @@ DisableBroadcast: false
|
||||
# Requires server name below to be correct
|
||||
PerServerRewards: false
|
||||
|
||||
# If true, milestones work per server
|
||||
# Please note totals still sync, but milestones can be claimed on each server
|
||||
# Needs to be set across all needed servers
|
||||
PerServerMilestones: false
|
||||
|
||||
# If true, points will be given on a per server level
|
||||
# Points will be added when server gets vote from bungee
|
||||
PerServerPoints: false
|
||||
@@ -51,18 +56,14 @@ TriggerVotifierEvent: false
|
||||
# Also can be applied to rewards
|
||||
Server: PleaseSet
|
||||
|
||||
# Rewards from bungee vote party
|
||||
# Gives to only players only
|
||||
# Use regular voteparty rewards otherwise
|
||||
# Can edit via /av gui
|
||||
BungeeVotePartyRewards: {}
|
||||
|
||||
# -----------------------------
|
||||
# For socket setup below only
|
||||
# -----------------------------
|
||||
|
||||
# Bungee communication, add bungee host/port here
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add this to bungee server
|
||||
# For socket method
|
||||
SpigotServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
@@ -22,17 +22,16 @@ MySQL:
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Maxium size of caching mysql
|
||||
# -1 for no limit
|
||||
# Affecting this value may affect performance
|
||||
MaxSize: -1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
# Don't use with PLUGINMESSAGING bungee setup
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#MaxLifeTime: -1
|
||||
#Additional info on connection string
|
||||
#Line: ''
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# --------------------
|
||||
# AllowUnJoined options
|
||||
@@ -80,7 +79,7 @@ VoteReminding:
|
||||
# This can also be edited via /av gui
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou have %sitesavailable% to vote on still!'
|
||||
Player: '&aYou have %sitesavailable% sites to vote on still!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
@@ -110,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
|
||||
@@ -252,6 +255,10 @@ Format:
|
||||
ToggleBroadcasts:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
ToggleReminders:
|
||||
Enabled: '&cVote reminders enabled'
|
||||
Disabled: '&cVote reminders disabled'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
@@ -376,7 +383,7 @@ DisableCoolDownCheck: false
|
||||
DisableInteractEvent: false
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In ticks
|
||||
# In miliseconds, 1000 = 1 second
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
@@ -414,6 +421,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
|
||||
@@ -426,6 +437,10 @@ LimitMonthlyVotes: false
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# Close inventory on player vote
|
||||
# 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
|
||||
@@ -438,6 +453,20 @@ UsePrimaryAccountForPlaceholders: false
|
||||
# Only affects placeholderapi placeholders
|
||||
AlwaysWaitForCachePlaceholders: 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
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
@@ -564,6 +593,11 @@ PreloadSkulls: false
|
||||
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
|
||||
LoadSkulls: true
|
||||
|
||||
# Limit number of users to load in a second
|
||||
# Effects background tasks mainly
|
||||
# set to -1 to disable (default value)
|
||||
#PlayerDataLoadLimit: 500
|
||||
|
||||
# Use vault for permission checks
|
||||
# May not work on some plugins
|
||||
UseVaultPermissions: false
|
||||
|
||||
@@ -79,8 +79,8 @@ CHEST:
|
||||
# Name: 'Extra item'
|
||||
## Works on most GUI items
|
||||
# Slot: 10
|
||||
## Send rewards on click, run commands, check conditions, etc
|
||||
# Rewards: []
|
||||
## Send rewards on click, run commands, check conditions, etc
|
||||
# Rewards: []
|
||||
|
||||
# GUI for /vote url, /vote
|
||||
VoteURL:
|
||||
@@ -204,6 +204,7 @@ CHEST:
|
||||
Amount: 1
|
||||
VoteBest:
|
||||
Name: 'VoteBest: %player%'
|
||||
BackButton: true
|
||||
DayBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
|
||||
@@ -18,9 +18,14 @@ AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
|
||||
# If true only cumulative reward at a time can be given
|
||||
# The cumulative rewards will go in order as listed under Cumulative, so if true
|
||||
# the first cumulative (in the order as listed) that can be given will, then will ignore the rest
|
||||
OnlyOneCumulative: false
|
||||
# NOTE: This is not a 1 time reward, that's what milestones are for!
|
||||
# If total votes (Can be changed) divided by cumulative amount
|
||||
# and as no remainder (So divides perfectly)then a reward is given
|
||||
# and with no remainder (So divides perfectly) then a reward is given
|
||||
Cumulative:
|
||||
# Number of votes required
|
||||
# Allows multiple cumulative rewards
|
||||
@@ -28,7 +33,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
|
||||
@@ -37,6 +42,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!'
|
||||
@@ -168,6 +178,11 @@ LogoutRewards: {}
|
||||
|
||||
EnableMonthlyAwards: true
|
||||
|
||||
# TopVoter Placeholders:
|
||||
#%place% - place in topvoter
|
||||
#%topvoter% - topvoter type
|
||||
#%votes% - current total votes related to top voter
|
||||
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
|
||||
@@ -26,7 +26,7 @@ VoteSites:
|
||||
ServiceSite: 'PlanetMinecraft.com'
|
||||
|
||||
# vote url for /vote
|
||||
# Format for this can be set in Format.yml
|
||||
# Format for this can be set in Config.yml
|
||||
# Do not include colors here
|
||||
# If you need to force a url set the url as this:
|
||||
# VoteURL: '[Text="ANY TEXT TO CLICK ON HERE",url="URLHERE"]'
|
||||
@@ -62,7 +62,7 @@ VoteSites:
|
||||
Amount: 1
|
||||
|
||||
# Rewards to give
|
||||
# https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards
|
||||
# https://github.com/BenCodez/AdvancedCore/wiki/Rewards
|
||||
Rewards:
|
||||
# Execute console commands
|
||||
Commands:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.bungee.VotingPluginBungee
|
||||
author: BenCodez
|
||||
author: BenCodez
|
||||
softDepends:
|
||||
- RedisBungee
|
||||
@@ -11,14 +11,13 @@ Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Maxium size of caching mysql
|
||||
# -1 for no limit
|
||||
# Affecting this value may affect performance
|
||||
MaxSize: -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
|
||||
|
||||
Debug: false
|
||||
# Have a reward on each server
|
||||
@@ -52,10 +51,33 @@ 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
|
||||
|
||||
VoteParty:
|
||||
# If enabled, will trigger vote party reward
|
||||
# in BungeeSettings.yml under BungeeVotePartyReward
|
||||
# Only runs rewards for online players
|
||||
Enabled: false
|
||||
# Votes required
|
||||
VotesRequired: 100
|
||||
# Increase amount required on each vote party
|
||||
IncreaseVotesRequired: 0
|
||||
# If false, will only send to servers listed below
|
||||
SendToAllServers: true
|
||||
# Servers to send to, if SendToAllServers is false
|
||||
ServersToSend: []
|
||||
# List of commands to run on bungee server
|
||||
# Set spigot commands in BungeeSettings.yml
|
||||
BungeeCommands: []
|
||||
Broadcast: '&aVote party has been reached!'
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# PLUGINMESSAGING Settings
|
||||
# ----------------------------
|
||||
@@ -68,22 +90,5 @@ WaitForUserOnline: false
|
||||
# SOCKET Settings
|
||||
# ONLY for SOCKET method
|
||||
# ----------------------------
|
||||
|
||||
# Server to send vote to if player is offline
|
||||
FallBackServer: factions
|
||||
|
||||
# Bungee communication, Add this to each spigot server
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add each spigot server here
|
||||
# For socket method
|
||||
SpigotServers:
|
||||
lobby:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
factions:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1999
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
+271
-261
@@ -1,261 +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.2
|
||||
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
|
||||
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
|
||||
adminvoteDownload:
|
||||
description: Command Alias
|
||||
aliases: avdownload
|
||||
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
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteSetVotePartyCount:
|
||||
description: Command Alias
|
||||
aliases: avSetVotePartyCount
|
||||
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
|
||||
adminvoteForceVoteParty:
|
||||
description: Command Alias
|
||||
aliases: avForceVoteParty
|
||||
adminvoteSetRequestMethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
adminvoteUser:
|
||||
description: Command Alias
|
||||
aliases: avUser
|
||||
adminvoteCurrentPluginTime:
|
||||
description: Command Alias
|
||||
aliases: avCurrentPluginTime
|
||||
adminvoteResetPoints:
|
||||
description: Command Alias
|
||||
aliases: avResetPoints
|
||||
adminvoteVotePartyExtraRequired:
|
||||
description: Command Alias
|
||||
aliases: avVotePartyExtraRequired
|
||||
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
|
||||
- PremiumVanishs
|
||||
- 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
|
||||
+13
-5
@@ -1,10 +1,8 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.6.2</version>
|
||||
<version>6.9.2</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -213,12 +211,22 @@
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.limework</groupId>
|
||||
<artifactId>redisbungee</artifactId>
|
||||
<version>0.6.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.19-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -4,7 +4,15 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
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.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
@@ -18,7 +26,7 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeHandler {
|
||||
public class BungeeHandler implements Listener {
|
||||
@Getter
|
||||
private ClientHandler clientHandler;
|
||||
|
||||
@@ -29,6 +37,12 @@ public class BungeeHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyCurrent = 0;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyRequired = 0;
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
@@ -39,6 +53,16 @@ public class BungeeHandler {
|
||||
public void close() {
|
||||
socketHandler.closeConnection();
|
||||
clientHandler.stopConnection();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
}
|
||||
|
||||
@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 load() {
|
||||
@@ -53,7 +77,10 @@ public class BungeeHandler {
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
|
||||
plugin.getPluginMessaging().setDebug(true);
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
|
||||
|
||||
plugin.getPluginMessaging().setDebug(plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
@Override
|
||||
@@ -77,22 +104,36 @@ public class BungeeHandler {
|
||||
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.clearCache();
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
@@ -124,6 +165,11 @@ public class BungeeHandler {
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
|
||||
plugin.debug(
|
||||
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
@@ -139,17 +185,28 @@ public class BungeeHandler {
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast() && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (Boolean.valueOf(args.get(4)) || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (Boolean.valueOf(args.get(4))
|
||||
|| plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
@@ -176,6 +233,11 @@ public class BungeeHandler {
|
||||
|
||||
user.offVote();
|
||||
|
||||
if (args.size() > 2) {
|
||||
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
|
||||
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
@@ -198,6 +260,19 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
@@ -207,6 +282,23 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String broadcast = args.get(0);
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
@@ -216,7 +308,13 @@ public class BungeeHandler {
|
||||
|
||||
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") {
|
||||
|
||||
@@ -268,6 +366,19 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
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
|
||||
@@ -285,6 +396,23 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
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[3];
|
||||
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
|
||||
@@ -305,6 +433,25 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBungee") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
String broadcast = data[0];
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
}
|
||||
|
||||
@@ -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,6 +16,7 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
@@ -44,7 +45,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;
|
||||
@@ -208,11 +208,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Getter
|
||||
private boolean ymlError = false;
|
||||
|
||||
@Getter
|
||||
private Timer voteTimer = new Timer();
|
||||
|
||||
@Getter
|
||||
private UserManager votingPluginUserManager;
|
||||
|
||||
private void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
|
||||
RewardHandler.getInstance().addDirectlyDefined(directlyDefinedReward);
|
||||
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
|
||||
}
|
||||
|
||||
public void basicBungeeUpdate() {
|
||||
@@ -270,7 +273,11 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
public LinkedHashMap<TopVoterPlayer, Integer> getTopVoter(TopVoter top) {
|
||||
return topVoter.get(top);
|
||||
LinkedHashMap<TopVoterPlayer, Integer> top1 = topVoter.get(top);
|
||||
if (top1 == null) {
|
||||
top1 = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
}
|
||||
return top1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -340,11 +347,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String siteName : sites) {
|
||||
if (siteName.equalsIgnoreCase(url)) {
|
||||
return siteName;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return url;
|
||||
@@ -398,7 +404,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
public void loadDirectlyDefined() {
|
||||
RewardHandler.getInstance().getDirectlyDefinedRewards().clear();
|
||||
getRewardHandler().getDirectlyDefinedRewards().clear();
|
||||
// AllSites reward
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("AllSites") {
|
||||
|
||||
@@ -846,6 +852,28 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
});
|
||||
}
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("BungeeVotePartyRewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
getBungeeSettings().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return getBungeeSettings().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getBungeeSettings().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
getBungeeSettings().setValue(path, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
@@ -1015,15 +1043,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
|
||||
@@ -1041,7 +1071,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,
|
||||
@@ -1060,7 +1090,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) {
|
||||
@@ -1077,11 +1107,11 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
if (getProfile().contains("dev")) {
|
||||
plugin.getLogger().warning(
|
||||
plugin.getLogger().info(
|
||||
"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;
|
||||
@@ -1090,7 +1120,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
if (!site.hasRewards() && !hasRewards) {
|
||||
issues = false;
|
||||
plugin.getLogger().warning("No rewards detected for the site: " + site.getKey()
|
||||
+ ". See https://github.com/BenCodez/VotingPlugin/wiki/Rewards on how to add rewards");
|
||||
+ ". See https://github.com/BenCodez/VotingPlugin/wiki/Rewards");
|
||||
}
|
||||
|
||||
boolean contains = false;
|
||||
@@ -1189,8 +1219,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
// /adminvote, /av
|
||||
getCommand("adminvote").setExecutor(new CommandAdminVote(this));
|
||||
getCommand("adminvote").setTabCompleter(new AdminVoteTabCompleter());
|
||||
getCommand("adminvote").setPermission("VotingPlugin.Commands.AdminVote");
|
||||
getCommand("av").setExecutor(new CommandAdminVote(this));
|
||||
getCommand("av").setTabCompleter(new AdminVoteTabCompleter());
|
||||
getCommand("av").setPermission("VotingPlugin.Commands.AdminVote");
|
||||
|
||||
Permission perm = Bukkit.getPluginManager().getPermission("VotingPlugin.Player");
|
||||
if (perm != null) {
|
||||
@@ -1271,7 +1303,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
loadDirectlyDefined();
|
||||
reloadAdvancedCore(userStorage);
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
placeholders.load();
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
}
|
||||
|
||||
voteReminding.loadRemindChecking();
|
||||
coolDownCheck.checkEnabled();
|
||||
@@ -1316,98 +1350,119 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
update = false;
|
||||
|
||||
synchronized (plugin) {
|
||||
getUserManager().getDataManager().clearCacheBasic();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
getUserManager().getDataManager().clearCacheBasic();
|
||||
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
try {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
|
||||
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
|
||||
|
||||
ArrayList<TopVoter> topVotersToCheck = new ArrayList<TopVoter>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (plugin.getConfigFile().getLoadTopVoter(top)) {
|
||||
topVotersToCheck.add(top);
|
||||
tempTopVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
|
||||
}
|
||||
}
|
||||
boolean topVoterIgnorePermissionUse = plugin.getConfigFile().getTopVoterIgnorePermission();
|
||||
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
int currentDay = LocalDateTime.now().getDayOfMonth();
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance()
|
||||
.getYearFromMili(time))) {
|
||||
|
||||
times.put(entry.getKey(), LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (!extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + uuids.size()
|
||||
+ " users, " + plugin.getStorageType().toString());
|
||||
time1 = System.currentTimeMillis();
|
||||
|
||||
topVoterHandler.updateTopVoters(tempTopVoter);
|
||||
setVoteToday(voteToday);
|
||||
serverData.updateValues();
|
||||
getSigns().updateSigns();
|
||||
|
||||
tempTopVoter = null;
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
plugin.extraDebug("Current cached users: "
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
checkFirstTimeLoaded();
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().info("Looks like something went wrong");
|
||||
ex.printStackTrace();
|
||||
|
||||
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
|
||||
try {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
|
||||
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
|
||||
|
||||
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>());
|
||||
}
|
||||
}
|
||||
boolean topVoterIgnorePermissionUse = plugin.getConfigFile()
|
||||
.getTopVoterIgnorePermission();
|
||||
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
int currentDay = LocalDateTime.now().getDayOfMonth();
|
||||
int currentDataLoad = 0;
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance()
|
||||
.getYearFromMili(time))) {
|
||||
|
||||
times.put(entry.getKey(), LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (!extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
plugin.getPlaceholders().onUpdate(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
if (dataLoadLimit > 0) {
|
||||
currentDataLoad++;
|
||||
if (currentDataLoad >= dataLoadLimit) {
|
||||
currentDataLoad -= dataLoadLimit;
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + uuids.size()
|
||||
+ " users, " + plugin.getStorageType().toString() + ", data load limit: "
|
||||
+ dataLoadLimit);
|
||||
time1 = System.currentTimeMillis();
|
||||
|
||||
topVoterHandler.updateTopVoters(tempTopVoter);
|
||||
placeholders.onUpdate();
|
||||
setVoteToday(voteToday);
|
||||
serverData.updateValues();
|
||||
getSigns().updateSigns();
|
||||
|
||||
tempTopVoter = null;
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
plugin.extraDebug("Current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
checkFirstTimeLoaded();
|
||||
} catch (Exception ex) {
|
||||
if (plugin != null) {
|
||||
plugin.getLogger().info("Looks like something went wrong");
|
||||
}
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>() {
|
||||
@@ -201,14 +200,15 @@ public class VotingPluginMetrics {
|
||||
}));
|
||||
}
|
||||
if (users > 10000) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users_in_thousands_plus_10", new Callable<String>() {
|
||||
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;
|
||||
}
|
||||
}));
|
||||
@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>() {
|
||||
|
||||
@@ -330,7 +330,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"));
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -7,7 +7,7 @@ import lombok.Getter;
|
||||
public class BungeeMessageData {
|
||||
|
||||
// Message string
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
|
||||
|
||||
@Getter
|
||||
private int allTimeTotal = 0;
|
||||
@@ -21,15 +21,21 @@ public class BungeeMessageData {
|
||||
private int points = 0;
|
||||
@Getter
|
||||
private int weeklyTotal = 0;
|
||||
@Getter
|
||||
private int votePartyCurrent = 0;
|
||||
@Getter
|
||||
private int votePartyRequired = 0;
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
int milestoneCount) {
|
||||
int milestoneCount, int votePartyCurrent, int votePartyRequired) {
|
||||
this.allTimeTotal = allTimeTotal;
|
||||
this.monthTotal = monthTotal;
|
||||
this.weeklyTotal = weeklyTotal;
|
||||
this.dailyTotal = dailyTotal;
|
||||
this.points = points;
|
||||
this.milestoneCount = milestoneCount;
|
||||
this.votePartyCurrent = votePartyCurrent;
|
||||
this.votePartyRequired = votePartyRequired;
|
||||
}
|
||||
|
||||
public BungeeMessageData(String str) {
|
||||
@@ -42,12 +48,16 @@ public class BungeeMessageData {
|
||||
points = Integer.parseInt(data[4]);
|
||||
milestoneCount = Integer.parseInt(data[5]);
|
||||
}
|
||||
if (data.length >= 8) {
|
||||
votePartyCurrent = Integer.parseInt(data[6]);
|
||||
votePartyRequired = Integer.parseInt(data[7]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allTimeTotal + "//" + monthTotal + "//" + weeklyTotal + "//" + dailyTotal + "//" + points + "//"
|
||||
+ milestoneCount;
|
||||
+ milestoneCount + "//" + votePartyCurrent + "//" + votePartyRequired;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,10 @@ public class Config {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public boolean getRedisSupport() {
|
||||
return getData().getBoolean("RedisSupport", false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getData().getString("BungeeServer.Host", "");
|
||||
}
|
||||
@@ -77,6 +81,34 @@ public class Config {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getData().getBoolean("VoteParty.SendToAllServers", true);
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired", 100);
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getData().getStringList("VoteParty.BungeeCommands");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class RedisBungee implements Listener {
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
private VotingPluginBungee plugin;
|
||||
|
||||
public RedisBungee(VotingPluginBungee plugin) {
|
||||
this.plugin = plugin;
|
||||
if (plugin.getConfig().getRedisSupport()) {
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, this);
|
||||
plugin.getLogger().info("Loaded expiremental redis support");
|
||||
enabled = true;
|
||||
} else {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerJoinedNetworkEvent(PlayerJoinedNetworkEvent event) {
|
||||
plugin.login(plugin.getProxy().getPlayer(event.getUuid()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerChangedServerNetworkEventt(PlayerChangedServerNetworkEvent event) {
|
||||
plugin.login(plugin.getProxy().getPlayer(event.getUuid()));
|
||||
}
|
||||
|
||||
public boolean isOnline(ProxiedPlayer p) {
|
||||
return RedisBungeeAPI.getRedisBungeeApi().isPlayerOnline(p.getUniqueId());
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
plugin.getProxy().getPluginManager().unregisterListener(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
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();
|
||||
}
|
||||
@@ -18,6 +18,30 @@ public class VoteCache {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getData().getInt("VoteParty.CurrentVotes", 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotes", 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
getData().set("VoteParty.CurrentVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
getData().set("VoteParty.IncreaseVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
getData().set("VoteParty.Cache." + server, amount);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getData().getInt("VoteParty.Cache." + server, 0);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
Configuration section = getData().getSection("VoteCache." + server + "." + num);
|
||||
section.set("Name", voteData.getPlayerName());
|
||||
|
||||
@@ -20,12 +20,15 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
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.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
@@ -36,10 +39,11 @@ import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
@@ -78,6 +82,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
private boolean votifierEnabled = true;
|
||||
|
||||
@Getter
|
||||
private RedisBungee redis;
|
||||
|
||||
@Getter
|
||||
private TimeHandle timeHandle;
|
||||
|
||||
private ConcurrentHashMap<UUID, String> uuidPlayerNameCache = new ConcurrentHashMap<UUID, String>();
|
||||
|
||||
public synchronized void checkCachedVotes(String server) {
|
||||
if (getProxy().getServerInfo(server) != null) {
|
||||
if (!getProxy().getServerInfo(server).getPlayers().isEmpty()) {
|
||||
@@ -89,7 +101,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
boolean toSend = true;
|
||||
if (getConfig().getWaitForUserOnline()) {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(cache.getUuid()));
|
||||
if (p == null || !p.isConnected()) {
|
||||
if (isOnline(p)) {
|
||||
toSend = false;
|
||||
} else if (p != null && p.isConnected()
|
||||
&& !p.getServer().getInfo().getName().equals(server)) {
|
||||
@@ -102,7 +114,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
} else {
|
||||
debug("Not sending vote because user isn't on server " + server + ": "
|
||||
+ cache.toString());
|
||||
@@ -118,7 +130,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
public synchronized void checkOnlineVotes(ProxiedPlayer player, String uuid, String server) {
|
||||
if (player != null && player.isConnected() && cachedOnlineVotes.containsKey(uuid)) {
|
||||
if (isOnline(player) && cachedOnlineVotes.containsKey(uuid)) {
|
||||
ArrayList<OfflineBungeeVote> c = cachedOnlineVotes.get(uuid);
|
||||
if (!c.isEmpty()) {
|
||||
if (server == null) {
|
||||
@@ -129,7 +141,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
sendPluginMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
@@ -144,6 +156,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
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();
|
||||
@@ -158,7 +173,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
// Parse JSON response and get UUID
|
||||
JsonElement element = new JsonParser().parse(bufferedReader);
|
||||
JsonElement element = JsonParser.parseReader(bufferedReader);
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
String uuidAsString = object.get("id").getAsString();
|
||||
|
||||
@@ -179,6 +194,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
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) {
|
||||
@@ -309,12 +331,16 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
voteCacheFile.save();
|
||||
}
|
||||
timeHandle.save();
|
||||
voteCacheFile.save();
|
||||
nonVotedPlayersCache.save();
|
||||
if (mysql != null) {
|
||||
mysql.shutdown();
|
||||
}
|
||||
if (redis != null) {
|
||||
redis.destroy();
|
||||
}
|
||||
getLogger().info("VotingPlugin disabled");
|
||||
}
|
||||
|
||||
@@ -333,9 +359,16 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -359,15 +392,26 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
if (mysqlLoaded) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
voteCacheFile = new VoteCache(this);
|
||||
voteCacheFile.load();
|
||||
voteCacheFile = new VoteCache(this);
|
||||
voteCacheFile.load();
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(this);
|
||||
nonVotedPlayersCache.load();
|
||||
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());
|
||||
}
|
||||
};
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
try {
|
||||
for (String server : voteCacheFile.getServers()) {
|
||||
@@ -429,7 +473,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() {
|
||||
|
||||
@@ -470,6 +520,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
}
|
||||
|
||||
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
|
||||
@@ -507,8 +560,44 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PostLoginEvent event) {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayer(event.getPlayer());
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public boolean isOnline(ProxiedPlayer p) {
|
||||
if (p != null) {
|
||||
if (redis != null && redis.isEnabled()) {
|
||||
return redis.isOnline(p);
|
||||
} else {
|
||||
return p.isConnected();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void login(ProxiedPlayer p) {
|
||||
if (isOnline(p)) {
|
||||
if (p.getServer() != null && p.getServer().getInfo() != null) {
|
||||
final String server = p.getServer().getInfo().getName();
|
||||
final ProxiedPlayer proixedPlayer = p;
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(proixedPlayer, proixedPlayer.getUniqueId().toString(), server);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,23 +633,17 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
String player = in.readUTF();
|
||||
debug("Login: " + player);
|
||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
||||
if (p != null && p.isConnected()) {
|
||||
if (p.getServer() != null && p.getServer().getInfo() != null) {
|
||||
final String server = p.getServer().getInfo().getName();
|
||||
final ProxiedPlayer proixedPlayer = p;
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(proixedPlayer, proixedPlayer.getUniqueId().toString(), server);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
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);
|
||||
out.writeInt(size);
|
||||
@@ -598,6 +681,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
public void reload(boolean loadMysql) {
|
||||
config.load();
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
if (loadMysql) {
|
||||
try {
|
||||
if (!config.getData().getString("Host", "").isEmpty()) {
|
||||
@@ -708,6 +793,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
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);
|
||||
@@ -731,6 +817,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
BungeeMessageData text = null;
|
||||
|
||||
addVoteParty();
|
||||
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
if (mysql == null) {
|
||||
@@ -738,6 +826,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// one time query to insert player
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", new DataValueString(player));
|
||||
}
|
||||
@@ -750,7 +839,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
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);
|
||||
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)));
|
||||
@@ -761,17 +851,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
debug("Setting totals " + text.toString());
|
||||
mysql.update(uuid, update);
|
||||
} else {
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0);
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
|
||||
}
|
||||
|
||||
/*
|
||||
* String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" +
|
||||
* mysqlUpdate(data, uuid, "MonthTotal", 1) + "//" + mysqlUpdate(data, uuid,
|
||||
* "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1) + "//" +
|
||||
* mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid,
|
||||
* "MilestoneCount", 1);
|
||||
*/
|
||||
|
||||
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
@@ -782,10 +864,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
ServerInfo info = getProxy().getServerInfo(s);
|
||||
boolean forceCache = false;
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if ((p == null || !p.isConnected()) && getConfig().getWaitForUserOnline()) {
|
||||
if (!isOnline(p) && getConfig().getWaitForUserOnline()) {
|
||||
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)) {
|
||||
@@ -802,20 +887,18 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if (p != null && p.isConnected()
|
||||
&& !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
|
||||
if (isOnline(p) && !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
|
||||
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + config.getBroadcast());
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
@@ -829,10 +912,12 @@ 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);
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired);
|
||||
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
@@ -844,4 +929,63 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
}
|
||||
|
||||
private int votePartyVotes = 0;
|
||||
private int currentVotePartyVotesRequired = 0;
|
||||
|
||||
public void addCurrentVotePartyVotes(int amount) {
|
||||
votePartyVotes += amount;
|
||||
voteCacheFile.setVotePartyCurrentVotes(votePartyVotes);
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
}
|
||||
|
||||
public void addVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
addCurrentVotePartyVotes(1);
|
||||
|
||||
if (votePartyVotes >= currentVotePartyVotesRequired) {
|
||||
debug("Vote party reached");
|
||||
addCurrentVotePartyVotes(-currentVotePartyVotesRequired);
|
||||
|
||||
currentVotePartyVotesRequired += getConfig().getVotePartyIncreaseVotesRequired();
|
||||
voteCacheFile.setVotePartyInreaseVotesRequired(voteCacheFile.getVotePartyInreaseVotesRequired()
|
||||
+ getConfig().getVotePartyIncreaseVotesRequired());
|
||||
|
||||
if (!getConfig().getVotePartyBroadcast().isEmpty()) {
|
||||
getProxy().broadcast(new TextComponent(
|
||||
ChatColor.translateAlternateColorCodes('&', getConfig().getVotePartyBroadcast())));
|
||||
}
|
||||
|
||||
for (String command : getConfig().getVotePartyBungeeCommands()) {
|
||||
getProxy().getPluginManager().dispatchCommand(getProxy().getConsole(), command);
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
if (getConfig().getVotePartySendToAllServers()) {
|
||||
for (Entry<String, ServerInfo> entry : getProxy().getServers().entrySet()) {
|
||||
sendVoteParty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
for (String server : getConfig().getVotePartyServersToSend()) {
|
||||
ServerInfo serverInfo = getProxy().getServerInfo(server);
|
||||
if (serverInfo != null) {
|
||||
sendVoteParty(server, serverInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
voteCacheFile.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendVoteParty(String server, ServerInfo serverInfo) {
|
||||
if (!serverInfo.getPlayers().isEmpty()) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(server, "VotePartyBungee");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessageServer(server, "VotePartyBungee");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -18,11 +18,11 @@ 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) {
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
@@ -63,16 +65,44 @@ public class Config extends VelocityYMLFile {
|
||||
return getBoolean(getNode("SendVotesToAllServers"), true);
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getBoolean(getVotePartyNode().getNode("Enabled"), false);
|
||||
}
|
||||
|
||||
public ConfigurationNode getVotePartyNode() {
|
||||
return getNode("VoteParty");
|
||||
}
|
||||
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getBoolean(getVotePartyNode().getNode("SendToAllServers"), false);
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("VotesRequired"), 100);
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("IncreaseVotesRequired"), 0);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getString(getVotePartyNode().getNode("Broadcast"), "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getStringList(getVotePartyNode().getNode("ServersToSend"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getStringList(getVotePartyNode().getNode("BungeeCommands"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public ConfigurationNode getSpigotServerConfiguration(String s) {
|
||||
return getNode("SpigotServers", s);
|
||||
}
|
||||
|
||||
public Collection<String> getSpigotServers() {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (ConfigurationNode conf : getNode("SpigotServers").getChildrenList()) {
|
||||
list.add(conf.getKey().toString());
|
||||
}
|
||||
return list;
|
||||
public @NonNull Collection<? extends ConfigurationNode> getSpigotServers() {
|
||||
return getNode("SpigotServers").getChildrenMap().values();
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
|
||||
@@ -14,6 +14,30 @@ public class VoteCache extends VelocityYMLFile {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getInt(getNode("VoteParty").getNode("CurrentVotes"), 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getInt(getNode("VoteParty").getNode("IncreaseVotes"), 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
getNode("VoteParty").getNode("CurrentVotes").setValue(amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
getNode("VoteParty").getNode("IncreaseVotes").setValue(amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
getNode("VoteParty").getNode("Cache").getNode(server).setValue(amount);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getNode("VoteParty").getNode("Cache").getNode(server).getInt(0);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
String[] path = new String[] { "VoteCache", server, "" + num };
|
||||
|
||||
|
||||
+148
-23
@@ -20,13 +20,16 @@ import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
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.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -36,6 +39,7 @@ 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.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
@@ -48,9 +52,9 @@ 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.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
@@ -107,6 +111,11 @@ public class VotingPluginVelocity {
|
||||
|
||||
private Timer timer;
|
||||
|
||||
@Getter
|
||||
private TimeHandle timeHandle;
|
||||
|
||||
private ConcurrentHashMap<UUID, String> uuidPlayerNameCache = new ConcurrentHashMap<UUID, String>();
|
||||
|
||||
@Inject
|
||||
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
|
||||
@DataDirectory Path dataDirectory) {
|
||||
@@ -143,7 +152,7 @@ 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());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
} else {
|
||||
debug("Not sending vote because user isn't on server " + serverToCheck + ": "
|
||||
+ cache.toString());
|
||||
@@ -169,7 +178,7 @@ public class VotingPluginVelocity {
|
||||
sendPluginMessageServer(serverToCheck, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
@@ -198,7 +207,7 @@ public class VotingPluginVelocity {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
// Parse JSON response and get UUID
|
||||
JsonElement element = new JsonParser().parse(bufferedReader);
|
||||
JsonElement element = JsonParser.parseReader(bufferedReader);
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
String uuidAsString = object.get("id").getAsString();
|
||||
|
||||
@@ -223,6 +232,11 @@ public class VotingPluginVelocity {
|
||||
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) {
|
||||
@@ -333,6 +347,14 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
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
|
||||
@@ -374,9 +396,11 @@ public class VotingPluginVelocity {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
voteCacheFile.save();
|
||||
}
|
||||
if (timeHandle != null) {
|
||||
timeHandle.save();
|
||||
}
|
||||
voteCacheFile.save();
|
||||
nonVotedPlayersCache.save();
|
||||
if (mysql != null) {
|
||||
mysql.shutDown();
|
||||
@@ -431,14 +455,24 @@ public class VotingPluginVelocity {
|
||||
server.getCommandManager().register(meta, new VotingPluginVelocityCommand(this));
|
||||
|
||||
if (mysqlLoaded) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(
|
||||
new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
|
||||
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());
|
||||
}
|
||||
};
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
try {
|
||||
for (String serverToCheck : voteCacheFile.getServers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
@@ -480,7 +514,9 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
for (String player : cachedOnlineVotes.keySet()) {
|
||||
checkOnlineVotes(server.getPlayer(UUID.fromString(player)).get(), player, null);
|
||||
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();
|
||||
|
||||
@@ -495,7 +531,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() {
|
||||
|
||||
@@ -528,16 +570,20 @@ public class VotingPluginVelocity {
|
||||
|
||||
clientHandles = new HashMap<String, ClientHandler>();
|
||||
List<String> l = config.getBlockedServers();
|
||||
for (String s : config.getSpigotServers()) {
|
||||
for (ConfigurationNode d : config.getSpigotServers()) {
|
||||
String s = d.getKey().toString();
|
||||
if (!l.contains(s)) {
|
||||
ConfigurationNode d = config.getSpigotServerConfiguration(s);
|
||||
clientHandles.put(s, new ClientHandler(d.getNode("Host").getString(""),
|
||||
clientHandles.put(s, new ClientHandler(d.getNode("Host").getString("0.0.0.0"),
|
||||
d.getNode("Port").getInt(1298), encryptionHandler, config.getDebug()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
|
||||
try {
|
||||
getVersionFile();
|
||||
if (versionFile != null) {
|
||||
@@ -671,6 +717,8 @@ public class VotingPluginVelocity {
|
||||
|
||||
public void reload(boolean loadMySQL) {
|
||||
config.reload();
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
if (loadMySQL) {
|
||||
if (!config.getString(config.getNode("Host"), "").isEmpty()) {
|
||||
loadMysql();
|
||||
@@ -776,6 +824,7 @@ public class VotingPluginVelocity {
|
||||
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);
|
||||
@@ -799,6 +848,8 @@ public class VotingPluginVelocity {
|
||||
|
||||
BungeeMessageData text = null;
|
||||
|
||||
addVoteParty();
|
||||
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
if (mysql == null) {
|
||||
@@ -818,7 +869,8 @@ public class VotingPluginVelocity {
|
||||
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);
|
||||
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)));
|
||||
@@ -829,7 +881,7 @@ public class VotingPluginVelocity {
|
||||
debug("Setting totals " + text.toString());
|
||||
mysql.update(uuid, update);
|
||||
} else {
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0);
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -872,7 +924,7 @@ public class VotingPluginVelocity {
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
@@ -880,12 +932,16 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Player p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
Player p = null;
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
}
|
||||
if (p != null && p.isActive() && !config.getBlockedServers()
|
||||
.contains(p.getCurrentServer().get().getServerInfo().getName())) {
|
||||
sendPluginMessageServer(p.getCurrentServer().get().getServer(), "VoteOnline", player, uuid,
|
||||
service, "" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + config.getBroadcast());
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
@@ -900,7 +956,8 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid);
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired);
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
@@ -913,4 +970,72 @@ public class VotingPluginVelocity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private int votePartyVotes = 0;
|
||||
private int currentVotePartyVotesRequired = 0;
|
||||
|
||||
public void addCurrentVotePartyVotes(int amount) {
|
||||
votePartyVotes += amount;
|
||||
voteCacheFile.setVotePartyCurrentVotes(votePartyVotes);
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
}
|
||||
|
||||
public void addVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
addCurrentVotePartyVotes(1);
|
||||
|
||||
if (votePartyVotes >= currentVotePartyVotesRequired) {
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
addCurrentVotePartyVotes(-currentVotePartyVotesRequired);
|
||||
|
||||
currentVotePartyVotesRequired += getConfig().getVotePartyIncreaseVotesRequired();
|
||||
voteCacheFile.setVotePartyInreaseVotesRequired(voteCacheFile.getVotePartyInreaseVotesRequired()
|
||||
+ getConfig().getVotePartyIncreaseVotesRequired());
|
||||
|
||||
if (!getConfig().getVotePartyBroadcast().isEmpty()) {
|
||||
for (RegisteredServer server : getVotePartyServers()) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(server, "VotePartyBroadcast", config.getVotePartyBroadcast());
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessageServer(server.getServerInfo().getName(), config.getVotePartyBroadcast());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String command : getConfig().getVotePartyBungeeCommands()) {
|
||||
server.getCommandManager().executeAsync(server.getConsoleCommandSource(), command);
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (RegisteredServer server : getVotePartyServers()) {
|
||||
sendVoteParty(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
voteCacheFile.save();
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<RegisteredServer> getVotePartyServers() {
|
||||
if (getConfig().getVotePartySendToAllServers()) {
|
||||
return server.getAllServers();
|
||||
}
|
||||
Collection<RegisteredServer> list = new ArrayList<RegisteredServer>();
|
||||
for (String server : getConfig().getVotePartyServersToSend()) {
|
||||
if (this.server.getServer(server).isPresent()) {
|
||||
list.add(this.server.getServer(server).get());
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void sendVoteParty(RegisteredServer server) {
|
||||
if (!server.getPlayersConnected().isEmpty()) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(server, "VotePartyBungee");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessageServer(server.getServerInfo().getName(), "VotePartyBungee");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -318,6 +317,16 @@ public class CommandLoader {
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, true);
|
||||
}
|
||||
} else {
|
||||
if (user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender,
|
||||
"&cMilestone " + num + " for " + user.getPlayerName()
|
||||
+ " already given when it shouldn't be, Current AllTimeTotal: "
|
||||
+ user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: "
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,12 +372,13 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
int newTotal = 0;
|
||||
synchronized (pointLock) {
|
||||
user.addPoints(Integer.parseInt(args[3]));
|
||||
newTotal = user.addPoints(Integer.parseInt(args[3]));
|
||||
}
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3]
|
||||
+ " points" + ", " + args[1] + " now has " + user.getPoints() + " points"));
|
||||
+ " points" + ", " + args[1] + " now has " + newTotal + " points"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -379,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"));
|
||||
@@ -428,7 +438,6 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int page = Integer.parseInt(args[1]);
|
||||
new AdminVoteHelp(plugin, sender, page).open();
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
@@ -900,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) {
|
||||
|
||||
@@ -1153,16 +1188,6 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "SetVotePartyCount", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVotePartyCount|" + adminPerm, "Set voteparty count") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
plugin.getVoteParty().setTotalVotes(Integer.parseInt(args[1]));
|
||||
sendMessage(sender, "&cSet vote party count to " + args[1]);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ClearOfflineVotes" },
|
||||
"VotingPlugin.Commands.AdminVote.ClearOfflineVotes|" + adminPerm, "Clear all offline votes") {
|
||||
|
||||
@@ -1212,8 +1237,8 @@ public class CommandLoader {
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "ForceVoteParty" },
|
||||
"VotingPlugin.Commands.AdminVote.ForceVoteParty|" + adminPerm,
|
||||
.add(new CommandHandler(new String[] { "VoteParty", "Force" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.Force|" + adminPerm,
|
||||
"Force a voteparty reward, resets vote count") {
|
||||
|
||||
@Override
|
||||
@@ -1222,8 +1247,34 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "SetVoteCount", "(Number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.SetVoteCount|" + adminPerm, "Set voteparty count") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int num = Integer.parseInt(args[2]);
|
||||
if (num == 0) {
|
||||
plugin.getVoteParty().reset(true);
|
||||
sendMessage(sender, "&cVoteparty totals have been set to 0 and all been reset");
|
||||
} else {
|
||||
plugin.getVoteParty().setTotalVotes(num);
|
||||
sendMessage(sender, "&cVoteparty total votes has been set to " + args[2]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "AddVoteCount", "(Number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.SetVoteCount|" + adminPerm, "Add voteparty count") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int num = plugin.getVoteParty().getTotalVotes() + Integer.parseInt(args[2]);
|
||||
plugin.getVoteParty().setTotalVotes(num);
|
||||
sendMessage(sender, "&cVoteparty total votes has been set to " + num);
|
||||
}
|
||||
});
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "VotePartyExtraRequired", "(Number)" },
|
||||
.add(new CommandHandler(new String[] { "VoteParty", "SetExtraRequired", "(Number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.SetExtraRequired|" + adminPerm,
|
||||
"Set VotePartyExtraRequired value") {
|
||||
|
||||
@@ -1241,7 +1292,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");
|
||||
}
|
||||
@@ -1380,7 +1431,7 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
new AdminVotePlaceholdersPlayer(plugin, sender,
|
||||
UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1499,7 +1550,6 @@ public class CommandLoader {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1734,6 +1784,26 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getVoteCommand().add(new CommandHandler(new String[] { "ToggleReminders" },
|
||||
"VotingPlugin.Commands.Vote.ToggleReminders", "Enable/disable vote reminders", false) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player p = (Player) sender;
|
||||
boolean value = false;
|
||||
if (plugin.getVoteReminding().getRemindersEnabled().containsKey(p.getUniqueId())) {
|
||||
value = !plugin.getVoteReminding().getRemindersEnabled().get(p.getUniqueId());
|
||||
}
|
||||
plugin.getVoteReminding().getRemindersEnabled().put(p.getUniqueId(), value);
|
||||
|
||||
if (value) {
|
||||
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleRemindersEnabled());
|
||||
} else {
|
||||
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleRemindersDisabled());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteShopEnabled()) {
|
||||
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Shop" },
|
||||
"VotingPlugin.Commands.Vote.Shop|" + playerPerm, "Open VoteShop GUI", false) {
|
||||
@@ -1783,7 +1853,7 @@ public class CommandLoader {
|
||||
|
||||
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
|
||||
if (hasPerm) {
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
|
||||
@@ -1794,7 +1864,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));
|
||||
|
||||
@@ -1966,7 +2036,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,
|
||||
@@ -2003,7 +2073,8 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
new VoteTopVoter(plugin, sender, null, top, 1).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
new VoteTopVoter(plugin, sender, null, top, 1)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2013,7 +2084,8 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int page = Integer.parseInt(args[2]);
|
||||
new VoteTopVoter(plugin, sender, null, top, page).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
new VoteTopVoter(plugin, sender, null, top, page)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2025,7 +2097,8 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int page = Integer.parseInt(args[1]);
|
||||
|
||||
new VoteTopVoter(plugin, sender, null, TopVoter.getDefault(), page).open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
new VoteTopVoter(plugin, sender, null, TopVoter.getDefault(), page)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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,7 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("AllSites"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("AllSites"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -136,7 +136,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 +145,16 @@ public class AdminGUI {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("EverySiteReward"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("EverySiteReward"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit BungeeVotePartyRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("BungeeVotePartyRewards"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -355,7 +364,7 @@ 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"));
|
||||
}
|
||||
});
|
||||
|
||||
+9
@@ -95,6 +95,15 @@ public class AdminVoteBungeeSettings extends GUIHandler {
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerMilestones", plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerPoints", plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
|
||||
|
||||
+3
-2
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -53,7 +54,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
@@ -92,7 +93,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
|
||||
+7
-8
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -43,7 +44,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user.getOfflinePlayer(), user, identifier);
|
||||
String value = placeholder.placeholderRequest(user, identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
@@ -51,13 +52,13 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user.getOfflinePlayer(), user, identifier);
|
||||
String value = placeholder.placeholderRequest(identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -81,18 +82,16 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
msg.add("VotingPlugin_" + identifier + " = "
|
||||
+ placeholder.placeholderRequest(user.getOfflinePlayer(), placeholderUser, identifier));
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
|
||||
msg.add("VotingPlugin_" + identifier + " = "
|
||||
+ placeholder.placeholderRequest(user.getOfflinePlayer(), placeholderUser, identifier));
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
+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.api.valuerequest.ValueRequestBuilder;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
@@ -93,7 +92,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}, new Number[] { 0, 10, 50, 100 })
|
||||
.currentValue("" + plugin.getServerData().getVotePartyExtraRequired()).allowCustomOption(true)
|
||||
.request(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-3
@@ -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,12 +67,12 @@ 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)
|
||||
.request(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class AdminVoteCumulativeRemove extends GUIHandler {
|
||||
new AdminVoteCumulative(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
new AdminVoteMilestones(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+2
-3
@@ -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,12 +67,12 @@ 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)
|
||||
.request(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+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.command.gui.RewardEditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
@@ -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"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
new AdminVoteVoteShop(plugin, p).open();
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ public class AdminVoteVoteShopItems extends GUIHandler {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteShopItem(plugin, clickEvent.getPlayer(), (String) getData("ident"))
|
||||
.open(GUIMethod.CHEST);
|
||||
;
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
}
|
||||
|
||||
@@ -87,6 +87,10 @@ public class VoteBest extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteBestBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -128,6 +127,12 @@ public class VoteGUI extends GUIHandler {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (player.getUniqueId().toString().equals(user.getUUID())) {
|
||||
inv.requirePermission("VotingPlugin.Commands.Vote.GUI");
|
||||
} else {
|
||||
inv.requirePermission("VotingPlugin.Commands.Vote.GUI.Other");
|
||||
}
|
||||
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
@@ -171,12 +176,16 @@ public class VoteGUI extends GUIHandler {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -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;
|
||||
@@ -51,7 +50,11 @@ public class VoteShop extends GUIHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
@@ -61,14 +64,17 @@ 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);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
@@ -114,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));
|
||||
|
||||
@@ -131,7 +137,7 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
} else {
|
||||
new VoteShopConfirm(plugin, player, user, identifier).open(GUIMethod.CHEST);
|
||||
;
|
||||
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -93,7 +92,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user);
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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());
|
||||
@@ -104,8 +104,8 @@ public class VoteTopVoter extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (plugin.getGui().getChestVoteTopOpenMainGUIOnClick()) {
|
||||
VotingPluginUser user = (VotingPluginUser) getData("User");
|
||||
new VoteGUI(plugin, player, user)
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
} else {
|
||||
getInv().forceClose(clickEvent.getPlayer());
|
||||
|
||||
+2
-2
@@ -74,8 +74,8 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = (VotingPluginUser) getData("User");
|
||||
new VoteGUI(plugin, player, user)
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
|
||||
@@ -223,7 +223,7 @@ public class VoteURL extends GUIHandler {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(), "CHEST.VoteURL.ExtraItems." + str + ".Rewards")
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -41,6 +41,10 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private boolean perServerPoints = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerMilestones")
|
||||
@Getter
|
||||
private boolean perServerMilestones = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerRewards")
|
||||
@Getter
|
||||
private boolean perServerRewards = false;
|
||||
|
||||
@@ -41,10 +41,18 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean preloadSkulls = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCachePlaceholders")
|
||||
@Getter
|
||||
private boolean autoCachePlaceholders = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
@ConfigDataInt(path = "PlayerDataLoadLimit")
|
||||
@Getter
|
||||
private int playerDataLoadLimit = -1;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
@@ -81,10 +89,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;
|
||||
@@ -101,6 +105,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<String>();
|
||||
|
||||
@ConfigDataListString(path = "CachedPlaceholders")
|
||||
@Getter
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
|
||||
@ConfigDataBoolean(path = "DisableInteractEvent")
|
||||
@Getter
|
||||
private boolean disableInteractEvent = false;
|
||||
@@ -117,6 +125,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean extraAllSitesCheck = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CloseInventoryOnVote")
|
||||
@Getter
|
||||
private boolean closeInventoryOnVote = true;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraBackgroundUpdate")
|
||||
@Getter
|
||||
private boolean extraBackgroundUpdate = false;
|
||||
@@ -133,6 +145,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;
|
||||
@@ -170,6 +190,14 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastEnabled = "&cYou will now see vote broadcasts";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleReminders.Disabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleRemindersDisabled = "&cVote reminders disabled";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleReminders.Enabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleRemindersEnabled = "&cVote reminders enabled";
|
||||
|
||||
@Getter
|
||||
private int formatPageSize = 10;
|
||||
|
||||
|
||||
@@ -74,6 +74,10 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private boolean chestVoteShopRequireConfirmation = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteBest.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteBestBackButton = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteToday.IconTitle")
|
||||
@Getter
|
||||
private String chestVoteTodayIconTitle = "%player%";
|
||||
|
||||
@@ -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;
|
||||
@@ -34,6 +35,10 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private boolean enableWeeklyAwards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "OnlyOneCumulative")
|
||||
@Getter
|
||||
private boolean onlyOneCumulative = false;
|
||||
|
||||
@Getter
|
||||
private String firstVoteRewardsPath = "FirstVote";
|
||||
|
||||
@@ -87,6 +92,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.
|
||||
*
|
||||
@@ -349,8 +362,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();
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ 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;
|
||||
@@ -34,7 +33,7 @@ public class CoolDownCheck implements Listener {
|
||||
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 {
|
||||
@@ -110,7 +109,7 @@ public class CoolDownCheck implements Listener {
|
||||
|
||||
@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());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.bencodez.votingplugin.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -24,6 +25,23 @@ public class ServerData {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addAutoCachedPlaceholder(String placeholder) {
|
||||
List<String> p = getAutoCachedPlaceholder();
|
||||
if (!p.contains(placeholder)) {
|
||||
p.add(placeholder);
|
||||
setAutoCachedPlaceholder(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public List<String> getAutoCachedPlaceholder() {
|
||||
return getData().getStringList("AutoCachePlaceholders");
|
||||
}
|
||||
|
||||
public synchronized void addServiceSite(String site) {
|
||||
ArrayList<String> l = getServiceSites();
|
||||
if (!getServiceSites().contains(site)) {
|
||||
@@ -246,6 +264,24 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyRequired() {
|
||||
return getData().getInt("BungeeVotePartyRequired");
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyCurrent(int current) {
|
||||
getData().set("BungeeVotePartyCurrent", current);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyRequired(int required) {
|
||||
getData().set("BungeeVotePartyRequired", required);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerPostVoteEvent 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 bungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private BungeeMessageData bungeeTextTotals;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean forceBungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser user;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean realVote = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee) {
|
||||
super(true);
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
this.realVote = realVote;
|
||||
this.forceBungee = forceBungee;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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,13 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import java.util.TimerTask;
|
||||
|
||||
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 +21,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 +29,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 +62,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().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
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.TimerTask;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -13,6 +15,7 @@ import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -44,6 +47,9 @@ public class PlayerVoteListener implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onplayerVote(PlayerVoteEvent event) {
|
||||
if (!plugin.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
String playerName = event.getPlayer();
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
if (!plugin.getConfigFile().isAllowUnjoined()) {
|
||||
@@ -103,22 +109,25 @@ public class PlayerVoteListener implements Listener {
|
||||
user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
}
|
||||
|
||||
// reupdate cache
|
||||
user.clearCache();
|
||||
|
||||
user.updateName(true);
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
if (!plugin.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
// reupdate cache
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
user.updateName(true);
|
||||
|
||||
// vote party
|
||||
plugin.getVoteParty().vote(user, event.isRealVote(), event.isForceBungee());
|
||||
|
||||
if (event.isBroadcast() && !plugin.getBungeeSettings().isDisableBroadcast() ) {
|
||||
if (event.isBroadcast() && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
// broadcast vote if enabled in config
|
||||
if (plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& (plugin.getBungeeSettings().isBungeeBroadcast() || !event.isBungee())) {
|
||||
@@ -143,8 +152,7 @@ public class PlayerVoteListener implements Listener {
|
||||
// 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();
|
||||
@@ -160,16 +168,17 @@ 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);
|
||||
user.closeInv();
|
||||
if (plugin.getConfigFile().isCloseInventoryOnVote()) {
|
||||
user.closeInv();
|
||||
}
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
plugin.debug(
|
||||
@@ -193,9 +202,10 @@ public class PlayerVoteListener implements Listener {
|
||||
plugin.getSpecialRewards().checkCumualativeVotes(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkMilestone(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
|
||||
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
|
||||
@@ -207,9 +217,23 @@ 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);
|
||||
|
||||
plugin.getTimer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
}
|
||||
}, 1000 * 5);
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -52,13 +52,6 @@ public class VotiferEvent implements Listener {
|
||||
// ignore own plugin calls of event
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServerData().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
@@ -72,11 +65,11 @@ public class VotiferEvent implements Listener {
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
plugin.debug("IP: " + IP);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getVoteTimer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
plugin.getServerData().addServiceSite(voteSite);
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getBungeeSettings().isVotifierBypass()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
|
||||
@@ -89,7 +82,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 {
|
||||
@@ -117,7 +110,7 @@ public class VotiferEvent implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.bencodez.votingplugin.placeholders;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -46,7 +47,7 @@ public class MVdWPlaceholders {
|
||||
&& user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
return place.placeholderRequest(event.getOfflinePlayer(), user,
|
||||
return place.placeholderRequest(user,
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ public class MVdWPlaceholders {
|
||||
|
||||
}
|
||||
|
||||
for (final PlaceHolder<VotingPluginUser> place : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (final NonPlayerPlaceHolder<VotingPluginUser> place : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String str = place.getIdentifier();
|
||||
if (!str.endsWith("_")) {
|
||||
PlaceholderAPI.registerPlaceholder(VotingPluginMain.plugin, "VotingPlugin_" + str,
|
||||
@@ -63,7 +64,7 @@ public class MVdWPlaceholders {
|
||||
|
||||
@Override
|
||||
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
|
||||
return place.placeholderRequest(event.getOfflinePlayer(), null,
|
||||
return place.placeholderRequest(
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,15 +5,23 @@ import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserDataChanged;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
@@ -30,7 +38,7 @@ import lombok.Getter;
|
||||
public class PlaceHolders {
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<PlaceHolder<VotingPluginUser>>();
|
||||
private ArrayList<NonPlayerPlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<NonPlayerPlaceHolder<VotingPluginUser>>();
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder<VotingPluginUser>> placeholders = new ArrayList<PlaceHolder<VotingPluginUser>>();
|
||||
@@ -41,41 +49,69 @@ public class PlaceHolders {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
|
||||
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
return getPlaceHolder(p, identifier, true);
|
||||
}
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier, boolean javascript) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript && p != null) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, null, identifier);
|
||||
if (!identifier.endsWith("Position")) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
String str = placeholder.placeholderRequest(identifier);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p == null) {
|
||||
return "no player";
|
||||
}
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
|
||||
user.setWaitForCache(false);
|
||||
if (!user.isCached()) {
|
||||
user.loadCache();
|
||||
return "..";
|
||||
if (!cachedPlaceholders.contains(identifier)) {
|
||||
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
|
||||
user.setWaitForCache(false);
|
||||
if (!user.isCached()) {
|
||||
user.loadCache();
|
||||
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
}
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()) {
|
||||
if (user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
try {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, user, identifier);
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
} else {
|
||||
return "....";
|
||||
}
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.debug(e);
|
||||
return "...";
|
||||
return "Error";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +122,7 @@ public class PlaceHolders {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier, false);
|
||||
return getPlaceHolder(p, identifier, false);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -97,54 +133,54 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("total") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getTotal(TopVoter.Monthly));
|
||||
}
|
||||
}.withDescription("Month total"));
|
||||
}.withDescription("Month total").updateDataKey("MonthTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("alltimetotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getTotal(TopVoter.AllTime));
|
||||
}
|
||||
}.withDescription("Alltime total"));
|
||||
}.withDescription("Alltime total").updateDataKey("AllTimeTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("lastmonthtotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getLastMonthTotal());
|
||||
}
|
||||
}.withDescription("Last month total"));
|
||||
}.withDescription("Last month total").updateDataKey("LastMonthTotal"));
|
||||
|
||||
// end of older placeholders
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("DisableBroadcast") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getDisableBroadcast();
|
||||
}
|
||||
}.withDescription("Returns true/false if user has broadcast disabled"));
|
||||
}.withDescription("Returns true/false if user has broadcast disabled").updateDataKey("DisableBroadcast"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("MilestoneCount") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getMilestoneCount();
|
||||
}
|
||||
}.withDescription("User milestonecount"));
|
||||
}.withDescription("User milestonecount").updateDataKey("MilestoneCount"));
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestShopIdentifierLimit(identifier) > 0) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String ident) {
|
||||
public String placeholderRequest(VotingPluginUser user, String ident) {
|
||||
return "" + user.getVoteShopIdentifierLimit(identifier);
|
||||
}
|
||||
}.withDescription("User voteshop limit for " + identifier));
|
||||
}.withDescription("User voteshop limit for " + identifier).updateDataKey("VoteShopLimit" + identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,121 +188,121 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Total_" + top.toString()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getTotal(top));
|
||||
}
|
||||
}.withDescription("User total for " + top.getName()));
|
||||
}.withDescription("User total for " + top.getName()).updateDataKey(top.getColumnName()));
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestDailyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getHighestDailyTotal());
|
||||
}
|
||||
}.withDescription("Best daily total"));
|
||||
}.withDescription("Best daily total").updateDataKey("HighestDailyTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestWeeklyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getHighestWeeklyTotal());
|
||||
}
|
||||
}.withDescription("Best weekly total"));
|
||||
}.withDescription("Best weekly total").updateDataKey("HighestWeeklyTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestMonthlyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getHighestMonthlyTotal());
|
||||
}
|
||||
}.withDescription("Best monthly total"));
|
||||
}.withDescription("Best monthly total").updateDataKey("HighestMonthlyTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("DailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getDayVoteStreak());
|
||||
}
|
||||
}.withDescription("Current daily votestreak"));
|
||||
}.withDescription("Current daily votestreak").updateDataKey("DayVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("WeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getWeekVoteStreak());
|
||||
}
|
||||
}.withDescription("Current weekly votestreak"));
|
||||
}.withDescription("Current weekly votestreak").updateDataKey("WeekVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("MonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getMonthVoteStreak());
|
||||
}
|
||||
}.withDescription("Current month votestreak"));
|
||||
}.withDescription("Current month votestreak").updateDataKey("MonthVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestDailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getBestDayVoteStreak());
|
||||
}
|
||||
}.withDescription("Best daily votestreak"));
|
||||
}.withDescription("Best daily votestreak").updateDataKey("BestDayVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestWeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getBestWeekVoteStreak());
|
||||
}
|
||||
}.withDescription("Best weekly votestreak"));
|
||||
}.withDescription("Best weekly votestreak").updateDataKey("BestWeekVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestMonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getBestMonthVoteStreak());
|
||||
}
|
||||
}.withDescription("Best month votestreak"));
|
||||
}.withDescription("Best month votestreak").updateDataKey("BestMonthVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Points") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
}.withDescription("User points"));
|
||||
}.withDescription("User points").updateDataKey("Points"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Points_Format") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||
return numberFormat.format(user.getPoints());
|
||||
}
|
||||
}.withDescription("User points"));
|
||||
}.withDescription("User points").updateDataKey("Points"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVote") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Boolean.toString(user.canVoteAll());
|
||||
}
|
||||
}.withDescription("Return true/false if player can vote on all sites"));
|
||||
}.withDescription("Return true/false if player can vote on all sites").updateDataKey("LastVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVoteSites") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getSitesNotVotedOn();
|
||||
}
|
||||
}.withDescription("Return number of votesites available"));
|
||||
}.withDescription("Return number of votesites available").updateDataKey("LastVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_AnySite") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
if (user.canVoteAny()) {
|
||||
return plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
|
||||
}
|
||||
@@ -290,39 +326,40 @@ public class PlaceHolders {
|
||||
|
||||
return "Error";
|
||||
}
|
||||
}.withDescription("How long until user can vote on anysite"));
|
||||
}.withDescription("How long until user can vote on anysite").updateDataKey("LastVotes"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return user.voteCommandNextInfo(voteSite);
|
||||
}
|
||||
}.withDescription("How long until user can vote on " + voteSite.getKey()));
|
||||
}.withDescription("How long until user can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Last_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return user.voteCommandLastDuration(voteSite);
|
||||
}
|
||||
}.withDescription("How long ago user voted on " + voteSite.getKey()));
|
||||
}.withDescription("How long ago user voted on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVote_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.canVoteSite(voteSite);
|
||||
}
|
||||
}.withDescription("Whether or not player can vote on " + voteSite.getKey()));
|
||||
}.withDescription("Whether or not player can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_All_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -331,10 +368,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_AllVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_AllVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
@@ -347,10 +384,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_All_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_All_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
@@ -366,10 +406,11 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Month_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -378,10 +419,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Month_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Month_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
@@ -394,10 +438,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_MonthVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_MonthVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
@@ -413,10 +457,11 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Week_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -425,10 +470,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Week_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Week_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
@@ -441,10 +489,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_WeekVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_WeekVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
@@ -460,10 +508,11 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Daily_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -472,10 +521,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Daily_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Daily_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (!StringParser.getInstance().isInt(identifier.split("_")[2])) {
|
||||
return null;
|
||||
}
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
@@ -491,15 +543,15 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VotePartyContributedVotes") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getVotePartyVotes();
|
||||
}
|
||||
}.useStartsWith().withDescription("See vote party placeholders contributed"));
|
||||
}.useStartsWith().withDescription("See vote party placeholders contributed").updateDataKey("VotePartyVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_DailyVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_DailyVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
@@ -514,34 +566,68 @@ public class PlaceHolders {
|
||||
|
||||
// non players
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("VotePartyVotesCurrent") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("VotePartyVotesCurrent") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
return Integer.toString(plugin.getVoteParty().getTotalVotes());
|
||||
}
|
||||
}.withDescription("Current amount of voteparty votes"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("VotePartyVotesNeeded") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("VotePartyVotesNeeded") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
return Integer.toString(plugin.getVoteParty().getNeededVotes());
|
||||
}
|
||||
}.withDescription("Voteparty votes needed"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("VotePartyVotesRequired") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("VotePartyVotesRequired") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
return Integer.toString(plugin.getVoteParty().getVotesRequired());
|
||||
}
|
||||
}.withDescription("Amount of votes needed for voteparty"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalMonthTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("BungeeVotePartyVotesCurrent") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyCurrent());
|
||||
}
|
||||
return "" + 0;
|
||||
}
|
||||
}.withDescription("Current amount of bungee voteparty votes"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("BungeeVotePartyVotesNeeded") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired()
|
||||
- plugin.getBungeeHandler().getBungeeVotePartyCurrent());
|
||||
}
|
||||
return "" + 0;
|
||||
}
|
||||
}.withDescription("Voteparty bungee votes needed"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("BungeeVotePartyVotesRequired") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired());
|
||||
}
|
||||
return "" + 0;
|
||||
}
|
||||
}.withDescription("Amount of votes needed for bungee voteparty"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalMonthTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.Monthly).values()) {
|
||||
total += num;
|
||||
@@ -550,10 +636,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global month total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalAllTimeTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalAllTimeTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.AllTime).values()) {
|
||||
total += num;
|
||||
@@ -562,10 +648,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global alltime total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalWeeklyTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalWeeklyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.Weekly).values()) {
|
||||
total += num;
|
||||
@@ -574,10 +660,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global weekly total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalDailyTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalDailyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.Daily).values()) {
|
||||
total += num;
|
||||
@@ -586,10 +672,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global daily total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("TimeUntilDayReset") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("TimeUntilDayReset") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0);
|
||||
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0)
|
||||
@@ -623,5 +709,167 @@ public class PlaceHolders {
|
||||
|
||||
}
|
||||
}.withDescription("Time until plugin time day changes"));
|
||||
|
||||
Set<String> placeholdersSet = new HashSet<String>();
|
||||
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
|
||||
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
|
||||
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
|
||||
}
|
||||
|
||||
for (String toCache : placeholdersSet) {
|
||||
if (toCache.startsWith("VotingPlugin")) {
|
||||
toCache = toCache.substring("VotingPlugin_".length());
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getUserManager().getUserDataChange().add(new UserDataChanged() {
|
||||
|
||||
@Override
|
||||
public void onChange(AdvancedCoreUser user, String... keys) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String key : keys) {
|
||||
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
|
||||
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
|
||||
user.dontCache();
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(),
|
||||
placeholder.placeholderRequest(vpUser, ident));
|
||||
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on " + key);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onVotePartyUpdate() {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("VoteParty")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBungeeVotePartyUpdate() {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("BungeeVoteParty")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll();
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
}
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
if (ident != null) {
|
||||
String str = placeholder.placeholderRequest(ident);
|
||||
if (str != null) {
|
||||
placeholder.getCache().put(ident, str);
|
||||
}
|
||||
} else {
|
||||
plugin.debug("ident null: " + placeholder.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
@@ -58,7 +58,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,17 +87,38 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
if (gotCumulative) {
|
||||
gotCumulativeAny = true;
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired + ", total: "
|
||||
+ top.toString() + ", current total: " + total);
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired, forceBungee);
|
||||
if (!plugin.getSpecialRewardsConfig().isOnlyOneCumulative() || !gotCumulativeAny) {
|
||||
gotCumulativeAny = true;
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired + ", total: "
|
||||
+ top.toString() + ", current total: " + total);
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired, forceBungee);
|
||||
} else {
|
||||
plugin.debug("Already got one cumulative");
|
||||
}
|
||||
} else {
|
||||
plugin.devDebug(user.getPlayerName() + " not able to get cumulative " + votesRequired
|
||||
+ ", total required: " + top.toString() + ", current player total: " + total);
|
||||
@@ -112,7 +133,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);
|
||||
@@ -124,7 +145,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);
|
||||
@@ -177,7 +198,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;
|
||||
@@ -187,6 +208,8 @@ public class SpecialRewards {
|
||||
plugin.debug(user.getPlayerName() + " got milestone " + votesRequired);
|
||||
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Milestone " + votesRequired + " not enabled or has no rewards");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -211,7 +234,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")) {
|
||||
@@ -255,7 +278,7 @@ 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));
|
||||
}
|
||||
@@ -281,7 +304,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));
|
||||
}
|
||||
@@ -293,7 +316,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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -335,7 +335,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();
|
||||
|
||||
@@ -23,7 +23,7 @@ public class TopVoterPlayer {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
|
||||
public ItemStack getPlayerHead() {
|
||||
return PlayerUtils.getInstance().getPlayerSkull(getPlayerName(), false);
|
||||
}
|
||||
|
||||
@@ -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,13 +185,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,13 +204,7 @@ 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);
|
||||
}
|
||||
});
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,12 +290,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
ArrayList<Integer> days = new ArrayList<Integer>();
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time != 0) {
|
||||
months.add(MiscUtils.getInstance().getMonthFromMili(time));
|
||||
days.add(MiscUtils.getInstance().getDayFromMili(time));
|
||||
} else {
|
||||
return false;
|
||||
if (voteSite.isEnabled() && !voteSite.isHidden()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time != 0) {
|
||||
months.add(MiscUtils.getInstance().getMonthFromMili(time));
|
||||
days.add(MiscUtils.getInstance().getDayFromMili(time));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -398,7 +384,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public HashMap<String, Boolean> getHasGottenMilestone() {
|
||||
HashMap<String, Boolean> hasGottenMilestone = new HashMap<String, Boolean>();
|
||||
ArrayList<String> milestoneList = getUserData().getStringList("GottenMileStones");
|
||||
ArrayList<String> milestoneList = getUserData().getStringList(getGottenMilestonesPath());
|
||||
for (String str : milestoneList) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1) {
|
||||
@@ -570,27 +556,6 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* public Integer hasLastCumulative(int votesRequired) { HashMap<Integer,
|
||||
* Integer> lastCumative = getLastCumulatives(); if
|
||||
* (lastCumative.containsKey(votesRequired)) { return
|
||||
* lastCumative.get(votesRequired); } return 0; } public HashMap<Integer,
|
||||
* Integer> getLastCumulatives() { HashMap<Integer, Integer> lastCumulative =
|
||||
* new HashMap<Integer, Integer>(); ArrayList<String> milestoneList =
|
||||
* getUserData().getStringList("LastCumulative"); for (String str :
|
||||
* milestoneList) { String[] data = str.split("//"); if (data.length > 1) { try
|
||||
* { lastCumulative.put(Integer.parseInt(data[0]), Integer.parseInt(data[1])); }
|
||||
* catch (Exception e) { e.printStackTrace(); } } } return lastCumulative; }
|
||||
* public void setLastCumulatives(HashMap<Integer, Integer> lastCumulative) {
|
||||
* ArrayList<String> data = new ArrayList<String>(); for (Entry<Integer,
|
||||
* Integer> entry : lastCumulative.entrySet()) { String str = entry.getKey() +
|
||||
* "//" + entry.getValue(); data.add(str); }
|
||||
* getUserData().setStringList("LastCumulative", data); } public void
|
||||
* setLastCumulative(int votesRequired, int value) { HashMap<Integer, Integer>
|
||||
* lastCumulative = getLastCumulatives(); lastCumulative.put(votesRequired,
|
||||
* value); setLastCumulatives(lastCumulative); }
|
||||
*/
|
||||
|
||||
public void giveMonthlyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMonthlyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
@@ -701,16 +666,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));
|
||||
}
|
||||
@@ -718,6 +690,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()) {
|
||||
@@ -750,7 +768,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));
|
||||
}
|
||||
|
||||
@@ -807,7 +825,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
String str = entry.getKey() + "//" + entry.getValue().booleanValue();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList("GottenMileStones", data);
|
||||
getUserData().setStringList(getGottenMilestonesPath(), data);
|
||||
}
|
||||
|
||||
public String getGottenMilestonesPath() {
|
||||
if (plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
return plugin.getOptions().getServer() + "_" + "GottenMilestones";
|
||||
}
|
||||
return "GottenMileStones";
|
||||
}
|
||||
|
||||
public void setHighestDailyTotal(int total) {
|
||||
@@ -877,7 +902,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) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
@@ -38,6 +39,7 @@ public class VoteParty implements Listener {
|
||||
public void addTotal(VotingPluginUser user) {
|
||||
setTotalVotes(getTotalVotes() + 1);
|
||||
user.setVotePartyVotes(user.getVotePartyVotes() + 1);
|
||||
plugin.getPlaceholders().onVotePartyUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,13 +187,23 @@ public class VoteParty implements Listener {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyGiveAllPlayers()) {
|
||||
plugin.debug("Trying to give all players vote party");
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
ArrayList<String> alreadyGotten = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
user.dontCache();
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly() || user.isOnline()) {
|
||||
giveReward(user, forceBungee);
|
||||
}
|
||||
|
||||
alreadyGotten.add(p.getUniqueId().toString());
|
||||
}
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
if (!alreadyGotten.contains(uuid)) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly() || user.isOnline()) {
|
||||
giveReward(user, forceBungee);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Trying to give all voted players vote party");
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.bencodez.votingplugin.votereminding;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -11,6 +13,8 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteReminding.
|
||||
@@ -22,6 +26,9 @@ public class VoteReminding {
|
||||
|
||||
private Timer timer;
|
||||
|
||||
@Getter
|
||||
private ConcurrentHashMap<UUID, Boolean> remindersEnabled = new ConcurrentHashMap<UUID, Boolean>();
|
||||
|
||||
public VoteReminding(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@@ -62,7 +69,7 @@ public class VoteReminding {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
checkRemind(user);
|
||||
@@ -95,6 +102,11 @@ public class VoteReminding {
|
||||
}
|
||||
|
||||
public boolean shouldRemind(VotingPluginUser user) {
|
||||
if (remindersEnabled.containsKey(user.getJavaUUID())) {
|
||||
if (!remindersEnabled.get(user.getJavaUUID()).booleanValue()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (user.shouldBeReminded()) {
|
||||
boolean hasPermAll = user.hasPermission("VotingPlugin.Login.RemindVotes.All");
|
||||
if (hasPermAll) {
|
||||
|
||||
Reference in new issue
Block a user