Compare commits

...
90 Commits
Author SHA1 Message Date
BenCodez 3f54c05f86 Update version number to 6.9.4 2022-08-27 19:30:43 -04:00
BenCodez dd1cf02c49 Fix voteparty setextrarequired command 2022-08-22 15:43:35 -04:00
BenCodez b462373dfc Run bstats metrics async 2022-08-20 07:54:20 -04:00
BenCodez c6e5d008d2 Update to 1.19.2 2022-08-07 14:07:31 -04:00
BenCodez 9a91561304 Improve addpoints command 2022-08-04 15:36:19 -04:00
BenCodez 1c6981e538 Change name of plugin in softdepend 2022-07-28 15:48:15 -04:00
BenCodez b6e366ff9d Update to 1.19.1 2022-07-27 18:59:58 -04:00
BenCodez ca0fbe7e3b Update version number to 6.9.3 2022-07-23 16:21:02 -04:00
BenCodez 27d8b3e718 Change gottenmilestones column to be bigger 2022-07-22 20:11:38 -04:00
BenCodez 8430609d0f Fix error on velocity if mysql is not set 2022-07-16 17:16:55 -04:00
BenCodez 8fe5e87999 Improve config comments 2022-07-10 15:06:43 -04:00
BenCodez 6b985e19c2 Add new experimental support for redis, new fully tested 2022-07-03 21:22:17 -04:00
BenCodez 4636cc78b2 Fix an error on velocity 2022-07-03 12:01:12 -04:00
BenCodez 8c66b50749 Fix spelling 2022-06-30 07:57:10 -04:00
BenCodez 7f6e95d47e Clicking icons in /votelast can now open links (if enabled) 2022-06-27 08:11:54 -04:00
BenCodez cd60ade45f Add additional debug for loading votesites 2022-06-26 12:39:24 -04:00
BenCodez f82945b97b Fix typo 2022-06-21 19:37:51 -04:00
BenCodez a3e9651378 Add config option to always process placeholders 2022-06-21 19:14:23 -04:00
BenCodez a764ca0ed7 Undo change 2022-06-21 19:03:51 -04:00
BenCodez d21464560a Minor change in placeholder handling 2022-06-21 19:01:31 -04:00
BenCodez 88c5dc7c86 Update version number to 6.9.2 2022-06-07 16:01:30 -04:00
BenCodez b2b2c710c5 Open gui on votesite creation 2022-06-07 14:09:50 -04:00
BenCodez 4175e2d36a Update 1.19 2022-06-07 13:29:33 -04:00
BenCodez a84adb367d Modify delay to login event 2022-06-02 17:10:46 -04:00
BenCodez 7368158707 Add command /av voteexact 2022-06-02 17:01:36 -04:00
BenCodez 5d3c1cb553 Use exact player name in /av user for forcing a vote 2022-05-29 13:04:58 -04:00
BenCodez cb1206db0b Updates to pluginmessaging and sockets 2022-05-18 20:12:45 -04:00
BenCodez 03396e447f Fix color codes on bungee commands 2022-05-17 20:56:58 -04:00
BenCodez 6dec0826af Update version number to 6.9.1 2022-05-15 15:33:12 -04:00
BenCodez f443f77dfe Add option to set cumulative as recurring 2022-05-13 17:04:04 -04:00
BenCodez 5c4636d8c2 Fixed issues with settings points to quickly, causing lost points 2022-05-12 20:55:22 -04:00
BenCodez 51c6c4066b Add cumulative blacklist 2022-05-12 19:27:02 -04:00
BenCodez 161fc6da95 Improve config comment on bungee 2022-05-08 12:11:10 -04:00
BenCodez aba23f355e Fix some issues with points within rewards 2022-05-07 19:37:59 -04:00
BenCodez ac78b4d350 Fix error on bungee 2022-04-27 17:30:41 -04:00
BenCodez 0c01f8d3c1 Update version number to 6.9 2022-04-24 15:15:57 -04:00
BenCodez 77dc7d51f5 Fix alternate broadcast broadcasting 0 votes on each login 2022-04-24 14:48:27 -04:00
BenCodez ee5c4db0c9 Fix playerjoinevent not working 2022-04-24 14:46:06 -04:00
BenCodez f9b47c5c63 Fix vote point adding in rewards 2022-04-18 16:59:56 -04:00
BenCodez d7dc82b1a7 Add extra checks 2022-04-18 16:57:57 -04:00
BenCodez c5041edd8a Add exr 2022-04-18 16:57:20 -04:00
BenCodez d52b7f85b3 use new method to get reward handler 2022-04-15 20:15:58 -04:00
BenCodez 3e4564578a CHange points reward handling 2022-04-15 14:35:07 -04:00
BenCodez 65312cd2a1 Add config option to only broadcast once for offline votes 2022-04-14 20:36:19 -04:00
BenCodez b2db9675ca Add ability to check if player doesn't have permission for vote shop 2022-04-13 16:47:09 -04:00
BenCodez 0a66c2dd7e Synchronize points adding 2022-04-06 17:36:20 -04:00
BenCodez 7c02cb91f4 Update version number to 6.8.4 2022-03-26 21:16:18 -04:00
BenCodez 3a390659cd Reenable config option 2022-03-26 20:16:11 -04:00
BenCodez 99bd32c8f5 Improve placeholder cache 2022-03-24 19:59:00 -04:00
BenCodez de894a98b2 Disable auto cache placeholders when no config option present 2022-03-24 17:35:00 -04:00
BenCodez 8c668289ce Add config options for mysql 2022-03-20 14:14:04 -04:00
BenCodez 95e850cb84 Add blacklist for rewards broadcasts 2022-03-20 12:48:03 -04:00
BenCodez d2134abc45 Fix broadcast blacklist not working on bungee setups 2022-03-19 17:10:47 -04:00
BenCodez 3316662889 Add default top voter material item 2022-03-05 21:57:15 -05:00
BenCodez 5b3ced6ca9 Attempt to fix /vote help for 1.12 2022-03-05 18:54:37 -05:00
BenCodez 50a5169543 Add extra check for background task for shutdowns 2022-03-03 16:52:23 -05:00
BenCodez c8d5e2f4b5 Have placeholders return error message rather than dots 2022-03-02 17:33:05 -05:00
BenCodez 3dcd78e4f5 change vote processing to java timers (hopes to reduce thread usage) 2022-02-22 16:51:18 -05:00
BenCodez de570574c9 Fix potential NPE on velocity shutdown 2022-02-20 16:52:32 -05:00
BenCodez 116eda2866 Update version number to 6.8.3 2022-02-20 13:44:33 -05:00
BuildTools 30f1576510 Fix creating milestones in GUI not working correctly 2022-02-19 17:00:05 -05:00
BuildTools 64e897615a use java timer for login/logout event 2022-02-18 19:16:18 -05:00
BuildTools 2dfd8dcfa5 Update version number to 6.8.2 2022-02-13 15:59:08 -05:00
BuildTools 00791766f1 Change default value of config option 2022-02-13 14:28:26 -05:00
ben 4d2c783d85 Improve getting uuid on proxy setups, more efficient 2022-02-11 17:14:05 -05:00
ben 19f1664662 Ignore casing when checking for disabled votesites 2022-02-06 12:34:01 -05:00
ben ca2e6fb530 Add extra null check 2022-02-02 16:57:28 -05:00
Ben eca7c6641a Merge pull request #1220 from pseudoforceyt/patch-1
Fix bungee setup wiki link
2022-01-24 16:46:52 -05:00
Ilamparithi M 47fe6b57e2 Fix bungee setup wiki link 2022-01-24 19:34:57 +05:30
ben 911819c69b Fix weekly top voters rewards feeding off monthly top voters 2022-01-23 14:03:25 -05:00
ben cda72b5c5b Let AdvancedCore handle vanished players 2022-01-23 13:18:16 -05:00
ben 75a3da98fa Change dependency 2022-01-22 15:24:13 -05:00
ben ced74fdee3 Changes to vanish event 2022-01-22 14:22:58 -05:00
ben b8460ff755 Add debug message for vanish login 2022-01-21 22:08:29 -05:00
ben 50bb1facc4 Modify event handling for playershowevent 2022-01-21 21:20:54 -05:00
ben 5ed21949e1 Add soft depends 2022-01-19 21:28:09 -05:00
ben 253e4937db Fix playershowevent not working completely 2022-01-19 19:51:32 -05:00
ben 192685ceec Add playershowevent for vanished players 2022-01-19 17:10:38 -05:00
BenCodez 16de063e51 Update version number to 6.8.1 2022-01-15 20:43:35 -05:00
BenCodez 1d3ce9ed64 Add another check 2022-01-14 21:50:21 -05:00
BenCodez d357c927c8 Add extra checks to ensure plugin is enabled before processing a vote 2022-01-14 21:47:33 -05:00
BenCodez 1143595238 modify placeholders 2022-01-13 20:57:33 -05:00
BenCodez 0917c36889 Add null check for player in placeholders 2022-01-12 18:57:12 -05:00
BenCodez c113214ae0 Add extra check on placeholders 2022-01-12 16:44:47 -05:00
BenCodez b2c444d125 Add PlayerPostVoteEvent 2022-01-11 21:04:50 -05:00
BenCodez 78fdce0eab fix npe 2022-01-10 18:51:02 -05:00
BenCodez feff09eccb Fix potential NPE 2022-01-09 17:35:57 -05:00
BenCodez d0646472bf Fix typos in votesites.yml 2022-01-09 11:22:29 -05:00
BenCodez 8471f50402 Fix certain placeholders not working 2022-01-06 19:28:13 -05:00
BenCodez 621450dae4 Add option to enable/disable auto placeholder cache 2022-01-03 21:15:16 -05:00
50 changed files with 1200 additions and 679 deletions

