Compare commits

...
56 Commits
Author SHA1 Message Date
BenCodez f5d67833b2 Update version number to 6.9.5 2022-09-25 15:00:56 -04:00
BenCodez a1eb2f63e5 Fix cache issues on player vote 2022-09-14 20:28:19 -04:00
BenCodez a882b8d86f Undo minor change for cache on vote 2022-09-14 15:42:32 -04:00
BenCodez 0a745ae4c0 Fix issues with cache delays for cumulative/milestones 2022-09-10 15:00:48 -04:00
BenCodez d38a0549d3 Add 1 total to cumulative on local votes to prevent cumulative delay 2022-09-09 20:23:37 -04:00
BenCodez 6e6394f1fb Always update placeholder cache on background update 2022-09-08 19:21:54 -04:00
BenCodez ce58e12740 Fix error with sockets method on broadcasts 2022-09-03 20:46:51 -04:00
BenCodez 2411354a5f Added extra debug for reminders 2022-09-02 20:10:47 -04:00
BenCodez 13efd0c482 Add option for voteparty once per week 2022-08-30 19:36:06 -04:00
BenCodez 8fce74f30d Always store bungee voteparty info incase of restart 2022-08-27 20:14:36 -04:00
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
43 changed files with 919 additions and 590 deletions

No files matched your search

+39 -27
View File
@@ -109,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
@@ -379,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
@@ -437,32 +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
# Enable auto caching placeholders
# Generally this works well, but if you need to cache placeholders manually set them below
AutoCachePlaceholders: false
# Set which placeholders to cache at all times
# Use for placeholders to are pulled constantly or on the main thread
# Mainly aimed for scoreboards
# Placeholders may auto cache in certain conditions
# Will use additional memory, but not a lot
# Still in early stages, please report bugs
# Please remove VotingPlugin_ from the placeholder listed here
CachedPlaceholders: []
#- Total_AllTime
# If true, permissions will be handled differently
MultiplePermissionsCheck: false
@@ -484,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
+8 -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!'
@@ -69,6 +74,8 @@ VoteParty:
ResetMonthly: false
# If true, will give voteparty only once per day
OnlyOncePerDay: false
# If true, will give voteparty once per week only
OnlyOncePerWeek: false
# Reset extra votes
ResetExtraVotesMonthly: false
# Count votes from /av vote?
+27 -5
View File
@@ -12,6 +12,7 @@ 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
@@ -50,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
@@ -90,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, SuperVanish, PremiumVanish]
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.4</version>
<version>6.9.5</version>
<packaging>jar</packaging>
<name>VotingPlugin</name>
<properties>
@@ -226,7 +226,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.2-R0.1-SNAPSHOT</version>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -107,6 +107,8 @@ public class BungeeHandler implements Listener {
bungeeVotePartyCurrent = text.getVotePartyCurrent();
bungeeVotePartyRequired = text.getVotePartyRequired();
plugin.getPlaceholders().onBungeeVotePartyUpdate();
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
boolean setTotals = Boolean.valueOf(args.get(7));
@@ -169,6 +171,8 @@ public class BungeeHandler implements Listener {
bungeeVotePartyCurrent = text.getVotePartyCurrent();
bungeeVotePartyRequired = text.getVotePartyRequired();
plugin.getPlaceholders().onBungeeVotePartyUpdate();
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
plugin.debug(
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
@@ -236,6 +240,8 @@ public class BungeeHandler implements Listener {
if (args.size() > 2) {
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
}
plugin.setUpdate(true);
@@ -260,6 +266,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 +314,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 +372,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 +402,23 @@ public class BungeeHandler implements Listener {
}
});
socketHandler.add(new SocketReceiver("Broadcast") {
@Override
public void onReceive(String[] data) {
if (data.length > 2) {
VoteSite site = plugin.getVoteSite(data[1], true);
String p = data[2];
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
if (site != null) {
site.broadcastVote(user, false);
} else {
plugin.getLogger().warning("No votesite for " + data[1]);
}
}
}
});
socketHandler.add(new SocketReceiver("Status") {
@Override
@@ -2,7 +2,6 @@ package com.bencodez.votingplugin;
import org.bukkit.entity.Player;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject;
import com.bencodez.votingplugin.user.UserManager;
@@ -16,11 +15,11 @@ public class VotingPluginHooks {
}
public void addCustomRequirement(RequirementInject inject) {
RewardHandler.getInstance().addInjectedRequirements(inject);
getMainClass().getRewardHandler().addInjectedRequirements(inject);
}
public void addCustomReward(RewardInject inject) {
RewardHandler.getInstance().addInjectedReward(inject);
getMainClass().getRewardHandler().addInjectedReward(inject);
}
public void backgroundUpdate(Player player) {
@@ -45,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,7 +207,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
@Getter
private boolean ymlError = false;
@Getter
private Timer voteTimer = new Timer();
@@ -216,7 +215,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
private UserManager votingPluginUserManager;
private void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
RewardHandler.getInstance().addDirectlyDefined(directlyDefinedReward);
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
}
public void basicBungeeUpdate() {
@@ -405,7 +404,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
}
public void loadDirectlyDefined() {
RewardHandler.getInstance().getDirectlyDefinedRewards().clear();
getRewardHandler().getDirectlyDefinedRewards().clear();
// AllSites reward
addDirectlyDefinedRewards(new DirectlyDefinedReward("AllSites") {
@@ -1020,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") {
@@ -1044,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
@@ -1070,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,
@@ -1089,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) {
@@ -1110,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;
@@ -1189,8 +1196,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
*/
@Override
public void onUnLoad() {
getSigns().storeSigns();
HandlerList.unregisterAll(plugin);
if (bungeeSettings.isUseBungeecoord()) {
try {
getBungeeHandler().close();
@@ -1198,6 +1203,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
debug(e);
}
}
getSigns().storeSigns();
HandlerList.unregisterAll(plugin);
plugin = null;
}
@@ -1355,8 +1362,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
plugin.debug("Starting background task, current cached users: "
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
placeholders.onUpdate();
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
try {
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
@@ -1444,6 +1449,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
time1 = System.currentTimeMillis();
topVoterHandler.updateTopVoters(tempTopVoter);
placeholders.onUpdate();
setVoteToday(voteToday);
serverData.updateValues();
getSigns().updateSigns();
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin;
import java.util.concurrent.Callable;
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.votingplugin.user.UserManager;
public class VotingPluginMetrics {
@@ -15,7 +14,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
return "True";
} else {
@@ -27,7 +26,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
return "True";
} else {
@@ -39,7 +38,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
return "True";
} else {
@@ -94,7 +93,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
return "True";
} else {
@@ -109,7 +108,7 @@ public class VotingPluginMetrics {
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Day")) {
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Day", s)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Day", s))) {
return "True";
}
@@ -126,7 +125,7 @@ public class VotingPluginMetrics {
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Week")) {
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Week", s)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Week", s))) {
return "True";
}
@@ -143,7 +142,7 @@ public class VotingPluginMetrics {
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Month")) {
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Month", s)
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Month", s))) {
return "True";
}
@@ -163,7 +162,7 @@ public class VotingPluginMetrics {
@Override
public String call() throws Exception {
return "" + RewardHandler.getInstance().getRewards().size();
return "" + plugin.getRewardHandler().getRewards().size();
}
}));
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites", new Callable<String>() {
@@ -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);
}
});
@@ -63,6 +63,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
private HashMap<String, ClientHandler> clientHandles;
private HashMap<String, ClientHandler> redisClientHandles;
@Getter
private Config config;
@@ -78,13 +80,12 @@ 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;
@@ -338,9 +339,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
if (mysql != null) {
mysql.shutdown();
}
if (redis != null) {
redis.destroy();
}
getLogger().info("VotingPlugin disabled");
}
@@ -363,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;
@@ -473,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() {
@@ -514,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);
@@ -569,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;
@@ -718,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);
@@ -778,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");
@@ -810,43 +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);
}
// one time query to insert player
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();
@@ -863,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)) {
@@ -881,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 {
@@ -906,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"));
}
}
@@ -142,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;
}
@@ -531,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() {
@@ -572,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,14 +371,14 @@ public class CommandLoader {
@Override
public void execute(CommandSender sender, String[] args) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
user.cache();
int newTotal = 0;
synchronized (pointLock) {
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 " + newTotal + " points"));
}
});
@@ -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");
}
@@ -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));
}
@@ -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));
@@ -73,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;
@@ -89,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;
@@ -149,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.
*
@@ -262,6 +271,10 @@ public class SpecialRewardsConfig extends YMLFile {
return getData().getBoolean("VoteParty.OnlyOncePerDay");
}
public boolean getVotePartyOnlyOncePerWeek() {
return getData().getBoolean("VoteParty.OnlyOncePerWeek");
}
public boolean getVotePartyResetEachDay() {
return getData().getBoolean("VoteParty.ResetEachDay");
}
@@ -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());
}
}
@@ -1,8 +1,10 @@
package com.bencodez.votingplugin.data;
import java.time.temporal.WeekFields;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import org.bukkit.Bukkit;
@@ -163,6 +165,14 @@ public class ServerData {
return false;
}
public boolean isLastVotePartySameWeek() {
int num = getData().getInt("LastVotePartyWeek", 0);
if (num != plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear())) {
return true;
}
return false;
}
/**
* Next sign number.
*
@@ -264,6 +274,12 @@ public class ServerData {
saveData();
}
public void updateLastVotePartyWeek() {
getData().set("LastVotePartyWeek",
plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear()));
saveData();
}
public int getBungeeVotePartyCurrent() {
return getData().getInt("BungeeVotePartyCurrent");
}
@@ -8,7 +8,6 @@ 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;
@@ -63,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 {
plugin.getLoginTimer().schedule(new TimerTask() {
@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();
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);
}
}
@@ -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;
@@ -192,7 +194,6 @@ public class PlayerVoteListener implements Listener {
}
user.addPoints();
}
user.checkDayVoteStreak(event.isForceBungee());
// other rewards
@@ -200,9 +201,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
@@ -214,14 +216,24 @@ public class PlayerVoteListener implements Listener {
}, 40);
}
}
if (!user.isOnline()) {
user.clearCache();
}
}
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
event.isForceBungee());
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
event.isForceBungee());
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
plugin.getTimer().schedule(new TimerTask() {
@Override
public void run() {
VotingPluginUser user = plugin.getVotingPluginUserManager()
.getVotingPluginUser(UUID.fromString(uuid));
if (!user.isOnline()) {
user.clearCache();
}
}
}, 1000 * 5);
}
plugin.setUpdate(true);
}
@@ -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: "
@@ -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;
@@ -209,7 +208,7 @@ public class VoteSite {
}
public boolean hasRewards() {
return RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
return plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
plugin.getConfigVoteSites().getRewardsPath(key));
}
@@ -240,4 +239,19 @@ public class VoteSite {
return ArrayUtils.getInstance().containsIgnoreCase(plugin.getServerData().getServiceSites(), getServiceSite());
}
public String loadingDebug() {
String str = "Loading votesite key: " + key;
str += ", Displayname: " + displayName;
str += ", VoteDelay: " + getVoteDelay();
str += ", VoteDelayMin: " + getVoteDelayMin();
str += ", VoteDelayDaily: " + isVoteDelayDaily();
str += ", IsWaitUntilVoteDelay: " + isWaitUntilVoteDelay();
str += ", ServiceSite: " + getServiceSite();
str += ", TimeOffSet:" + getTimeOffSet();
str += ", Url: " + getVoteURL();
str += ", IgnoreCanVote: " + isIgnoreCanVote();
str += ", Hidden: " + isHidden();
return str;
}
}
@@ -85,7 +85,9 @@ public class PlaceHolders {
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
placeholdersToSetCacheOn.add(identifier);
}
return "..";
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
return "..";
}
}
}
}
@@ -103,7 +105,11 @@ public class PlaceHolders {
if (cache.containsKey(p.getUniqueId())) {
return cache.get(p.getUniqueId());
} else {
return "....";
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
return "....";
} else {
return placeholder.placeholderRequest(user, identifier);
}
}
} else {
return placeholder.placeholderRequest(user, identifier);
@@ -762,11 +768,11 @@ public class PlaceHolders {
for (String key : keys) {
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
user.dontCache();
vpUser.dontCache();
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(),
placeholder.placeholderRequest(vpUser, ident));
plugin.devDebug("Updated cache for " + vpUser.getUUID() + " on " + key);
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID() + " on " + key);
}
@@ -805,19 +811,15 @@ public class PlaceHolders {
public void onUpdate(VotingPluginUser user) {
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.isUsesCache()) {
if (!placeholder.getIdentifier().startsWith("Top_") || placeholder.getCache().isEmpty()
|| placeholder.getUpdateDataKey().isEmpty()) {
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
for (String ident : placeholder.getCache().keySet()) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
}
}
}
}
public void onUpdate() {
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
while (!placeholdersToSetCacheOn.isEmpty()) {
String toCache = placeholdersToSetCacheOn.poll();
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
@@ -852,24 +854,6 @@ public class PlaceHolders {
}
}
}
for (String uuid : uuids) {
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
user.dontCache();
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
if (placeholder.isUsesCache()) {
if (placeholder.getIdentifier().startsWith("Top_")) {
for (String ident : placeholder.getCache().keySet()) {
if (ident != null) {
placeholder.getCache().get(ident).put(user.getJavaUUID(),
placeholder.placeholderRequest(user, ident));
} else {
plugin.debug("ident null: " + placeholder.getIdentifier());
}
}
}
}
}
}
}
}
@@ -2,13 +2,13 @@ package com.bencodez.votingplugin.specialrewards;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit;
import com.bencodez.advancedcore.api.messages.StringParser;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.bungee.BungeeMessageData;
@@ -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));
}
@@ -277,7 +294,7 @@ public class SpecialRewards {
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(cumulative)).setServer(forceBungee)
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
}
public void giveFirstVoteRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
@@ -287,7 +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));
}
@@ -314,7 +331,7 @@ public class SpecialRewards {
}
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getMilestoneRewardsPath(milestone)).setOnline(online)
.withPlaceHolder("Milestone", "" + milestone).setServer(forceBungee).send(user);
.withPlaceHolder("Milestone", "" + milestone).setServer(forceBungee).send(user);
}
public void giveVoteStreakReward(VotingPluginUser user, boolean online, String type, String string, int votes,
@@ -328,8 +345,7 @@ public class SpecialRewards {
}
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath(type, string)).setOnline(online)
.withPlaceHolder("Type", type).setServer(forceBungee).withPlaceHolder("Streak", "" + votes)
.send(user);
.withPlaceHolder("Type", type).setServer(forceBungee).withPlaceHolder("Streak", "" + votes).send(user);
}
}
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin.test;
import java.util.ArrayList;
import com.bencodez.advancedcore.api.rewards.Reward;
import com.bencodez.advancedcore.api.rewards.RewardHandler;
import com.bencodez.advancedcore.api.rewards.RewardOptions;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.events.PlayerVoteEvent;
@@ -24,13 +23,13 @@ public class VoteTester {
long time1 = System.currentTimeMillis();
ArrayList<Long> timesPerReward = new ArrayList<Long>();
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(name);
Reward reward = RewardHandler.getInstance().getReward(rewardName);
Reward reward = plugin.getRewardHandler().getReward(rewardName);
int rewardsGiven = 0;
for (int i = 0; i < amount; i++) {
long start1 = System.currentTimeMillis();
if (reward.canGiveReward(user, new RewardOptions())) {
rewardsGiven++;
RewardHandler.getInstance().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
plugin.getRewardHandler().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
}
long start2 = System.currentTimeMillis();
timesPerReward.add(start2 - start1);
@@ -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;
@@ -116,7 +115,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
* @param value the value
* @return current total points
*/
public int addPoints(int value) {
public synchronized int addPoints(int value) {
PlayerReceivePointsEvent event = new PlayerReceivePointsEvent(this, value);
Bukkit.getPluginManager().callEvent(event);
@@ -171,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);
}
}
@@ -192,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);
}
}
@@ -217,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);
}
}
@@ -685,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));
}
@@ -702,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()) {
@@ -734,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));
}
@@ -868,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) {
@@ -60,29 +60,40 @@ public class VoteParty implements Listener {
}
public void check(boolean forceBungee) {
if (getTotalVotes() >= getVotesRequired() && ((plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
&& plugin.getServerData().isLastVotePartySameDay())
|| !plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay())) {
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
setTotalVotes(getTotalVotes() - getVotesRequired());
}
if (getTotalVotes() < getVotesRequired()) {
return;
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
&& plugin.getServerData().isLastVotePartySameDay()) {
return;
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerWeek()
&& plugin.getServerData().isLastVotePartySameWeek()) {
return;
}
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
setTotalVotes(getTotalVotes() - getVotesRequired());
}
VotePartyEvent event = new VotePartyEvent();
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
VotePartyEvent event = new VotePartyEvent();
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
giveRewards(forceBungee);
giveRewards(forceBungee);
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired() > 0) {
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
}
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired() > 0) {
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
plugin.getServerData().updateLastVoteParty();
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
plugin.getServerData().updateLastVoteParty();
}
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerWeek()) {
plugin.getServerData().updateLastVotePartyWeek();
}
}
@@ -164,11 +175,9 @@ public class VoteParty implements Listener {
public void giveReward(VotingPluginUser user, boolean online, boolean useBungee) {
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
plugin.getSpecialRewardsConfig().getVotePartyRewardsPath())
.setOnline(online)
.withPlaceHolder("VotesRequired",
"" + plugin.getSpecialRewardsConfig().getVotePartyVotesRequired())
.setServer(useBungee).send(user);
plugin.getSpecialRewardsConfig().getVotePartyRewardsPath()).setOnline(online)
.withPlaceHolder("VotesRequired", "" + plugin.getSpecialRewardsConfig().getVotePartyVotesRequired())
.setServer(useBungee).send(user);
}
public void giveRewards(boolean forceBungee) {
@@ -104,6 +104,7 @@ public class VoteReminding {
public boolean shouldRemind(VotingPluginUser user) {
if (remindersEnabled.containsKey(user.getJavaUUID())) {
if (!remindersEnabled.get(user.getJavaUUID()).booleanValue()) {
return false;
}
}
@@ -115,6 +116,7 @@ public class VoteReminding {
return user.canVoteAny();
}
} else {
plugin.debug(user.getUUID() + " no need to remind because plaeyr has VotingPlugin.NoRemind");
return false;
}
}
@@ -132,7 +134,11 @@ public class VoteReminding {
}
plugin.debug(user.getPlayerName() + " was reminded!");
} else {
plugin.debug("Not reminding for " + user.getUUID());
}
} else {
plugin.debug(user.getUUID() + " has no permission for reminders");
}
}
}