No files matched your search

+2 -2
View File
@@ -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
@@ -66,4 +66,4 @@ BungeeVotePartyRewards: {}
# For socket setup below only
# -----------------------------
# Options available here:
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
+45 -23
View File
@@ -30,6 +30,8 @@ MySQL:
#MaxLifeTime: -1
#Additional info on connection string
#Line: ''
#Attempt to use mariadb driver
#UseMariaDB: false
# --------------------
# AllowUnJoined options
@@ -107,7 +109,11 @@ Format:
# Broadcast vote message
# Set to an empty message to disable
# Use %NewLine% for a new line
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
# If true uses broadcast setting below for offline votes
OnlyOneOfflineBroadcast: false
OfflineBroadcast: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %numberofvotes% times!'
# Broadcast only when player is online
BroadcastWhenOnline: false
@@ -377,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
@@ -415,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
@@ -431,28 +441,6 @@ PreventRepeatMilestones: false
# This is to prevent any possible exploits
CloseInventoryOnVote: true
# When enabled the command /vote setprimaryaccount (playername)
# will be shown (after restart)
# Primary account will be used instead of the players account to get
# placeholder and other data such as vote reminding
# Mainly to be used for alts and such
UsePrimaryAccountForPlaceholders: false
# Always force placeholders to return value if the value isn't cached
# This should prevent server from crashing when pulling placeholders on main thread
# Only affects placeholderapi placeholders
AlwaysWaitForCachePlaceholders: false
# 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
@@ -474,6 +462,40 @@ CustomCommands:
# Forces player to run this command
Commands:
- tokencommand
# ---------------------------------------
# Placeholderapi placeholders settings
# ---------------------------------------
# When enabled the command /vote setprimaryaccount (playername)
# will be shown (after restart)
# Primary account will be used instead of the players account to get
# placeholder and other data such as vote reminding
# Mainly to be used for alts and such
UsePrimaryAccountForPlaceholders: false
# Always force placeholders to return value if the value isn't cached
# This should prevent server from crashing when pulling placeholders on main thread
# Only affects placeholderapi placeholders
AlwaysWaitForCachePlaceholders: false
# Always force placeholders to be processed and return a proper value
# This has small chance of crashing the server (mainly with mysql and using placeholders on main thread)
AlwaysProcessPlaceholders: false
# Enable auto caching placeholders
# Generally this works well, but if you need to cache placeholders manually set them below
AutoCachePlaceholders: false
# Set which placeholders to cache at all times
# Use for placeholders to are pulled constantly or on the main thread
# Mainly aimed for scoreboards
# Placeholders may auto cache in certain conditions
# Will use additional memory, but not a lot
# Still in early stages, please report bugs
# Please remove VotingPlugin_ from the placeholder listed here
CachedPlaceholders: []
#- Total_AllTime
######################
# Debug
+1
View File
@@ -138,6 +138,7 @@ CHEST:
# %time% = time, using timeformat below
# %timesince% = time since vote
Line: '&6%timeSince%'
ClickableLinks: true
VoteNext:
Name: 'VoteNext: %player%'
BackButton: true
+6 -1
View File
@@ -33,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
@@ -42,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!'
+2 -2
View File
@@ -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:
+29 -5
View File
@@ -12,9 +12,12 @@ Password: ''
# Max number of connections
MaxConnections: 1
# Table name prefix, for use with mutliple servers
# Don't use with PLUGINMESSAGING bungee setup
Prefix: ''
#UseSSL: true
#PublicKeyRetrieval: false
#Attempt to use mariadb driver
#UseMariaDB: false
Debug: false
# Have a reward on each server
@@ -48,10 +51,6 @@ 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
@@ -88,4 +87,29 @@ WaitForUserOnline: false
# ONLY for SOCKET method
# ----------------------------
# Options available here:
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
# ----------------------------
# Redis setup
# Experimental
# Primary server for redis needs votifier
# Set socket host on each proxy and redissockets on primary redis only
# All servers on pluginmessaging
# ----------------------------
# Support for redis
# experimental
RedisSupport: false
# Enable on primary server with votifier
PrimaryServer: false
RedisSocketHost:
Host: 0.0.0.0
Port: 1234
RedisServers:
secondproxy:
Host: 0.0.0.0
Port: 1235
+271 -257
View File
@@ -1,257 +1,271 @@
name: ${project.name}
version: ${project.version}
main: com.bencodez.votingplugin.VotingPluginMain
description: Highly Customizable Voting Listener!
website: https://www.spigotmc.org/resources/votingplugin.15358/
author: BenCodez
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe]
loadbefore: [MCPerks]
api-version: 1.13
libraries:
- org.openjdk.nashorn:nashorn-core:15.3
commands:
vote:
description: Vote command
adminvote:
description: Admin commands for VotingPlugin
av:
description: Admin commands for VotingPlugin
votehelp:
description: See access to a list of commands, Formated in Format.yml
aliases: vhelp
votetotal:
description: See totals of votes
aliases: vtotal
votelast:
description: See the last time you voted
aliases: vlast
votenext:
description: See when you can vote next
aliases: vnext
votetop:
description: See top voters
aliases: vtop
votetoday:
description: See who voted today
aliases: vtoday
votegui:
description: Open VoteGUI
aliases: vgui
voteurl:
description: Open VoteURL
aliases: vurl
votereward:
description: Open VoteReward GUI
aliases: vreward
vote?:
description: View Help
aliases: v?
voteparty:
description: A command
aliases: vparty
voteshop:
description: A command
aliases: vshop
votebest:
description: A command
aliases: vbest
votestreak:
description: A command
aliases: vstreak
votetogglebroadcast:
description: A command
aliases: vtogglebroadcast
votepoints:
description: A command
aliases: vpoints
votetogglereminders:
aliases: [vtogglereminder,vtoggle]
votelist:
description: A command
aliases: vlist
voteall:
description: A command
aliases: vall
votechoices:
description: A command
alaises: vchoices
votegivepoints:
description: A command
alaises: vgivepoints
adminvotehelp:
description: Open adminvote help
aliases: avhelp
adminvote?:
description: Open adminvote help
aliases: av?
adminvotereport:
description: Command Alias
aliases: avreport
adminvoteperms:
description: Command Alias
aliases: avperms
adminvotereload:
description: Command Alias
aliases: avreload
adminvotetestreward:
description: Command Alias
aliases: avtestreward
adminvoteversion:
description: Command Alias
aliases: avversion
adminvotesites:
description: Command Alias
aliases: avsites
adminvoterewards:
description: Command Alias
aliases: avrewards
adminvoteuuid:
description: Command Alias
aliases: avuuid
adminvotevotesite:
description: Command Alias
aliases: avvotesite
adminvoteconfig:
description: Command Alias
aliases: avconfig
adminvoteupdatecheck:
description: Command Alias
aliases: avupdatecheck
adminvotevote:
description: Command Alias
aliases: [avvote, fakevote]
adminvotegui:
description: Command Alias
aliases: avgui
adminvotegivereward:
description: Command Alias
aliases: avgivereward
adminvoteConvertFromData:
description: Command Alias
aliases: avConvertFromData
adminvoteConvertToData:
description: Command Alias
aliases: avConvertFromData
adminvoteClearTotal:
description: Command Alias
adminvoteBackgroundUpdate:
description: Command Alias
aliases: avBackgroundUpdate
adminvoteClearCache:
description: Command Alias
aliases: avClearCache
adminvoteServiceSites:
description: Command Alias
aliases: avServiceSites
adminvoteVoteParty:
description: Command Alias
aliases: avVoteParty
adminvoteChoices:
description: Command Alias
aliases: avChoices
adminvoteReloadAll:
description: Command Alias
aliases: avReloadAll
adminvotePermsPlayer:
description: Command Alias
aliases: avPermsPlayer
adminvoteResyncMilestonesAlreadyGiven:
description: Command Alias
aliases: avResyncMilestonesAlreadyGiven
voteSetPrimaryAccount:
description: Command Alias
adminvoteClearOfflineVotes:
description: Command Alias
aliases: avClearOfflineVotes
adminvoteGiveAll:
description: Command Alias
aliases: avGiveAll
adminvoteGiveAllOnline:
description: Command Alias
aliases: avGiveAllOnline
adminvoteForceTimeChanged:
description: Command Alias
aliases: avForceTimeChanged
adminvoteplayername:
description: Command Alias
aliases: avplayername
adminvoteResyncMilestones:
description: Command Alias
aliases: avResyncMilestones
adminvoteClearOfflineRewards:
description: Command Alias
aliases: avClearOfflineRewards
adminvoteUserRemove:
description: Command Alias
aliases: avUserRemove
adminvotePurge:
description: Command Alias
aliases: avPurge
adminvoteJavascript:
description: Command Alias
aliases: avJavascript
adminvoteStatus:
description: Command Alias
aliases: avStatus
adminvoteTest:
description: Command Alias
aliases: avTest
adminvotePlaceholders:
description: Command Alias
aliases: avPlaceholders
adminvoteDownloadJenkins:
description: Command Alias
aliases: avDownloadJenkins
adminvoteSetRequestMethod:
description: Command Alias
aliases: avSetRequestMethod
adminvoteUser:
description: Command Alias
aliases: avUser
adminvoteCurrentPluginTime:
description: Command Alias
aliases: avCurrentPluginTime
adminvoteResetPoints:
description: Command Alias
aliases: avResetPoints
adminvoteRunCMD:
description: Command Alias
aliases: avRunCMD
adminvoteuseruuidremove:
description: Command Alias
aliases: avuseruuidremove
adminvoteedit:
description: Command Alias
aliases: avedit
adminvoteResetMilestoneCount:
description: Command Alias
aliases: avResetMilestoneCount
permissions:
VotingPlugin.Player:
description: Allows basic access player commands
VotingPlugin.Mod:
description: Allows mod commands
VotingPlugin.Admin:
description: Allows admincommands
VotingPlugin.Login.RemindVotes:
description: Allows players to get remined on login if they can vote
default: true
VotingPlugin.Admin.Debug:
description: Permission to view debug info ingame
VotingPlugin.Signs.Create:
description: Allows access to create signs
VotingPlugin.TopVoter.Ignore:
description: Allows you to be exempt from top voter
VotingPlugin.NoRemind:
description: Ignore vote reminding
default: false
VotingPlugin.Sign.Create:
description: Permission to create sign
VotingPlugin.Admin.GenerateServiceSite:
description: Permission for generating votesite message
VotingPlugin.Login.RemindVotes:
description: Permission to allow timed reminders
VotingPlugin.Login.RemindVotes.All:
description: Remind if player can vote on all votesites, rather than any
default: false
name: ${project.name}
version: ${project.version}
main: com.bencodez.votingplugin.VotingPluginMain
description: Highly Customizable Voting Listener!
website: https://www.spigotmc.org/resources/votingplugin.15358/
author: BenCodez
softdepend:
- MVdWPlaceholders
- Votifier
- VotifierPlus
- NuVotifier
- CMI
- Vault
- PlaceholderAPI
- ProtocolLib
- MVdWPlaceholderAPI
- AuthMe
- SuperVanish
- PremiumVanish
- DiscordSRV
loadbefore:
- MCPerks
api-version: 1.13
libraries:
- org.openjdk.nashorn:nashorn-core:15.3
commands:
vote:
description: Vote command
adminvote:
description: Admin commands for VotingPlugin
av:
description: Admin commands for VotingPlugin
votehelp:
description: See access to a list of commands, Formated in Format.yml
aliases: vhelp
votetotal:
description: See totals of votes
aliases: vtotal
votelast:
description: See the last time you voted
aliases: vlast
votenext:
description: See when you can vote next
aliases: vnext
votetop:
description: See top voters
aliases: vtop
votetoday:
description: See who voted today
aliases: vtoday
votegui:
description: Open VoteGUI
aliases: vgui
voteurl:
description: Open VoteURL
aliases: vurl
votereward:
description: Open VoteReward GUI
aliases: vreward
vote?:
description: View Help
aliases: v?
voteparty:
description: A command
aliases: vparty
voteshop:
description: A command
aliases: vshop
votebest:
description: A command
aliases: vbest
votestreak:
description: A command
aliases: vstreak
votetogglebroadcast:
description: A command
aliases: vtogglebroadcast
votepoints:
description: A command
aliases: vpoints
votetogglereminders:
aliases:
- vtogglereminder
- vtoggle
votelist:
description: A command
aliases: vlist
voteall:
description: A command
aliases: vall
votechoices:
description: A command
alaises: vchoices
votegivepoints:
description: A command
alaises: vgivepoints
adminvotehelp:
description: Open adminvote help
aliases: avhelp
adminvote?:
description: Open adminvote help
aliases: av?
adminvotereport:
description: Command Alias
aliases: avreport
adminvoteperms:
description: Command Alias
aliases: avperms
adminvotereload:
description: Command Alias
aliases: avreload
adminvotetestreward:
description: Command Alias
aliases: avtestreward
adminvoteversion:
description: Command Alias
aliases: avversion
adminvotesites:
description: Command Alias
aliases: avsites
adminvoterewards:
description: Command Alias
aliases: avrewards
adminvoteuuid:
description: Command Alias
aliases: avuuid
adminvotevotesite:
description: Command Alias
aliases: avvotesite
adminvoteconfig:
description: Command Alias
aliases: avconfig
adminvoteupdatecheck:
description: Command Alias
aliases: avupdatecheck
adminvotevote:
description: Command Alias
aliases:
- avvote
- fakevote
adminvotegui:
description: Command Alias
aliases: avgui
adminvotegivereward:
description: Command Alias
aliases: avgivereward
adminvoteConvertFromData:
description: Command Alias
aliases: avConvertFromData
adminvoteConvertToData:
description: Command Alias
aliases: avConvertFromData
adminvoteClearTotal:
description: Command Alias
adminvoteBackgroundUpdate:
description: Command Alias
aliases: avBackgroundUpdate
adminvoteClearCache:
description: Command Alias
aliases: avClearCache
adminvoteServiceSites:
description: Command Alias
aliases: avServiceSites
adminvoteVoteParty:
description: Command Alias
aliases: avVoteParty
adminvoteChoices:
description: Command Alias
aliases: avChoices
adminvoteReloadAll:
description: Command Alias
aliases: avReloadAll
adminvotePermsPlayer:
description: Command Alias
aliases: avPermsPlayer
adminvoteResyncMilestonesAlreadyGiven:
description: Command Alias
aliases: avResyncMilestonesAlreadyGiven
voteSetPrimaryAccount:
description: Command Alias
adminvoteClearOfflineVotes:
description: Command Alias
aliases: avClearOfflineVotes
adminvoteGiveAll:
description: Command Alias
aliases: avGiveAll
adminvoteGiveAllOnline:
description: Command Alias
aliases: avGiveAllOnline
adminvoteForceTimeChanged:
description: Command Alias
aliases: avForceTimeChanged
adminvoteplayername:
description: Command Alias
aliases: avplayername
adminvoteResyncMilestones:
description: Command Alias
aliases: avResyncMilestones
adminvoteClearOfflineRewards:
description: Command Alias
aliases: avClearOfflineRewards
adminvoteUserRemove:
description: Command Alias
aliases: avUserRemove
adminvotePurge:
description: Command Alias
aliases: avPurge
adminvoteJavascript:
description: Command Alias
aliases: avJavascript
adminvoteStatus:
description: Command Alias
aliases: avStatus
adminvoteTest:
description: Command Alias
aliases: avTest
adminvotePlaceholders:
description: Command Alias
aliases: avPlaceholders
adminvoteDownloadJenkins:
description: Command Alias
aliases: avDownloadJenkins
adminvoteSetRequestMethod:
description: Command Alias
aliases: avSetRequestMethod
adminvoteUser:
description: Command Alias
aliases: avUser
adminvoteCurrentPluginTime:
description: Command Alias
aliases: avCurrentPluginTime
adminvoteResetPoints:
description: Command Alias
aliases: avResetPoints
adminvoteRunCMD:
description: Command Alias
aliases: avRunCMD
adminvoteuseruuidremove:
description: Command Alias
aliases: avuseruuidremove
adminvoteedit:
description: Command Alias
aliases: avedit
adminvoteResetMilestoneCount:
description: Command Alias
aliases: avResetMilestoneCount
permissions:
VotingPlugin.Player:
description: Allows basic access player commands
VotingPlugin.Mod:
description: Allows mod commands
VotingPlugin.Admin:
description: Allows admincommands
VotingPlugin.Admin.Debug:
description: Permission to view debug info ingame
VotingPlugin.Signs.Create:
description: Allows access to create signs
VotingPlugin.TopVoter.Ignore:
description: Allows you to be exempt from top voter
VotingPlugin.NoRemind:
description: Ignore vote reminding
default: false
VotingPlugin.Sign.Create:
description: Permission to create sign
VotingPlugin.Admin.GenerateServiceSite:
description: Permission for generating votesite message
VotingPlugin.Login.RemindVotes:
description: Permission to allow timed reminders
VotingPlugin.Login.RemindVotes.All:
description: Remind if player can vote on all votesites, rather than any
default: false
+2 -2
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.8</version>
<version>6.9.4</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -226,7 +226,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17.1-R0.1-SNAPSHOT</version>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -260,6 +260,19 @@ public class BungeeHandler implements Listener {
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcastOffline") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
if (args.size() > 2) {
String uuid = args.get(0);
String votes = args.get(2);
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
args.get(1));
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
}
});
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
@Override
public void onRecieve(String subChannel, ArrayList<String> args) {
@@ -295,7 +308,13 @@ public class BungeeHandler implements Listener {
socketHandler = new SocketHandler(plugin.getVersion(), plugin.getBungeeSettings().getSpigotServerHost(),
plugin.getBungeeSettings().getSpigotServerPort(), encryptionHandler,
plugin.getBungeeSettings().isBungeeDebug());
plugin.getBungeeSettings().isBungeeDebug()) {
@Override
public void log(String str) {
plugin.getLogger().info(str);
}
};
socketHandler.add(new SocketReceiver("bungeevote") {
@@ -347,6 +366,19 @@ public class BungeeHandler implements Listener {
}
});
socketHandler.add(new SocketReceiver("BroadcastOffline") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
String votes = data[0];
String p = data[1];
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
user.offlineBroadcast(user, false, Integer.parseInt(votes));
}
}
});
socketHandler.add(new SocketReceiver("BungeeBroadcast") {
@Override
@@ -364,6 +396,23 @@ public class BungeeHandler implements Listener {
}
});
socketHandler.add(new SocketReceiver("Broadcast") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
VoteSite site = plugin.getVoteSite(data[1], true);
String p = data[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
@@ -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() {
@@ -344,11 +347,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
return siteName;
}
}
}
for (String siteName : sites) {
if (siteName.equalsIgnoreCase(url)) {
return siteName;
}
}
}
return url;
@@ -402,7 +404,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
public void loadDirectlyDefined() {
RewardHandler.getInstance().getDirectlyDefinedRewards().clear();
getRewardHandler().getDirectlyDefinedRewards().clear();
// AllSites reward
addDirectlyDefinedRewards(new DirectlyDefinedReward("AllSites") {
@@ -1017,7 +1019,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
topVoterHandler.register();
metrics();
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
metrics();
}
});
// javascript api
getJavascriptEngineRequests().add(new JavascriptPlaceholderRequest("User") {
@@ -1041,15 +1049,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
// Add rewards
RewardHandler.getInstance().addInjectedReward(new RewardInjectInt("Points", 0) {
getRewardHandler().addInjectedReward(new RewardInjectInt("Points", 0) {
@Override
public String onRewardRequest(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
int num, HashMap<String, String> placeholders) {
UserManager.getInstance().getVotingPluginUser(user).addPoints(num);
return null;
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
String str = "" + vpUser.addPoints(num);
debug("Setting points to " + str);
return str;
}
}.synchronize().addEditButton(
}.synchronize().asPlaceholder("newpoints").addEditButton(
new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueNumber("Points", null) {
@Override
@@ -1067,7 +1077,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
}));
RewardHandler.getInstance().addInjectedReward(new RewardInjectConfigurationSection("VoteBossBar") {
getRewardHandler().addInjectedReward(new RewardInjectConfigurationSection("VoteBossBar") {
@Override
public String onRewardRequested(Reward arg0, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
@@ -1086,7 +1096,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
});
for (final TopVoter top : TopVoter.values()) {
RewardHandler.getInstance().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
getRewardHandler().addPlaceholder(new RewardPlaceholderHandle("Total_" + top.toString()) {
@Override
public String getValue(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
@@ -1107,7 +1117,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
"Using dev build, this is not a stable build, use at your own risk. Build number: " + buildNumber);
}
boolean hasRewards = RewardHandler.getInstance().hasRewards(getConfigVoteSites().getData(),
boolean hasRewards = getRewardHandler().hasRewards(getConfigVoteSites().getData(),
getConfigVoteSites().getEverySiteRewardPath());
boolean issues = true;
@@ -1346,114 +1356,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());
placeholders.onUpdate();
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.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);
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"));
}
}));
@@ -53,6 +53,14 @@ public class Config {
return getData().getInt("BungeeServer.Port", 1297);
}
public int getRedisSocketHostPort() {
return getData().getInt("RedisSocketHost.Port", 1297);
}
public String getRedisSocketHostHost() {
return getData().getString("RedisSocketHost.Host", "");
}
public boolean getDebug() {
return getData().getBoolean("Debug", false);
}
@@ -73,6 +81,14 @@ public class Config {
return getData().getSection("SpigotServers." + s);
}
public Configuration getRedisServersConfiguration(String s) {
return getData().getSection("RedisServers." + s);
}
public Collection<String> getRedisServers() {
return getData().getSection("RedisServers").getKeys();
}
public Collection<String> getSpigotServers() {
return getData().getSection("SpigotServers").getKeys();
}
@@ -81,6 +97,10 @@ public class Config {
return getData().getBoolean("WaitForUserOnline", false);
}
public boolean getPrimaryServer() {
return getData().getBoolean("PrimaryServer", false);
}
public boolean getVotePartyEnabled() {
return getData().getBoolean("VoteParty.Enabled", false);
}
@@ -9,6 +9,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
@Deprecated
public class RedisBungee implements Listener {
@Getter
private boolean enabled;
@@ -26,7 +26,7 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
serviceSite = "Empty";
}
plugin.vote(vote.getUsername(), serviceSite, true);
plugin.vote(vote.getUsername(), serviceSite, true, null, null);
}
});
@@ -20,6 +20,7 @@ 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;
@@ -62,6 +63,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
private HashMap<String, ClientHandler> clientHandles;
private HashMap<String, ClientHandler> redisClientHandles;
@Getter
private Config config;
@@ -77,16 +80,17 @@ public class VotingPluginBungee extends Plugin implements Listener {
private SocketHandler socketHandler;
private SocketHandler redisSocketHandler;
private VoteCache voteCacheFile;
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()) {
@@ -153,6 +157,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();
@@ -188,6 +195,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) {
@@ -325,9 +339,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (mysql != null) {
mysql.shutdown();
}
if (redis != null) {
redis.destroy();
}
getLogger().info("VotingPlugin disabled");
}
@@ -350,12 +361,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
config = new Config(this);
config.load();
try {
redis = new RedisBungee(this);
} catch (Exception e) {
e.printStackTrace();
}
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
boolean mysqlLoaded = true;
@@ -379,6 +384,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
this.getProxy().registerChannel("vp:vp");
if (mysqlLoaded) {
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
voteCacheFile = new VoteCache(this);
voteCacheFile.load();
@@ -458,7 +465,13 @@ public class VotingPluginBungee extends Plugin implements Listener {
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
socketHandler = new SocketHandler(getDescription().getVersion(), config.getBungeeHost(),
config.getBungeePort(), encryptionHandler, config.getDebug());
config.getBungeePort(), encryptionHandler, config.getDebug()) {
@Override
public void log(String str) {
getLogger().info(str);
}
};
socketHandler.add(new SocketReceiver() {
@@ -499,11 +512,46 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
+ voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
+ voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
if (getConfig().getRedisSupport()) {
redisSocketHandler = new SocketHandler(getDescription().getVersion(), config.getRedisSocketHostHost(),
config.getRedisSocketHostPort(), encryptionHandler, config.getDebug()) {
@Override
public void log(String str) {
getLogger().info(str);
}
};
redisSocketHandler.add(new SocketReceiver() {
@Override
public void onReceive(String[] data) {
if (data.length > 8) {
if (data[0].equalsIgnoreCase("Vote")) {
// todo
// sendRedisServerMessage("Vote", uuid, player, service, "" + votePartyVotes,""
// + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
vote(data[2], data[3], Boolean.valueOf(data[7]), new BungeeMessageData(data[8]), data[1]);
}
}
}
});
clientHandles = new HashMap<String, ClientHandler>();
for (
String s : config.getRedisServers()) {
Configuration d = config.getRedisServersConfiguration(s);
redisClientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1234),
encryptionHandler, config.getDebug()));
}
}
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
@@ -554,11 +602,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
public boolean isOnline(ProxiedPlayer p) {
if (p != null) {
if (redis != null && redis.isEnabled()) {
return redis.isOnline(p);
} else {
return p.isConnected();
}
return p.isConnected();
}
return false;
@@ -703,6 +747,12 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
public void sendRedisServerMessage(String... messageData) {
for (ClientHandler h : redisClientHandles.values()) {
h.sendMessage(messageData);
}
}
public void sendServerMessageServer(String server, String... messageData) {
if (clientHandles.containsKey(server)) {
clientHandles.get(server).sendMessage(messageData);
@@ -763,14 +813,17 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
}
public synchronized void vote(String player, String service, boolean realVote) {
public synchronized void vote(String player, String service, boolean realVote, BungeeMessageData text,
String uuid) {
try {
if (player == null || player.isEmpty()) {
getLogger().info("No name from vote on " + service);
return;
}
String uuid = getUUID(player);
if (uuid == null) {
uuid = getUUID(player);
}
if (uuid.isEmpty()) {
if (config.getAllowUnJoined()) {
debug("Fetching UUID online, since allowunjoined is enabled");
@@ -795,42 +848,42 @@ public class VotingPluginBungee extends Plugin implements Listener {
player = getProperName(uuid, player);
BungeeMessageData text = null;
if (!getConfig().getPrimaryServer()) {
addVoteParty();
if (getConfig().getBungeeManageTotals()) {
addVoteParty();
if (mysql == null) {
getLogger().severe("Mysql is not loaded correctly, stopping vote processing");
return;
}
if (getConfig().getBungeeManageTotals()) {
// one time query to insert player
if (!mysql.getUuids().contains(uuid)) {
mysql.update(uuid, "PlayerName", new DataValueString(player));
}
if (mysql == null) {
getLogger().severe("Mysql is not loaded correctly, stopping vote processing");
return;
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", new DataValueString(uuid)));
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
int monthTotal = getValue(data, "MonthTotal", 1);
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
int milestoneCount = getValue(data, "MilestoneCount", 1);
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points,
milestoneCount, votePartyVotes, currentVotePartyVotesRequired);
ArrayList<Column> update = new ArrayList<Column>();
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
update.add(new Column("Points", new DataValueInt(points)));
update.add(new Column("MilestoneCount", new DataValueInt(milestoneCount)));
debug("Setting totals " + text.toString());
mysql.update(uuid, update);
} else {
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
}
if (!mysql.getUuids().contains(uuid)) {
mysql.update(uuid, "PlayerName", new DataValueString(player));
}
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", new DataValueString(uuid)));
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
int monthTotal = getValue(data, "MonthTotal", 1);
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
int dailyTotal = getValue(data, "DailyTotal", 1);
int points = getValue(data, "Points", getConfig().getPointsOnVote());
int milestoneCount = getValue(data, "MilestoneCount", 1);
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points, milestoneCount,
votePartyVotes, currentVotePartyVotesRequired);
ArrayList<Column> update = new ArrayList<Column>();
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
update.add(new Column("Points", new DataValueInt(points)));
update.add(new Column("MilestoneCount", new DataValueInt(milestoneCount)));
debug("Setting totals " + text.toString());
mysql.update(uuid, update);
} else {
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
}
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
@@ -847,6 +900,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
forceCache = true;
debug("Forcing vote to cache");
}
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
}
if (info.getPlayers().isEmpty() || forceCache) {
// cache
if (!cachedVotes.containsKey(s)) {
@@ -865,9 +921,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
"" + getConfig().getBungeeManageTotals(),
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
}
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
}
}
}
} else {
@@ -890,16 +944,21 @@ public class VotingPluginBungee extends Plugin implements Listener {
debug("Caching online vote for " + player + " on " + service);
}
for (String s : getProxy().getServers().keySet()) {
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired);
if (config.getBroadcast()) {
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
}
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
"" + currentVotePartyVotesRequired);
}
}
} else if (method.equals(BungeeMethod.SOCKETS)) {
sendSocketVote(player, service, text);
}
if (getConfig().getRedisSupport() && getConfig().getPrimaryServer()) {
sendRedisServerMessage("Vote", uuid, player, service, "" + votePartyVotes,
"" + currentVotePartyVotesRequired, "" + time, "" + realVote, text.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
@@ -18,17 +18,17 @@ public class VotingPluginBungeeCommand extends Command {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("reload")) {
bungee.reload(false);
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee"));
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
}
if (args[0].equalsIgnoreCase("reloadmysql")) {
bungee.reload(true);
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee with MySQL"));
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee with MySQL"));
}
if (args[0].equalsIgnoreCase("vote")) {
if (args.length >= 2) {
String user = args[1];
String site = args[2];
bungee.vote(user, site, false);
bungee.vote(user, site, false, null, null);
sender.sendMessage(new TextComponent("Sending vote"));
}
}
@@ -27,6 +27,7 @@ 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;
@@ -113,6 +114,8 @@ public class VotingPluginVelocity {
@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) {
@@ -139,8 +142,9 @@ public class VotingPluginVelocity {
}
if (p == null || !p.isActive()) {
toSend = false;
} else if (p != null && p.isActive() && !p.getCurrentServer().get().getServerInfo()
.getName().equals(serverToCheck.getServerInfo().getName())) {
} else if (p != null && p.isActive()
&& (!p.getCurrentServer().isPresent() || !p.getCurrentServer().get().getServerInfo()
.getName().equals(serverToCheck.getServerInfo().getName()))) {
toSend = false;
}
@@ -229,6 +233,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) {
@@ -389,7 +398,9 @@ public class VotingPluginVelocity {
}
}
}
timeHandle.save();
if (timeHandle != null) {
timeHandle.save();
}
voteCacheFile.save();
nonVotedPlayersCache.save();
if (mysql != null) {
@@ -445,6 +456,8 @@ public class VotingPluginVelocity {
server.getCommandManager().register(meta, new VotingPluginVelocityCommand(this));
if (mysqlLoaded) {
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
nonVotedPlayersCache = new NonVotedPlayersCache(
new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
@@ -519,7 +532,13 @@ public class VotingPluginVelocity {
socketHandler = new SocketHandler(
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug());
config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug()) {
@Override
public void log(String str) {
getLogger().info(str);
}
};
socketHandler.add(new SocketReceiver() {
@@ -560,11 +579,13 @@ public class VotingPluginVelocity {
}
}
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
+ voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
}
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
+ voteCacheFile.getVotePartyInreaseVotesRequired();
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
try {
getVersionFile();
@@ -28,7 +28,6 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.advancedcore.api.updater.Updater;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
@@ -372,13 +371,14 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.clearCache();
synchronized (pointLock) {
user.addPoints(Integer.parseInt(args[3]));
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.cache();
int newTotal = 0;
newTotal = user.addPoints(Integer.parseInt(args[3]));
sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3]
+ " points" + ", " + args[1] + " now has " + newTotal + " points"));
}
sender.sendMessage(StringParser.getInstance().colorize("&cGave " + args[1] + " " + args[3]
+ " points" + ", " + args[1] + " now has " + user.getPoints() + " points"));
}
});
@@ -389,7 +389,7 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.clearCache();
user.cache();
user.removePoints(Integer.parseInt(args[3]));
sender.sendMessage(StringParser.getInstance().colorize("&cRemoved " + args[3] + " points from "
+ args[1] + ", " + args[1] + " now has " + user.getPoints() + " points"));
@@ -439,7 +439,6 @@ public class CommandLoader {
int page = Integer.parseInt(args[1]);
new AdminVoteHelp(plugin, sender, page).open();
}
});
@@ -910,6 +909,32 @@ public class CommandLoader {
}
});
plugin.getAdminVoteCommand()
.add(new CommandHandler(new String[] { "VoteExact", "(PlayerExact)", "(Sitename)" },
"VotingPlugin.Commands.AdminVote.VoteExact|" + adminPerm,
"Trigger manual vote with exact player name") {
@Override
public void execute(CommandSender sender, String[] args) {
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1],
args[2], false);
sendMessage(sender, "&cTriggering vote...");
if (voteEvent.getVoteSite() != null) {
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
sendMessage(sender,
"&cPossible issue with service site, has the server gotten the vote from "
+ voteEvent.getServiceSite() + "?");
}
}
plugin.getServer().getPluginManager().callEvent(voteEvent);
if (plugin.isYmlError()) {
sendMessage(sender, "&3Detected yml error, please check server log for details");
}
}
});
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", },
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote via GUI", false) {
@@ -1255,8 +1280,8 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
plugin.getServerData().setVotePartyExtraRequired(Integer.parseInt(args[1]));
sendMessage(sender, "&cSet VotePartyExtraRequired to " + args[1]);
plugin.getServerData().setVotePartyExtraRequired(Integer.parseInt(args[2]));
sendMessage(sender, "&cSet VotePartyExtraRequired to " + args[2]);
}
});
@@ -1267,7 +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");
}
@@ -1828,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) {
@@ -1839,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));
@@ -2011,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,
@@ -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,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("EverySiteReward"));
plugin.getRewardHandler().getDirectlyDefined("EverySiteReward"));
}
});
@@ -154,7 +154,7 @@ public class AdminGUI {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("BungeeVotePartyRewards"));
plugin.getRewardHandler().getDirectlyDefined("BungeeVotePartyRewards"));
}
});
@@ -364,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"));
}
});
@@ -17,7 +17,6 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueLi
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
import com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener;
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
@@ -212,7 +211,7 @@ public class AdminVoteVoteParty extends GUIHandler {
@Override
public void onClick(ClickEvent clickEvent) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance().getDirectlyDefined("VoteParty.Rewards"));
plugin.getRewardHandler().getDirectlyDefined("VoteParty.Rewards"));
}
});
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
@@ -68,7 +67,7 @@ public class AdminVoteCumulative extends GUIHandler {
@Override
public void onInput(Player player, Number value) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance()
plugin.getRewardHandler()
.getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
}
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
@@ -68,7 +67,7 @@ public class AdminVoteMilestones extends GUIHandler {
@Override
public void onInput(Player player, Number value) {
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
RewardHandler.getInstance()
plugin.getRewardHandler()
.getDirectlyDefined("MileStones." + value.intValue() + ".Rewards"));
}
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
@@ -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"));
}
});
@@ -12,7 +12,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.topvoter.TopVoter;
@@ -184,9 +183,9 @@ public class VoteGUI extends GUIHandler {
}
}
if (RewardHandler.getInstance().hasRewards(plugin.getGui().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
RewardHandler.getInstance().giveReward(UserManager.getInstance().getVotingPluginUser(player),
plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player),
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
new RewardOptions().addPlaceholder("identifier", slot));
}
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.command.CommandHandler;
import com.bencodez.advancedcore.api.gui.GUIHandler;
import com.bencodez.advancedcore.api.gui.GUIMethod;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.nms.NMSManager;
import com.bencodez.votingplugin.VotingPluginMain;
import net.md_5.bungee.api.ChatColor;
@@ -63,6 +64,28 @@ public class VoteHelp extends GUIHandler {
return msg;
}
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
if (!requirePerms || cmdHandle.hasPerm(sender)) {
unsorted.put(cmdHandle.getHelpLineCommand("/vote"),
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
}
}
ArrayList<String> unsortedList = new ArrayList<String>();
unsortedList.addAll(unsorted.keySet());
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
for (String cmd : unsortedList) {
msg.add(unsorted.get(cmd));
}
return msg;
}
@Override
public void onBook(Player player) {
@@ -86,7 +109,12 @@ public class VoteHelp extends GUIHandler {
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
int pagesize = plugin.getConfigFile().getFormatPageSize();
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
ArrayList<TextComponent> text = helpText(sender);
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
if (NMSManager.getInstance().isVersion("1.12")) {
text = helpTextLegacy(sender);
} else {
text = helpText(sender);
}
int maxPage = text.size() / pagesize;
if ((text.size() % pagesize) != 0) {
@@ -15,6 +15,7 @@ import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.ArrayUtils;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.objects.VoteSite;
import com.bencodez.votingplugin.user.UserManager;
import com.bencodez.votingplugin.user.VotingPluginUser;
public class VoteLast extends GUIHandler {
@@ -67,8 +68,24 @@ public class VoteLast extends GUIHandler {
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {
@Override
public void onClick(ClickEvent clickEvent) {
public void onClick(ClickEvent event) {
if (plugin.getGui().isChestVoteLastClickableLinks()) {
Player player = event.getPlayer();
if (player != null) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
user.sendMessage(
StringParser.getInstance()
.replacePlaceHolder(
StringParser.getInstance().replacePlaceHolder(
StringParser.getInstance()
.replacePlaceHolder(plugin.getGui()
.getChestVoteURLURLText(),
"voteurl", site.getVoteURL()),
"sitename", site.getDisplayName()),
"player", player.getName()));
}
}
}
@Override
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.UserManager;
@@ -65,7 +64,11 @@ public class VoteShop extends GUIHandler {
if (perm.isEmpty()) {
hasPerm = true;
} else {
hasPerm = player.hasPermission(perm);
if (perm.startsWith("!")) {
hasPerm = !player.hasPermission(perm.substring(1));
} else {
hasPerm = player.hasPermission(perm);
}
}
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
@@ -117,7 +120,7 @@ public class VoteShop extends GUIHandler {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/"
+ user.getUUID() + " bought " + identifier + " for " + points);
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
@@ -14,7 +14,6 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
import com.bencodez.advancedcore.api.item.ItemBuilder;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.misc.PlayerUtils;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -65,7 +64,7 @@ public class VoteShopConfirm extends GUIHandler {
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought "
+ identifier + " for " + points);
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
new RewardOptions().setPlaceholders(placeholders));
@@ -86,7 +86,7 @@ public class VoteTopVoter extends GUIHandler {
int pos = 1;
for (Entry<TopVoterPlayer, Integer> entry : users) {
ItemBuilder playerItem;
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
if (plugin.getGui().isChestVoteTopUseSkull()) {
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
@@ -41,6 +41,10 @@ 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;
@@ -69,6 +73,10 @@ public class Config extends YMLFile {
@Getter
private boolean alwaysWaitForCachePlaceholders = false;
@ConfigDataBoolean(path = "AlwaysProcessPlaceholders")
@Getter
private boolean alwaysProcessPlaceholders = false;
@ConfigDataBoolean(path = "AutoCreateVoteSites")
@Getter
private boolean autoCreateVoteSites = true;
@@ -85,10 +93,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;
@@ -145,6 +149,14 @@ public class Config extends YMLFile {
@Getter
private boolean formatAlternateBroadcastEnabled = false;
@ConfigDataBoolean(path = "Format.OnlyOneOfflineBroadcast")
@Getter
private boolean formatOnlyOneOfflineBroadcast = false;
@ConfigDataString(path = "Format.OfflineBroadcast")
@Getter
private String formatOfflineBroadcast = "&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %numberofvotes% times!";
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
@Getter
private boolean formatCommandsVoteForceLinks = true;
@@ -130,12 +130,12 @@ public class ConfigVoteSites extends YMLFile {
* @param siteName the site name
* @return the vote delay
*/
public int getVoteDelay(String siteName) {
return getData(siteName).getInt("VoteDelay", 24);
public double getVoteDelay(String siteName) {
return getData(siteName).getDouble("VoteDelay", 24);
}
public int getVoteDelayMin(String siteName) {
return getData(siteName).getInt("VoteDelayMin", 0);
public double getVoteDelayMin(String siteName) {
return getData(siteName).getDouble("VoteDelayMin", 0);
}
/**
@@ -199,7 +199,9 @@ public class ConfigVoteSites extends YMLFile {
if (!siteCheck(site)) {
plugin.getLogger().warning("Failed to load site " + site + ", see above");
} else {
voteSites.add(new VoteSite(plugin, site));
VoteSite voteSite = new VoteSite(plugin, site);
plugin.debug(voteSite.loadingDebug());
voteSites.add(voteSite);
}
}
}
@@ -393,7 +395,7 @@ public class ConfigVoteSites extends YMLFile {
* @param siteName the site name
* @param voteDelay the vote delay
*/
public void setVoteDelay(String siteName, int voteDelay) {
public void setVoteDelay(String siteName, double voteDelay) {
set(siteName, "VoteDelay", voteDelay);
}
@@ -146,6 +146,10 @@ public class GUI extends YMLFile {
@Getter
private boolean lastMonthGUI = false;
@ConfigDataBoolean(path = "CHEST.VoteLast.ClickableLinks")
@Getter
private boolean chestVoteLastClickableLinks = true;
private VotingPluginMain plugin;
public GUI(VotingPluginMain plugin) {
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.config;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import com.bencodez.advancedcore.api.yml.YMLFile;
@@ -91,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.
*
@@ -353,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());
}
}
@@ -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()) {
@@ -109,6 +115,9 @@ public class PlayerVoteListener implements Listener {
}
synchronized (object) {
if (!plugin.isEnabled()) {
return;
}
// reupdate cache
user.clearCache();
user.cache();
@@ -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,9 +168,8 @@ 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();
@@ -195,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
@@ -209,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;
@@ -65,7 +65,7 @@ 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() {
@@ -82,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 {
@@ -91,7 +91,7 @@ public class VotiferEvent implements Listener {
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr
+ "' does not exist, attempting to generaterate...");
+ "' does not exist, attempting to generate...");
plugin.getConfigVoteSites().generateVoteSite(voteSiteNameStr);
plugin.getLogger().info("Current known service sites: "
@@ -110,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));
}
@@ -240,4 +239,19 @@ public class VoteSite {
return ArrayUtils.getInstance().containsIgnoreCase(plugin.getServerData().getServiceSites(), getServiceSite());
}
public String loadingDebug() {
String str = "Loading votesite key: " + key;
str += ", Displayname: " + displayName;
str += ", VoteDelay: " + getVoteDelay();
str += ", VoteDelayMin: " + getVoteDelayMin();
str += ", VoteDelayDaily: " + isVoteDelayDaily();
str += ", IsWaitUntilVoteDelay: " + isWaitUntilVoteDelay();
str += ", ServiceSite: " + getServiceSite();
str += ", TimeOffSet:" + getTimeOffSet();
str += ", Url: " + getVoteURL();
str += ", IgnoreCanVote: " + isIgnoreCanVote();
str += ", Hidden: " + isHidden();
return str;
}
}
@@ -58,24 +58,36 @@ public class PlaceHolders {
}
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 (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.matches(identifier)) {
return placeholder.placeholderRequest(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 (!cachedPlaceholders.contains(identifier)) {
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
user.setWaitForCache(false);
if (!user.isCached()) {
user.loadCache();
placeholdersToSetCacheOn.add(identifier);
return "..";
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
placeholdersToSetCacheOn.add(identifier);
}
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
return "..";
}
}
}
}
@@ -93,7 +105,11 @@ public class PlaceHolders {
if (cache.containsKey(p.getUniqueId())) {
return cache.get(p.getUniqueId());
} else {
return "....";
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
return "....";
} else {
return placeholder.placeholderRequest(user, identifier);
}
}
} else {
return placeholder.placeholderRequest(user, identifier);
@@ -101,7 +117,7 @@ public class PlaceHolders {
}
} catch (Exception e) {
plugin.debug(e);
return "...";
return "Error";
}
}
@@ -378,6 +394,9 @@ public class PlaceHolders {
@Override
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()) {
@@ -410,6 +429,9 @@ public class PlaceHolders {
@Override
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()) {
@@ -458,6 +480,9 @@ public class PlaceHolders {
@Override
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()) {
@@ -506,6 +531,9 @@ public class PlaceHolders {
@Override
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()) {
@@ -690,7 +718,9 @@ public class PlaceHolders {
Set<String> placeholdersSet = new HashSet<String>();
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
}
for (String toCache : placeholdersSet) {
if (toCache.startsWith("VotingPlugin")) {
@@ -738,10 +768,11 @@ public class PlaceHolders {
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 cache for " + vpUser.getUUID() + " on " + key);
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on " + key);
}
@@ -816,7 +847,14 @@ public class PlaceHolders {
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
if (placeholder.isUsesCache()) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
if (ident != null) {
String str = placeholder.placeholderRequest(ident);
if (str != null) {
placeholder.getCache().put(ident, str);
}
} else {
plugin.debug("ident null: " + placeholder.getIdentifier());
}
}
}
}
@@ -827,8 +865,12 @@ public class PlaceHolders {
if (placeholder.isUsesCache()) {
if (placeholder.getIdentifier().startsWith("Top_")) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
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,8 +87,25 @@ public class SpecialRewards {
}
}
if (total != 0 && total >= votesRequired) {
if ((total % votesRequired) == 0) {
List<Integer> blackList = plugin.getSpecialRewardsConfig()
.getCumulativeBlackList(votesRequired);
boolean blackListed = false;
for (Integer num : blackList) {
if (num.intValue() == total) {
blackListed = true;
plugin.extraDebug("Not giving cumulative " + votesRequired + " to "
+ user.getPlayerName() + " due to blacklist");
}
}
if (plugin.getSpecialRewardsConfig().getCumulativeRecurring(votesRequired)) {
if (total != 0 && total >= votesRequired) {
if ((total % votesRequired) == 0 && !blackListed) {
gotCumulative = true;
}
}
} else {
if (total == votesRequired) {
gotCumulative = true;
}
}
@@ -116,7 +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);
@@ -128,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);
@@ -181,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;
@@ -217,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")) {
@@ -261,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));
}
@@ -287,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));
}
@@ -299,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();
@@ -45,7 +45,7 @@ public class UserManager {
manager.addKey(new UserDataKeyInt("DayVoteStreak"));
manager.addKey(new UserDataKeyInt("BestDayVoteStreak"));
manager.addKey(new UserDataKeyString("DayVoteStreakLastUpdate").setColumnType("MEDIUMTEXT"));
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("MEDIUMTEXT"));
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("LONGTEXT"));
manager.addKey(new UserDataKeyString("Reminded").setColumnType("VARCHAR(5)"));
manager.addKey(new UserDataKeyString("DisableBroadcast").setColumnType("VARCHAR(5)"));
manager.addKey(new UserDataKeyInt("WeekVoteStreak"));
@@ -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);
}
}
@@ -682,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));
}
@@ -699,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()) {
@@ -731,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));
}
@@ -865,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) {