Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b217edeadf | ||
|
|
aa4ad384c1 | ||
|
|
8021024b48 | ||
|
|
d3f246d048 | ||
|
|
9c2dfcab06 | ||
|
|
8b4224a034 | ||
|
|
61bf0007c1 | ||
|
|
151559c50e | ||
|
|
2dccf6e790 | ||
|
|
bc510b1ba0 | ||
|
|
0253d86b8d | ||
|
|
59cd31a6c8 | ||
|
|
068b24bd39 | ||
|
|
7f06797f5f | ||
|
|
3e2bdf4772 | ||
|
|
3b049299b1 | ||
|
|
05670bebeb | ||
|
|
81f73590a6 | ||
|
|
163e4cdadb | ||
|
|
512c02e501 | ||
|
|
25ef8ba315 | ||
|
|
8966feb35a | ||
|
|
0d29be48c7 | ||
|
|
bc2827659d | ||
|
|
0a72247a5d | ||
|
|
a102ec3566 | ||
|
|
f91b02d572 | ||
|
|
0f00741151 | ||
|
|
922302082f | ||
|
|
24e1fbb6e5 | ||
|
|
3026a2d48f | ||
|
|
58101bfea0 | ||
|
|
0a9e46ee85 | ||
|
|
fd67e45c58 | ||
|
|
b6af6de2df | ||
|
|
173051829e | ||
|
|
8a9ef4811f | ||
|
|
4fd6d580b1 | ||
|
|
415970101c | ||
|
|
668dcdd8b4 | ||
|
|
bf24533b54 | ||
|
|
b2daada576 | ||
|
|
9dd2c58134 | ||
|
|
7674c68bc7 | ||
|
|
0b3b0b29f5 | ||
|
|
60370a1a83 | ||
|
|
3bf273e854 | ||
|
|
a8e53c9b62 | ||
|
|
3015cd9604 | ||
|
|
839119e0a9 | ||
|
|
409a0665cc | ||
|
|
0549fe9c21 | ||
|
|
f047bb6176 | ||
|
|
ad04b7e966 | ||
|
|
2591cbf029 | ||
|
|
8213e07c74 | ||
|
|
972f9581e3 | ||
|
|
2e17b3defd | ||
|
|
76dbfb8fdf | ||
|
|
8fd206b119 | ||
|
|
9c6e514234 | ||
|
|
eb66ccb90d | ||
|
|
c004dc6106 | ||
|
|
f54ccbd7b2 | ||
|
|
8cdd0b713b | ||
|
|
2562e749db | ||
|
|
1a1e5d84bb | ||
|
|
d4d23035e3 | ||
|
|
5e334e4a8a | ||
|
|
22991efccf | ||
|
|
5341fbc3ba | ||
|
|
2e0fbd01e6 | ||
|
|
d1d395d9b3 | ||
|
|
9aeedac2ad | ||
|
|
265ed68e0f | ||
|
|
b73daaf917 | ||
|
|
39d8e414f4 | ||
|
|
693541dd00 | ||
|
|
5dce8031c5 | ||
|
|
babef8ccf3 | ||
|
|
7a881206ca | ||
|
|
aed8ecca26 | ||
|
|
25dab3157a | ||
|
|
81d8b535ee | ||
|
|
c94802a141 | ||
|
|
85e31f8292 | ||
|
|
da642cb3b2 | ||
|
|
96c707eca4 |
No files matched your search
@@ -2,10 +2,6 @@
|
||||
Plugin on SpigotMC
|
||||
https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/BenCodez/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
@@ -23,19 +19,6 @@ https://github.com/BenCodez/VotingPlugin/blob/master/VotingPlugin/Resources/LICE
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
BACKUP/OLD WAY
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.BenCodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
Versions:
|
||||
LATEST - latest stable release
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# --------------------------
|
||||
##########################################
|
||||
# Bungee Setup
|
||||
# Only if using votingplugin bungee to send votes
|
||||
# REQUIRES RESTART FOR CHANGES TO TAKE EFFECT
|
||||
# --------------------------
|
||||
##########################################
|
||||
|
||||
# Plugin using bungee, requires plugin on bungee server
|
||||
UseBungeecord: false
|
||||
@@ -12,7 +12,7 @@ UseBungeecord: false
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
@@ -62,7 +62,11 @@ Server: PleaseSet
|
||||
# Can edit via /av gui
|
||||
BungeeVotePartyRewards: {}
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# List of commands to run on bungee party
|
||||
# This runs a one time command only
|
||||
BungeeVotePartyGlobalCommands: []
|
||||
|
||||
####################################################################################
|
||||
# Global mysql data handle for between server commmunications
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
@@ -97,8 +101,10 @@ GlobalData:
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# -----------------------------
|
||||
# For socket setup below only
|
||||
# -----------------------------
|
||||
##########################################
|
||||
# For socket setup
|
||||
# Recommend to try PLUGINMESSAGING setup first
|
||||
# Options hidden by default to avoid confusion
|
||||
##########################################
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
+255
-217
@@ -4,10 +4,13 @@
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki
|
||||
# Config is sorted in sections
|
||||
# Use Control + F to search with Notepad++
|
||||
#
|
||||
|
||||
|
||||
###########################################
|
||||
# User storage
|
||||
###########################################
|
||||
# Valid Options:
|
||||
# - SQLITE
|
||||
# - FLAT
|
||||
# - MYSQL
|
||||
DataStorage: SQLITE
|
||||
|
||||
@@ -33,22 +36,10 @@ MySQL:
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# --------------------
|
||||
# AllowUnJoined options
|
||||
# May need to set to true for bungee setup
|
||||
# --------------------
|
||||
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
# VoteReminding
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
|
||||
# Configuration for VoteReminding
|
||||
# By default this should be all setup to work
|
||||
@@ -91,9 +82,9 @@ VoteReminding:
|
||||
Message: '&cRemember to vote'
|
||||
Delay: 30
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
# Format options
|
||||
###########################################
|
||||
|
||||
# Common PlacesHolders:
|
||||
# Special PlaceHolders will be commented where available
|
||||
@@ -305,6 +296,7 @@ Format:
|
||||
# Shop messages when using the /vote shop
|
||||
ShopPurchase: '&aYou bought the %Identifier% for %Points% Points!'
|
||||
ShopFailed: '&cYou do not have %Points% points to purchase this!'
|
||||
ShopNotPurchasable: '&cThis item is not buyable!'
|
||||
|
||||
# User not exist message, from commands such as /vote next (player)
|
||||
UserNotExist: '&cUser does not exist: %player%'
|
||||
@@ -329,11 +321,19 @@ Format:
|
||||
Weekly: 'Weekly'
|
||||
Monthly: 'Monthly'
|
||||
AllTime: 'AllTime'
|
||||
|
||||
# Playernames to not be broadcasted when voting
|
||||
# case sensitive
|
||||
VotingBroadcastBlacklist: []
|
||||
|
||||
# ------------------------------------------------
|
||||
# Playernames to not be broadcasted when broadcast comes from reward file
|
||||
# case sensitive
|
||||
BroadcastBlacklist: []
|
||||
|
||||
###########################################
|
||||
# Top Voter
|
||||
# Top voter rewards available in specialrewards.yml
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
|
||||
# Top voter blacklist
|
||||
# Hide these names from top voter lists
|
||||
@@ -369,150 +369,13 @@ MaxiumNumberOfTopVotersToLoad: 1000
|
||||
StoreTopVoters:
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# ------------------------------------------------
|
||||
# Advanced
|
||||
# Most of these values can be left untouched for most setups
|
||||
# ------------------------------------------------
|
||||
|
||||
# Enable per site cooldown events, requires more resources to use
|
||||
# Requires restart
|
||||
PerSiteCoolDownEvents: false
|
||||
|
||||
# Queue votes during a time change (doesn't apply to bungee voting)
|
||||
# Votes will be given when time change is completed
|
||||
QueueVotesDuringTimeChange: false
|
||||
|
||||
# If true vanished players are treated as if they are offline
|
||||
TreatVanishAsOffline: false
|
||||
|
||||
# If true, cooldown check is disabled
|
||||
DisableCoolDownCheck: false
|
||||
|
||||
# If true, disable PlayerInteractEvent (for clicking signs and skulls)
|
||||
DisableInteractEvent: false
|
||||
|
||||
# If false plugin will use offline player UUIDs
|
||||
OnlineMode: true
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In miliseconds, 1000 = 1 second
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
UseVoteStreaks: true
|
||||
|
||||
# If false, storing best totals will be disabled
|
||||
UseHighestTotals: true
|
||||
|
||||
# If true, /vote will open /vote gui by default
|
||||
UseVoteGUIMainCommand: false
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# If true, items given for rewards are dropped on the ground
|
||||
# If false, items will be given when there is space
|
||||
DropOnFullInv: true
|
||||
|
||||
# If true, allsites will have an extra check to prevent duplicate allsites from being given
|
||||
ExtraAllSitesCheck: false
|
||||
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# Playernames to not be broadcasted when voting
|
||||
# case sensitive
|
||||
VotingBroadcastBlacklist: []
|
||||
|
||||
# Playernames to not be broadcasted when broadcast comes from reward file
|
||||
# case sensitive
|
||||
BroadcastBlacklist: []
|
||||
|
||||
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
|
||||
# Limit monthly votes to number of days of a month multipled by the number of sites
|
||||
LimitMonthlyVotes: false
|
||||
|
||||
# This is an extra safe guard to prevent milestones
|
||||
# from being executed more than once
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# Close inventory on player vote
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
# Requires AddCustomCommand: true to be set
|
||||
CustomCommands:
|
||||
# identifier, not specific name
|
||||
command1:
|
||||
Args:
|
||||
- token
|
||||
# Message to send on command
|
||||
Message: 'token message'
|
||||
# Permission for this command
|
||||
Permission: 'votingplugin.commands.vote.token'
|
||||
# help message
|
||||
HelpMessage: 'See tokens'
|
||||
# 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
|
||||
######################
|
||||
###########################################
|
||||
|
||||
# Debug levels:
|
||||
# NONE
|
||||
@@ -534,16 +397,79 @@ DebugInGame: false
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
# Only update in the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
###########################################
|
||||
# Placeholderapi placeholders settings
|
||||
###########################################
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
# 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
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
# Valid Options:
|
||||
# AUTO - Auto cache after they have been used (Recommended)
|
||||
# SPECIFIC - Only cache certain placeholders
|
||||
# NONE - Don't cache any placeholders
|
||||
PlaceholderCacheLevel: AUTO
|
||||
|
||||
# Placeholder controls
|
||||
# Add _process to end of placeholder to force a return value rather than . or .. if no cached value is ready
|
||||
# Add _nocache to end of placeholder to skip cache and retrive a live value, uses a direct mysql connection, do not use on main thread
|
||||
#
|
||||
|
||||
# Set which placeholders to cache at all times
|
||||
# Use for placeholders to are pulled constantly or on the main thread
|
||||
# Mainly aimed for scoreboards that pull placeholders often
|
||||
# Placeholders may auto cache in certain conditions (if enabled above)
|
||||
# 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
|
||||
|
||||
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
|
||||
# Custom placeholder returns
|
||||
# For the example below use %votingplugin_custom_enoughpoints_5%
|
||||
# DO NOT USE ON MAIN THREAD IF POSSIBLE
|
||||
# Keep everything lowercase
|
||||
#CustomPlaceholderReturns:
|
||||
# 'enoughpoints_5':
|
||||
# 'true': 'User has enough points'
|
||||
# 'false': 'User does not have enough points'
|
||||
|
||||
###########################################
|
||||
# Login options
|
||||
###########################################
|
||||
|
||||
# If true vanished players are treated as if they are offline
|
||||
TreatVanishAsOffline: false
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In miliseconds, 1000 = 1 second
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe
|
||||
WaitUntilLoggedIn: true
|
||||
|
||||
###########################################
|
||||
# Disable/Enable features
|
||||
###########################################
|
||||
|
||||
# If true, cooldown check is disabled
|
||||
DisableCoolDownCheck: false
|
||||
|
||||
# If true, disable PlayerInteractEvent (for clicking signs and skulls)
|
||||
DisableInteractEvent: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
@@ -554,55 +480,57 @@ DisableNoServiceSiteMessage: false
|
||||
# If true fake votes will give points and totals
|
||||
CountFakeVotes: true
|
||||
|
||||
# Give VotingPlugin.Player by default
|
||||
# Requires restart to take affect
|
||||
GiveDefaultPermission: true
|
||||
# Whether or not to disable update checks
|
||||
DisableUpdateChecking: false
|
||||
|
||||
# Permissions given by VotingPlugin.Player by default
|
||||
# Permissions listed here will no be accessible with the default permission
|
||||
DisabledDefaultPermissions: []
|
||||
# Enable per site cooldown events, requires more resources to use
|
||||
# Requires restart
|
||||
PerSiteCoolDownEvents: false
|
||||
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
# Queue votes during a time change (doesn't apply to bungee voting)
|
||||
# Votes will be given when time change is completed
|
||||
QueueVotesDuringTimeChange: false
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
UseVoteStreaks: true
|
||||
|
||||
# If false, storing best totals will be disabled
|
||||
UseHighestTotals: true
|
||||
|
||||
# Enable Geyser prefix support
|
||||
# Geyser support is hit or miss currently
|
||||
# May work best if players vote with prefix
|
||||
GeyserPrefixSupport: false
|
||||
GeyserPrefix: '*'
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note: It takes 30-40 minutes before being able to download the latest build
|
||||
# You can also use /av download
|
||||
AutoDownload: false
|
||||
|
||||
# Whether or not to disable update checks
|
||||
DisableUpdateChecking: false
|
||||
# If false plugin will use offline player UUIDs
|
||||
OnlineMode: true
|
||||
|
||||
# Allow transfer of vote points between players
|
||||
AllowVotePointTransfers: false
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
#DisableCheckOnWorldChange: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
|
||||
# Disable checking permissions on tab complete
|
||||
DisableAdvancedTab: false
|
||||
|
||||
# Load command aliases, such as /avgui
|
||||
# Requires restart to take effect
|
||||
LoadCommandAliases: true
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe
|
||||
WaitUntilLoggedIn: true
|
||||
###########################################
|
||||
# Skull settings
|
||||
###########################################
|
||||
|
||||
# Preload skulls to improve performance for vote top
|
||||
# when using skulls as the item to display players
|
||||
@@ -614,10 +542,53 @@ PreloadSkulls: false
|
||||
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
|
||||
LoadSkulls: true
|
||||
|
||||
# Limit number of users to load in a second
|
||||
# Effects background tasks mainly
|
||||
# set to -1 to disable (default value)
|
||||
#PlayerDataLoadLimit: 500
|
||||
###########################################
|
||||
# Extra checks on vote
|
||||
###########################################
|
||||
|
||||
# If true, allsites will have an extra check to prevent duplicate allsites from being given
|
||||
ExtraAllSitesCheck: false
|
||||
|
||||
# This is an extra safe guard to prevent milestones
|
||||
# from being executed more than once
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
|
||||
# May need to enable this for bungee setups
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
##############################################
|
||||
# Command/Permission settings
|
||||
##############################################
|
||||
|
||||
# Give VotingPlugin.Player by default
|
||||
# Requires restart to take affect
|
||||
GiveDefaultPermission: true
|
||||
|
||||
# Permissions given by VotingPlugin.Player by default
|
||||
# Permissions listed here will no be accessible with the default permission
|
||||
DisabledDefaultPermissions: []
|
||||
|
||||
# If true, /vote will open /vote gui by default
|
||||
UseVoteGUIMainCommand: false
|
||||
|
||||
# Disable checking permissions on tab complete
|
||||
# Could increase performance slightly, but probably not
|
||||
DisableAdvancedTab: false
|
||||
|
||||
# Load command aliases, such as /avgui
|
||||
# Requires restart to take effect
|
||||
LoadCommandAliases: true
|
||||
|
||||
# Use vault for permission checks
|
||||
# May not work on some plugins
|
||||
@@ -629,14 +600,67 @@ UseVaultPermissions: false
|
||||
# - PERMISSION
|
||||
DisabledCommands: []
|
||||
|
||||
# Enable Geyser prefix support
|
||||
GeyserPrefixSupport: false
|
||||
GeyserPrefix: '*'
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
# Allow transfer of vote points between players
|
||||
# Requires restart for command to load
|
||||
# Command: /vote givepoints (player) (points)
|
||||
AllowVotePointTransfers: false
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
# Requires AddCustomCommand: true to be set
|
||||
CustomCommands:
|
||||
# identifier, not specific name
|
||||
command1:
|
||||
Args:
|
||||
- token
|
||||
# Message to send on command
|
||||
Message: 'token message'
|
||||
# Permission for this command
|
||||
Permission: 'votingplugin.commands.vote.token'
|
||||
# help message
|
||||
HelpMessage: 'See tokens'
|
||||
# Forces player to run this command
|
||||
Commands:
|
||||
- tokencommand
|
||||
|
||||
##############################################
|
||||
# Background task settings
|
||||
##############################################
|
||||
|
||||
# Only update in the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Enable to true for extra player checks
|
||||
# Recommend leaving this to false
|
||||
ExtraBackgroundUpdate: false
|
||||
|
||||
##########################################
|
||||
# Inventory controls
|
||||
##########################################
|
||||
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# If true, items given for rewards are dropped on the ground
|
||||
# If false, items will be given when there is space
|
||||
DropOnFullInv: true
|
||||
|
||||
# This will prevent spam clicking GUI's to prevent exploits
|
||||
# Number is time in between clicking in milliseconds
|
||||
SpamClickTime: 150
|
||||
@@ -644,12 +668,32 @@ SpamClickTime: 150
|
||||
# Uncomment to use
|
||||
#SpamClickMessage: '&cDetected spam clicking GUI, closing to prevent exploits'
|
||||
|
||||
# ###############################################################
|
||||
# Deprecated options, don't recommend using any of these
|
||||
|
||||
# Will force GUI's to close on every click
|
||||
AlwaysCloseInventory: false
|
||||
|
||||
# Close inventory on player vote
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# This will close GUI's if you shift click them rather than a regular
|
||||
# This can help prevent exploits
|
||||
CloseGUIOnShiftClick: false
|
||||
|
||||
###########################################
|
||||
# Purge settings
|
||||
###########################################
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
##########################################
|
||||
# Extra options
|
||||
# Options below don't need to be touched
|
||||
##########################################
|
||||
|
||||
# Options for request api
|
||||
# Current methods:
|
||||
# ANVIL
|
||||
@@ -660,9 +704,3 @@ RequestAPI:
|
||||
DefaultMethod: 'Anvil'
|
||||
DisabledMethods: []
|
||||
|
||||
# Shouldn't need to change this
|
||||
#AutoKillInvs: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
#DisableCheckOnWorldChange: false
|
||||
@@ -123,6 +123,7 @@ CHEST:
|
||||
# URL when clicking item in /vote (GUI version)
|
||||
URLText: '%VoteUrl%'
|
||||
# #Add Extra items
|
||||
# This extra item format works across other gui settings below
|
||||
# ExtraItems:
|
||||
# Item1:
|
||||
# Material: DIRT
|
||||
@@ -142,6 +143,10 @@ CHEST:
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
# Extra customization for displaying site names in GUI only
|
||||
#CustomSiteNamesDisplays:
|
||||
# Site1: site name display
|
||||
LoreLine: '%time%'
|
||||
VoteToday:
|
||||
Name: 'VoteToday'
|
||||
Line: '&6%VoteSite% : %Time%'
|
||||
@@ -161,11 +166,17 @@ CHEST:
|
||||
Lore: '&3&lVotes: &3%votes%'
|
||||
# Opens main GUI of the specific player that gets clicked
|
||||
OpenMainGUIOnClick: true
|
||||
# Close GUI when clicking on a player item
|
||||
CloseGUIOnClick: true
|
||||
SwitchItem:
|
||||
Name: '&3Switch TopVoter'
|
||||
Lore: '&bCurrently: %Top%'
|
||||
Material: 'OAK_SIGN'
|
||||
Amount: 1
|
||||
# Top voters for the switch item to use
|
||||
#TopVoters:
|
||||
#- ALLTIME
|
||||
#- MONTHLY
|
||||
# 8 Slots over from the bottom left
|
||||
# Bottom of GUI
|
||||
Slot: 7
|
||||
@@ -176,6 +187,15 @@ CHEST:
|
||||
# Item for player in GUI if use skull is false
|
||||
PlayerItem:
|
||||
Material: 'PAPER'
|
||||
Customization:
|
||||
Enabled: false
|
||||
# List of slots for top voter
|
||||
PlayerSlots: []
|
||||
# Add extra items
|
||||
ExtraItems: {}
|
||||
RemoveBottomBar: false
|
||||
# Set slot for backbutton
|
||||
BackButtonSlot: 0
|
||||
VoteTotal:
|
||||
Name: 'VoteTotal: %player%'
|
||||
BackButton: true
|
||||
@@ -278,6 +298,8 @@ CHEST:
|
||||
OpenVoteURL: false
|
||||
# If true, backbutton will be the last slot of the GUI
|
||||
EndOfGUI: false
|
||||
# If true, this item will become an exit button instead
|
||||
Exit: false
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
@@ -287,6 +309,10 @@ CHEST:
|
||||
VoteShopLimitReached: '&aYou reached your limit'
|
||||
VoteShopRequireConfirmation: false
|
||||
VoteShopDisabled: '&cVote shop disabled'
|
||||
# VoteShop extra items for display only
|
||||
#VoteShopExtraItems:
|
||||
#Item:
|
||||
#...
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
|
||||
@@ -13,7 +13,8 @@ FirstVote:
|
||||
FirstVoteToday: {}
|
||||
|
||||
# All vote rewards
|
||||
# Reward for voting on all sites in one day
|
||||
# One time reward for voting on all sites in one day
|
||||
# Enable ExtraAllSitesCheck if you get double rewards
|
||||
AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
@@ -94,7 +95,7 @@ VoteParty:
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# List of commands to execute, these only execute once.
|
||||
# %player% does not work here
|
||||
Commands: []
|
||||
GlobalCommands: []
|
||||
# Rewards to give per player
|
||||
Rewards:
|
||||
# Uncomment below for online players to be rewarded only
|
||||
|
||||
@@ -24,7 +24,7 @@ Prefix: ''
|
||||
OnlineMode: true
|
||||
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
####################################################################################
|
||||
# Global mysql data handle for between server commmunications
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
@@ -62,7 +62,8 @@ GlobalData:
|
||||
# Time offset for time changes
|
||||
# Must match on all servers
|
||||
TimeHourOffSet: 0
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
####################################################################################
|
||||
|
||||
Debug: false
|
||||
# Have a reward on each server
|
||||
@@ -83,7 +84,7 @@ WhiteListedServers: []
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
@@ -130,22 +131,22 @@ VoteParty:
|
||||
Broadcast: '&aVote party has been reached!'
|
||||
|
||||
|
||||
# ----------------------------
|
||||
##########################################
|
||||
# PLUGINMESSAGING Settings
|
||||
# ----------------------------
|
||||
##########################################
|
||||
|
||||
# Applies to PLUGINMESSAGING only
|
||||
# Votes will be forwarded when specific player is online
|
||||
WaitForUserOnline: false
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# Redis/multi proxy setup
|
||||
# Experimental
|
||||
##########################################
|
||||
# Multi-proxy setup
|
||||
# This is still a WIP, use with caution
|
||||
# Primary server needs votifier and config option enabled
|
||||
# Set socket host on each proxy and primary server set sub proxies
|
||||
# All servers should be on pluginmessaging or sockets setup
|
||||
# ----------------------------
|
||||
##########################################
|
||||
|
||||
# Support for redis
|
||||
# experimental
|
||||
|
||||
+50
-81
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.11.3</version>
|
||||
<version>6.13</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -194,7 +194,6 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>maven-central</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public</url>
|
||||
@@ -211,18 +210,8 @@
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.limework</groupId>
|
||||
<artifactId>redisbungee</artifactId>
|
||||
<version>0.6.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
@@ -265,51 +254,14 @@
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<build.profile.id>prod</build.profile.id>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>jitpack</id>
|
||||
<properties>
|
||||
<build.profile.id>jitpack</build.profile.id>
|
||||
</properties>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod2</id>
|
||||
<properties>
|
||||
@@ -322,42 +274,59 @@
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<id>deploy-snapshot</id>
|
||||
<properties>
|
||||
<build.profile.id>dev</build.profile.id>
|
||||
<build.profile.id>deploy-snapshot</build.profile.id>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>nexus</serverId>
|
||||
<nexusUrl>https://nexus.bencodez.com/nexus/</nexusUrl>
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<properties>
|
||||
<build.profile.id>deploy</build.profile.id>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
|
||||
@@ -302,7 +302,7 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
@@ -385,7 +385,7 @@ public class BungeeHandler implements Listener {
|
||||
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
@@ -457,7 +457,7 @@ public class BungeeHandler implements Listener {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(player));
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
@@ -522,6 +522,16 @@ public class BungeeHandler implements Listener {
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
@@ -567,7 +577,7 @@ public class BungeeHandler implements Listener {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
@@ -600,7 +610,7 @@ public class BungeeHandler implements Listener {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
|
||||
@@ -53,6 +53,7 @@ import com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
|
||||
import com.bencodez.advancedcore.api.skull.SkullHandler;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.logger.Logger;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
@@ -81,6 +82,7 @@ import com.bencodez.votingplugin.placeholders.MVdWPlaceholders;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceHolders;
|
||||
import com.bencodez.votingplugin.signs.Signs;
|
||||
import com.bencodez.votingplugin.specialrewards.SpecialRewards;
|
||||
import com.bencodez.votingplugin.test.VoteTester;
|
||||
import com.bencodez.votingplugin.timequeue.TimeQueueHandler;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterHandler;
|
||||
@@ -144,6 +146,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
@Getter
|
||||
private PlaceHolders placeholders;
|
||||
|
||||
@Getter
|
||||
private VoteTester voteTester;
|
||||
|
||||
@Getter
|
||||
private String profile = "";
|
||||
@@ -223,7 +228,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
public void basicBungeeUpdate() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
user.offVote();
|
||||
user.checkOfflineRewards();
|
||||
}
|
||||
@@ -1012,6 +1017,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
public void onPostLoad() {
|
||||
loadVersionFile();
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
|
||||
voteTester = new VoteTester(plugin);
|
||||
|
||||
loadVoteTimer();
|
||||
|
||||
@@ -1094,11 +1101,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
});
|
||||
getJavascriptEngine().put("VotingPluginHooks", VotingPluginHooks.getInstance());
|
||||
getJavascriptEngine().put("VotingPlugin", this);
|
||||
|
||||
loadTimer();
|
||||
|
||||
// placeholderapi loading
|
||||
placeholders = new PlaceHolders(this);
|
||||
getServerData().updatePlaceholders();
|
||||
placeholders.load();
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
|
||||
@@ -1385,10 +1394,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
placeholders.reload();
|
||||
}
|
||||
|
||||
voteReminding.loadRemindChecking();
|
||||
coolDownCheck.checkEnabled();
|
||||
|
||||
setUpdate(true);
|
||||
}
|
||||
|
||||
@@ -1415,6 +1426,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Loaded Files");
|
||||
}
|
||||
|
||||
@Getter
|
||||
private long lastBackgroundTaskTimeTaken = -1;
|
||||
|
||||
public void update() {
|
||||
if (update || configFile.isAlwaysUpdate()) {
|
||||
if (!updateStarted && plugin != null) {
|
||||
@@ -1429,7 +1443,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
|
||||
try {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
long startTime = System.currentTimeMillis();
|
||||
@@ -1451,69 +1464,71 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
.getTopVoterIgnorePermission();
|
||||
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
// ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
int currentDay = LocalDateTime.now().getDayOfMonth();
|
||||
int currentDataLoad = 0;
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished getting player data in " + time1 + " seconds, " + cols.size()
|
||||
+ " users, " + plugin.getStorageType().toString());
|
||||
time1 = System.currentTimeMillis();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance()
|
||||
.getYearFromMili(time))) {
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils
|
||||
.getInstance().getYearFromMili(time))) {
|
||||
|
||||
times.put(entry.getKey(), LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
times.put(entry.getKey(),
|
||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(time),
|
||||
ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
plugin.getPlaceholders().onUpdate(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
if (dataLoadLimit > 0) {
|
||||
currentDataLoad++;
|
||||
if (currentDataLoad >= dataLoadLimit) {
|
||||
currentDataLoad -= dataLoadLimit;
|
||||
Thread.sleep(1000);
|
||||
if (extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
if (plugin != null) {
|
||||
plugin.getPlaceholders().onUpdate(user);
|
||||
}
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + uuids.size()
|
||||
+ " users, " + plugin.getStorageType().toString() + ", data load limit: "
|
||||
+ dataLoadLimit);
|
||||
time1 = System.currentTimeMillis();
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
topVoterHandler.updateTopVoters(tempTopVoter);
|
||||
placeholders.onUpdate();
|
||||
@@ -1521,17 +1536,22 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
serverData.updateValues();
|
||||
getSigns().updateSigns();
|
||||
|
||||
tempTopVoter = null;
|
||||
|
||||
checkFirstTimeLoaded();
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
plugin.getUserManager().getDataManager().clearNonNeededCachedUsers();
|
||||
plugin.extraDebug("Current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
update = false;
|
||||
|
||||
tempTopVoter = null;
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
lastBackgroundTaskTimeTaken = totalTime;
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (plugin != null) {
|
||||
plugin.getLogger().info("Looks like something went wrong");
|
||||
|
||||
@@ -351,6 +351,14 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("background_task_time_taken", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getLastBackgroundTaskTimeTaken();
|
||||
}
|
||||
}));
|
||||
|
||||
if (!plugin.getBuildNumber().equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("dev_build_number", new Callable<String>() {
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class NonVotedPlayersCache {
|
||||
@@ -53,7 +54,8 @@ public class NonVotedPlayersCache {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File yamlFile = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
@@ -62,9 +64,24 @@ public class NonVotedPlayersCache {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -84,8 +101,8 @@ public class NonVotedPlayersCache {
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class VoteCache {
|
||||
@@ -114,7 +115,9 @@ public class VoteCache {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
File yamlFile = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
@@ -123,9 +126,23 @@ public class VoteCache {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -133,8 +150,8 @@ public class VoteCache {
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -330,6 +331,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
@@ -382,6 +386,9 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
if (!config.getGlobalDataEnabled()) {
|
||||
@@ -439,6 +446,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
getMysql().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastWeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
|
||||
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
|
||||
}
|
||||
@@ -563,7 +572,8 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
method = BungeeMethod.PLUGINMESSAGING;
|
||||
}
|
||||
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getData().getInt("TimeHourOffSet")) {
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getData().getString("TimeZone", ""),
|
||||
config.getData().getInt("TimeHourOffSet")) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
@@ -582,7 +592,7 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
try {
|
||||
lastOnline = Long.valueOf(lastOnlineStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastOnline < 1000
|
||||
@@ -879,6 +889,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(getDescription().getVersion(),
|
||||
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
|
||||
config.getDebug()) {
|
||||
@@ -923,10 +937,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
|
||||
getLogger().info("Loaded multi-proxy support");
|
||||
} else {
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.getServer().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1359,7 +1369,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
return servers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private int votePartyVotes = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int currentVotePartyVotesRequired = 0;
|
||||
|
||||
public void addCurrentVotePartyVotes(int amount) {
|
||||
@@ -1368,10 +1381,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
}
|
||||
|
||||
public void addVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
addCurrentVotePartyVotes(1);
|
||||
public void setCurrentVotePartyVotes(int amount) {
|
||||
votePartyVotes = amount;
|
||||
voteCacheFile.setVotePartyCurrentVotes(votePartyVotes);
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
}
|
||||
|
||||
public void checkVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
if (votePartyVotes >= currentVotePartyVotesRequired) {
|
||||
debug("Vote party reached");
|
||||
addCurrentVotePartyVotes(-currentVotePartyVotesRequired);
|
||||
@@ -1408,6 +1425,14 @@ public class VotingPluginBungee extends Plugin implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void addVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
addCurrentVotePartyVotes(1);
|
||||
|
||||
checkVoteParty();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendVoteParty(String server, ServerInfo serverInfo) {
|
||||
if (!serverInfo.getPlayers().isEmpty()) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
@@ -59,16 +59,51 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
sender.sendMessage(new TextComponent("&aSending status message"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
TextComponent[] msg = new TextComponent[4];
|
||||
TextComponent[] msg = new TextComponent[7];
|
||||
msg[0] = new TextComponent("&avotingpluginbungee reload - Reload plugin");
|
||||
msg[1] = new TextComponent("&avotingpluginbungee reloadmysql - Reload plugin including mysql");
|
||||
msg[2] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
|
||||
msg[3] = new TextComponent("&avotingpluginbungee status - Check socket connection status");
|
||||
msg[4] = new TextComponent("&avotingpluginbungee forcetimechange (timetype) - Force a time change");
|
||||
msg[5] = new TextComponent("&avotingpluginbungee voteparty force - Force a vote party");
|
||||
msg[6] = new TextComponent(
|
||||
"&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes");
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("voteparty")) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("Force")) {
|
||||
bungee.setCurrentVotePartyVotes(bungee.getCurrentVotePartyVotesRequired());
|
||||
bungee.checkVoteParty();
|
||||
sender.sendMessage(new TextComponent("Vote party forced"));
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[1].equalsIgnoreCase("SetVoteCount")) {
|
||||
if (isInt(args[2])) {
|
||||
bungee.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
|
||||
sender.sendMessage(new TextComponent("Set current vote party votes to " + args[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!"));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
if (st == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -2,10 +2,10 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityJSONFile;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
public class NonVotedPlayersCache extends VelocityYMLFile {
|
||||
public class NonVotedPlayersCache extends VelocityJSONFile {
|
||||
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityJSONFile;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class VoteCache extends VelocityYMLFile {
|
||||
public class VoteCache extends VelocityJSONFile {
|
||||
|
||||
public VoteCache(File file) {
|
||||
super(file);
|
||||
|
||||
+61
-10
@@ -59,6 +59,7 @@ import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.advancedcore.bungeeapi.time.BungeeTimeChecker;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
@@ -83,6 +84,7 @@ import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
|
||||
@@ -360,6 +362,9 @@ public class VotingPluginVelocity {
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
@@ -408,6 +413,9 @@ public class VotingPluginVelocity {
|
||||
|
||||
@Override
|
||||
public void onTimeChangedFinished(TimeType type) {
|
||||
if (type.equals(TimeType.MONTH)) {
|
||||
getMysql().copyColumnData(TopVoter.Monthly.getColumnName(), "LastMonthTotal");
|
||||
}
|
||||
getMysql().wipeColumnData(TopVoter.of(type).getColumnName());
|
||||
|
||||
for (RegisteredServer s : getAvailableAllServers()) {
|
||||
@@ -462,6 +470,8 @@ public class VotingPluginVelocity {
|
||||
getMysql().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastWeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastDailyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
|
||||
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
|
||||
}
|
||||
@@ -602,7 +612,8 @@ public class VotingPluginVelocity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getNode("TimeHourOffSet").getInt()) {
|
||||
bungeeTimeChecker = new BungeeTimeChecker(config.getNode("TimeZone").getString(""),
|
||||
config.getNode("TimeHourOffSet").getInt()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
@@ -623,7 +634,7 @@ public class VotingPluginVelocity {
|
||||
try {
|
||||
lastOnline = Long.valueOf(lastOnlineStr);
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastOnline < 1000
|
||||
@@ -743,12 +754,36 @@ public class VotingPluginVelocity {
|
||||
if (mysqlLoaded) {
|
||||
uuidPlayerNameCache = mysql.getRowsUUIDNameQuery();
|
||||
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.json"));
|
||||
|
||||
bungeeTimeChecker.loadTimer();
|
||||
// convert yml file if exists
|
||||
File yamlVoteCacheFile = new File(dataDirectory.toFile(), "votecache.yml");
|
||||
if (yamlVoteCacheFile.exists()) {
|
||||
VelocityYMLFile yamlVoteCache = new VelocityYMLFile(yamlVoteCacheFile);
|
||||
voteCacheFile.setConf(yamlVoteCache.getData());
|
||||
yamlVoteCacheFile.renameTo(new File(dataDirectory.toFile(), "oldvotecache.yml"));
|
||||
VelocityYMLFile oldYamlVoteCache = new VelocityYMLFile(
|
||||
new File(dataDirectory.toFile(), "oldvotecache.yml"));
|
||||
oldYamlVoteCache.setConf(yamlVoteCache.getData());
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(
|
||||
new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
|
||||
new File(dataDirectory.toFile(), "nonvotedplayerscache.json"), this);
|
||||
|
||||
// convert yml file if exists
|
||||
File yamlnonVotedPlayersCacheFile = new File(dataDirectory.toFile(), "nonvotedplayerscache.yml");
|
||||
if (yamlnonVotedPlayersCacheFile.exists()) {
|
||||
VelocityYMLFile yamlnonVotedPlayersCache = new VelocityYMLFile(yamlnonVotedPlayersCacheFile);
|
||||
voteCacheFile.setConf(yamlnonVotedPlayersCache.getData());
|
||||
yamlnonVotedPlayersCacheFile.renameTo(new File(dataDirectory.toFile(), "oldnonvotedplayerscache.yml"));
|
||||
VelocityYMLFile oldYamlnonVotedPlayersCache = new VelocityYMLFile(
|
||||
new File(dataDirectory.toFile(), "oldnonvotedplayerscache.yml"));
|
||||
oldYamlnonVotedPlayersCache.setConf(yamlnonVotedPlayersCache.getData());
|
||||
voteCacheFile.save();
|
||||
}
|
||||
|
||||
bungeeTimeChecker.loadTimer();
|
||||
|
||||
try {
|
||||
for (String key : voteCacheFile.getTimedVoteCache()) {
|
||||
@@ -936,6 +971,10 @@ public class VotingPluginVelocity {
|
||||
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(
|
||||
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
|
||||
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
|
||||
@@ -981,10 +1020,6 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
|
||||
getLogger().info("Loaded multi-proxy support");
|
||||
} else {
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.getServer().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,9 +1428,11 @@ public class VotingPluginVelocity {
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private int votePartyVotes = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int currentVotePartyVotesRequired = 0;
|
||||
private boolean votifierEnabled = true;
|
||||
|
||||
public void addCurrentVotePartyVotes(int amount) {
|
||||
votePartyVotes += amount;
|
||||
@@ -1403,10 +1440,24 @@ public class VotingPluginVelocity {
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
}
|
||||
|
||||
public void setCurrentVotePartyVotes(int amount) {
|
||||
votePartyVotes = amount;
|
||||
voteCacheFile.setVotePartyCurrentVotes(votePartyVotes);
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
}
|
||||
|
||||
private boolean votifierEnabled = true;
|
||||
|
||||
public void addVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
addCurrentVotePartyVotes(1);
|
||||
|
||||
checkVoteParty();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
if (votePartyVotes >= currentVotePartyVotesRequired) {
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
addCurrentVotePartyVotes(-currentVotePartyVotesRequired);
|
||||
|
||||
+36
-2
@@ -65,16 +65,50 @@ public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
String[] msg = new String[4];
|
||||
String[] msg = new String[7];
|
||||
msg[0] = "votingpluginbungee reload - Reload plugin";
|
||||
msg[1] = "votingpluginbungee reloadmysql - Reload plugin including mysql";
|
||||
msg[2] = "votingpluginbungee vote (player) (servicesite) - Send bungee vote";
|
||||
msg[3] = "votingpluginbungee status - Check socket connection status";
|
||||
msg[4] = "&avotingpluginbungee forcetimechange (timetype) - Force a time change";
|
||||
msg[5] = "&avotingpluginbungee voteparty force - Force a vote party";
|
||||
msg[6] = "&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes";
|
||||
for (String m : msg) {
|
||||
source.sendMessage(Component.text(m).color(NamedTextColor.AQUA));
|
||||
}
|
||||
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("voteparty")) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("Force")) {
|
||||
plugin.setCurrentVotePartyVotes(plugin.getCurrentVotePartyVotesRequired());
|
||||
plugin.checkVoteParty();
|
||||
source.sendMessage(Component.text("Vote party forced").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[1].equalsIgnoreCase("SetVoteCount")) {
|
||||
if (isInt(args[2])) {
|
||||
plugin.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
|
||||
source.sendMessage(Component.text("Set current vote party votes to " + args[2])
|
||||
.color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
if (st == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.commands;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -30,6 +31,7 @@ import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
|
||||
@@ -64,7 +66,6 @@ import com.bencodez.votingplugin.commands.gui.player.VoteURLVoteSite;
|
||||
import com.bencodez.votingplugin.commands.tabcompleter.AliasesTabCompleter;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.test.VoteTester;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -92,6 +93,32 @@ public class CommandLoader {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void processSlotClick(Player player, VotingPluginUser user, String slot) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(slot, "url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the adminPerm
|
||||
*/
|
||||
@@ -102,25 +129,32 @@ public class CommandLoader {
|
||||
public BInventoryButton getBackButton(VotingPluginUser user) {
|
||||
ConfigurationSection sec = plugin.getGui().getCHESTBackButton();
|
||||
boolean a = false;
|
||||
boolean exit = false;
|
||||
|
||||
ItemBuilder item;
|
||||
if (sec != null) {
|
||||
item = new ItemBuilder(sec);
|
||||
a = sec.getBoolean("OpenVoteURL", false);
|
||||
exit = sec.getBoolean("Exit");
|
||||
} else {
|
||||
item = new ItemBuilder(Material.BARRIER, 1).setName("&8Back to VoteGUI");
|
||||
}
|
||||
|
||||
final boolean openVoteURL = a;
|
||||
final boolean exitGUI = exit;
|
||||
BInventoryButton b = new BInventoryButton(item) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (!openVoteURL) {
|
||||
new VoteGUI(plugin, event.getWhoClicked(), user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
if (!exitGUI) {
|
||||
if (!openVoteURL) {
|
||||
new VoteGUI(plugin, event.getWhoClicked(), user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
} else {
|
||||
new VoteURL(plugin, event.getWhoClicked(), user, true).open();
|
||||
}
|
||||
} else {
|
||||
new VoteURL(plugin, event.getWhoClicked(), user, true).open();
|
||||
event.closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -255,36 +289,32 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ResyncMilestones" },
|
||||
"VotingPlugin.Commands.AdminVote.ResyncMilestones|" + adminPerm, "Resync Milestones") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting...");
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
user.setMilestoneCount(user.getTotal(TopVoter.AllTime));
|
||||
}
|
||||
sendMessage(sender, "&cFinished sync milestonecount with all time total");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "ResetMilestoneCount" },
|
||||
"VotingPlugin.Commands.AdminVote.ResetMilestoneCount|" + adminPerm,
|
||||
"Resets milestone count to alltimetotal") {
|
||||
.add(new CommandHandler(new String[] { "ResyncMilestones" },
|
||||
"VotingPlugin.Commands.AdminVote.ResyncMilestones|" + adminPerm,
|
||||
"Resync Milestones to all time total") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting to clear milestonecounts...");
|
||||
plugin.getTopVoterHandler().resetMilestoneCount();
|
||||
sendMessage(sender, "&cFinished");
|
||||
sendMessage(sender, "&cStarting...");
|
||||
plugin.getUserManager().copyColumnData(TopVoter.AllTime.getColumnName(), "MilestoneCount");
|
||||
sendMessage(sender, "&cFinished sync milestonecount with all time total");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ResetMilestoneCount" },
|
||||
"VotingPlugin.Commands.AdminVote.ResetMilestoneCount|" + adminPerm, "Resets milestone count to 0") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting to clear milestonecounts...");
|
||||
plugin.getTopVoterHandler().resetMilestoneCount();
|
||||
sendMessage(sender, "&cFinished");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "ResyncMilestonesAlreadyGiven" },
|
||||
"VotingPlugin.Commands.AdminVote.ResyncMilestonesGiven|" + adminPerm,
|
||||
@@ -302,34 +332,46 @@ public class CommandLoader {
|
||||
plugin.getLogger().warning("Failed to get number from " + str);
|
||||
}
|
||||
}
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
for (int num : nums) {
|
||||
if (milestoneCount >= num) {
|
||||
if (!user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender,
|
||||
"&cMilestone " + num + " for " + user.getPlayerName()
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
for (int num : nums) {
|
||||
if (milestoneCount >= num) {
|
||||
if (!user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender, "&cMilestone " + num + " for "
|
||||
+ user.getPlayerName()
|
||||
+ " not already given when it should be, Current AllTimeTotal: "
|
||||
+ user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: "
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, true);
|
||||
}
|
||||
} else {
|
||||
if (user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender,
|
||||
"&cMilestone " + num + " for " + user.getPlayerName()
|
||||
user.setHasGotteMilestone(num, true);
|
||||
}
|
||||
} else {
|
||||
if (user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender, "&cMilestone " + num + " for "
|
||||
+ user.getPlayerName()
|
||||
+ " already given when it shouldn't be, Current AllTimeTotal: "
|
||||
+ user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: "
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, false);
|
||||
}
|
||||
user.setHasGotteMilestone(num, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
sendMessage(sender, "&cFinished");
|
||||
|
||||
}
|
||||
@@ -820,6 +862,31 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ResetAllVotedSites" },
|
||||
"VotingPlugin.Commands.AdminVote.ResetAllVotedSites|" + adminPerm, "Resets all voted") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.resetLastVoted();
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cVoted sites reset for '" + args[1] + "'"));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "ResetVotedSite", "(Sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.ResetVotedSite|" + adminPerm,
|
||||
"Resets last voted for specific site") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.resetLastVoted(plugin.getVoteSite(args[3], false));
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
.colorize("&cVoted site reset for '" + args[1] + "'" + " on " + args[3]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "AddMilestoneCount", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.AddMilestoneCount|" + adminPerm, "Add milestonecount") {
|
||||
@@ -1240,7 +1307,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VoteTester.getInstance().testVotes(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
plugin.getVoteTester().testVotes(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
if (isPlayer(sender)) {
|
||||
sendMessage(sender, "&cSee console for details");
|
||||
}
|
||||
@@ -1253,7 +1320,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VoteTester.getInstance().testSpam(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
plugin.getVoteTester().testSpam(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
if (isPlayer(sender)) {
|
||||
sendMessage(sender, "&cSee console for details");
|
||||
}
|
||||
@@ -1266,7 +1333,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VoteTester.getInstance().testRewards(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
plugin.getVoteTester().testRewards(Integer.parseInt(args[3]), args[1], args[2]);
|
||||
if (isPlayer(sender)) {
|
||||
sendMessage(sender, "&cSee console for details");
|
||||
}
|
||||
@@ -1624,110 +1691,97 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
com.bencodez.advancedcore.thread.Thread.getInstance().run(new Runnable() {
|
||||
loadTabComplete();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
loadTabComplete();
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("Force Vote", new String[] {}, new ItemStack(Material.STONE)) {
|
||||
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("Force Vote", new String[] {}, new ItemStack(Material.STONE)) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
ArrayList<String> voteSites = new ArrayList<String>();
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
voteSites.add(voteSite.getKey());
|
||||
}
|
||||
new ValueRequest().requestString(player, "",
|
||||
ArrayUtils.getInstance().convert(voteSites), true, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
ArrayList<String> voteSites = new ArrayList<String>();
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
voteSites.add(voteSite.getKey());
|
||||
}
|
||||
new ValueRequest().requestString(player, "",
|
||||
ArrayUtils.getInstance().convert(voteSites), true,
|
||||
new StringListener() {
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(value, true),
|
||||
UserGUI.getInstance().getCurrentPlayer(player),
|
||||
plugin.getVoteSiteServiceSite(value), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
player.sendMessage("Forced vote for "
|
||||
+ UserGUI.getInstance().getCurrentPlayer(player) + " on "
|
||||
+ value);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("MileStones", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
String playerName = (String) event.getMeta(player, "Player");
|
||||
BInventory inv = new BInventory("MileStones: " + playerName);
|
||||
for (String mileStoneName : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (StringParser.getInstance().isInt(mileStoneName)) {
|
||||
int mileStone = Integer.parseInt(mileStoneName);
|
||||
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("" + mileStone, new String[] {
|
||||
"Enabled: " + plugin.getSpecialRewardsConfig()
|
||||
.getMilestoneRewardEnabled(mileStone),
|
||||
"&cClick to set wether this has been completed or not" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(value, true),
|
||||
UserGUI.getInstance().getCurrentPlayer(player),
|
||||
plugin.getVoteSiteServiceSite(value), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (StringParser.getInstance().isInt(clickEvent.getClickedItem()
|
||||
.getItemMeta().getDisplayName())) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
int mileStone = Integer.parseInt(clickEvent.getClickedItem()
|
||||
.getItemMeta().getDisplayName());
|
||||
String playerName = (String) event.getMeta(player,
|
||||
"Player");
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(playerName);
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + user.hasGottenMilestone(mileStone),
|
||||
new BooleanListener() {
|
||||
|
||||
player.sendMessage("Forced vote for "
|
||||
+ UserGUI.getInstance().getCurrentPlayer(player)
|
||||
+ " on " + value);
|
||||
@Override
|
||||
public void onInput(Player player,
|
||||
boolean value) {
|
||||
String playerName = UserGUI.getInstance()
|
||||
.getCurrentPlayer(player);
|
||||
VotingPluginUser user = UserManager
|
||||
.getInstance()
|
||||
.getVotingPluginUser(playerName);
|
||||
user.setHasGotteMilestone(mileStone, value);
|
||||
player.sendMessage(
|
||||
"Set milestone completetion to "
|
||||
+ value + " on "
|
||||
+ mileStone);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
UserGUI.getInstance().addPluginButton(plugin,
|
||||
new BInventoryButton("MileStones", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
String playerName = (String) event.getMeta(player, "Player");
|
||||
BInventory inv = new BInventory("MileStones: " + playerName);
|
||||
for (String mileStoneName : plugin.getSpecialRewardsConfig()
|
||||
.getMilestoneVotes()) {
|
||||
if (StringParser.getInstance().isInt(mileStoneName)) {
|
||||
int mileStone = Integer.parseInt(mileStoneName);
|
||||
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("" + mileStone, new String[] {
|
||||
"Enabled: " + plugin.getSpecialRewardsConfig()
|
||||
.getMilestoneRewardEnabled(mileStone),
|
||||
"&cClick to set wether this has been completed or not" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (StringParser.getInstance()
|
||||
.isInt(clickEvent.getClickedItem().getItemMeta()
|
||||
.getDisplayName())) {
|
||||
Player player = clickEvent.getPlayer();
|
||||
int mileStone = Integer
|
||||
.parseInt(clickEvent.getClickedItem()
|
||||
.getItemMeta().getDisplayName());
|
||||
String playerName = (String) event.getMeta(player,
|
||||
"Player");
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(playerName);
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + user.hasGottenMilestone(mileStone),
|
||||
new BooleanListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player,
|
||||
boolean value) {
|
||||
String playerName = UserGUI
|
||||
.getInstance()
|
||||
.getCurrentPlayer(player);
|
||||
VotingPluginUser user = UserManager
|
||||
.getInstance()
|
||||
.getVotingPluginUser(
|
||||
playerName);
|
||||
user.setHasGotteMilestone(mileStone,
|
||||
value);
|
||||
player.sendMessage(
|
||||
"Set milestone completetion to "
|
||||
+ value + " on "
|
||||
+ mileStone);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
@@ -2198,20 +2252,34 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
|
||||
int daily = 0;
|
||||
int weekly = 0;
|
||||
int month = 0;
|
||||
int all = 0;
|
||||
|
||||
for (String uuid : uuids) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
daily += user.getTotal(TopVoter.Daily);
|
||||
weekly += user.getTotal(TopVoter.Weekly);
|
||||
month += user.getTotal(TopVoter.Monthly);
|
||||
all += user.getTotal(TopVoter.AllTime);
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
int cTotal = 0;
|
||||
ArrayList<Integer> nums = plugin.getUserManager().getNumbersInColumn(top.getColumnName());
|
||||
for (Integer num : nums) {
|
||||
cTotal += num.intValue();
|
||||
}
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
all = cTotal;
|
||||
break;
|
||||
case Daily:
|
||||
daily = cTotal;
|
||||
break;
|
||||
case Monthly:
|
||||
month = cTotal;
|
||||
break;
|
||||
case Weekly:
|
||||
weekly = cTotal;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (String s : plugin.getConfigFile().getFormatCommandsVoteTotalAll()) {
|
||||
|
||||
@@ -183,6 +183,17 @@ public class AdminGUI {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder(Material.STONE, 1).setName("&cBackground task time").addLoreLine("&aClick to see")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().sendMessage("Last background task time: " + plugin.getLastBackgroundTaskTimeTaken());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
|
||||
+12
-12
@@ -38,14 +38,14 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "VotingPlugin_" + identifier + " - " + placeholder.getDescription();
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "VotingPlugin_" + identifier + "";
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -56,14 +56,14 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "VotingPlugin_" + identifier + " - " + placeholder.getDescription();
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "VotingPlugin_" + identifier + "";
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -82,26 +82,26 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cPlaceholders:");
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("VotingPlugin_" + identifier + " - " + placeholder.getDescription());
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("VotingPlugin_" + identifier + "");
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("VotingPlugin_" + identifier + " - " + placeholder.getDescription());
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("VotingPlugin_" + identifier + "");
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -40,7 +40,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
@@ -78,20 +78,20 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
placeholderUser = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueList("Commands", plugin.getSpecialRewardsConfig().getVotePartyCommands()) {
|
||||
new EditGUIValueList("Commands", plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, ArrayList<String> value) {
|
||||
|
||||
@@ -13,6 +13,7 @@ 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.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -91,6 +92,22 @@ public class VoteBest extends GUIHandler {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
String guiPath = "VoteBest";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,14 @@ import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
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.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -42,15 +44,15 @@ public class VoteGUI extends GUIHandler {
|
||||
|
||||
String str = plugin.getConfigFile().getVoteTopDefault();
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(slot, "url")) {
|
||||
lore = new String[] { "&aClick me" };
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "next")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteNext(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "last")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteLast(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "total")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteTotal(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "top")) {
|
||||
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterMonthly(1);
|
||||
@@ -136,11 +138,12 @@ public class VoteGUI extends GUIHandler {
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
|
||||
for (String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
for (final String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
ItemBuilder builder = getItemSlot(slot, player);
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 1000, 1000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -158,35 +161,15 @@ public class VoteGUI extends GUIHandler {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, slot);
|
||||
}
|
||||
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui()
|
||||
.getChestVoteGUISlotRewardsPath(slot, event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
|
||||
plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
event.getButton().getLastRewardsPath(player)),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
}
|
||||
@@ -198,12 +181,29 @@ public class VoteGUI extends GUIHandler {
|
||||
item.addPlaceholder("points", "" + user.getPoints());
|
||||
item.addPlaceholder("player", user.getPlayerName());
|
||||
item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
item.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
return item;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
String guiPath = "VoteGUI";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ import org.bukkit.entity.Player;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
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.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -64,7 +66,7 @@ public class VoteLast extends GUIHandler {
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
@@ -97,6 +99,22 @@ public class VoteLast extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteLast";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteLastBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
@@ -11,10 +11,12 @@ import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
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.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -87,9 +89,15 @@ public class VoteNext extends GUIHandler {
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(siteNameDisplay)
|
||||
.setLore(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time", user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
@@ -106,6 +114,22 @@ public class VoteNext extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteNext";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteNextBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ 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.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -55,6 +56,7 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
@@ -91,15 +93,15 @@ public class VoteShop extends GUIHandler {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.closeInventory();
|
||||
}
|
||||
// if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
// event.closeInventory();
|
||||
// }
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
boolean limitPass = true;
|
||||
@@ -142,6 +144,7 @@ public class VoteShop extends GUIHandler {
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,14 +157,27 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
user.sendMessage(plugin.getConfigFile().getFormatShopNotPurchasable());
|
||||
}
|
||||
|
||||
}.dontClose().addData("identifier", identifier).addData("Limit", limit));
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final String str : plugin.getGui().getChestGUIVoteShopExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIVoteShopExtraItems(str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteShopExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteShopBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
|
||||
@@ -13,6 +13,7 @@ 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.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -119,6 +120,22 @@ public class VoteStreak extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
String guiPath = "VoteStreak";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteStreakBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ 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.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
@@ -116,6 +117,22 @@ public class VoteToday extends GUIHandler {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteToday";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTodayBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
|
||||
@@ -2,11 +2,15 @@ package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@@ -17,6 +21,7 @@ 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.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -78,6 +83,15 @@ public class VoteTopVoter extends GUIHandler {
|
||||
.getTopVoter(top).clone();
|
||||
users = topVotes.entrySet();
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<Integer>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
playerSlots.addAll(customizationPlayerSlots);
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", topVoter);
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
@@ -86,6 +100,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
@@ -96,7 +111,8 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
BInventoryButton button = new BInventoryButton(playerItem
|
||||
.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
@@ -107,33 +123,85 @@ public class VoteTopVoter extends GUIHandler {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
} else {
|
||||
getInv().forceClose(clickEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey());
|
||||
|
||||
if (customzationEnabled && !playerSlots.isEmpty()) {
|
||||
button.setSlot(playerSlots.remove());
|
||||
}
|
||||
|
||||
inv.setCloseInv(plugin.getGui().getChestVoteTopCloseGUIOnClick());
|
||||
|
||||
inv.addButton(button);
|
||||
pos++;
|
||||
}
|
||||
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
TopVoter newTops = top;
|
||||
ArrayList<String> tops = plugin.getGui().getChestVoteTopSwitchItemTopVoters();
|
||||
if (!tops.isEmpty()) {
|
||||
for (String name : tops) {
|
||||
newTops.getSwitchItems().add(TopVoter.getTopVoter(name));
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
final TopVoter cur = newTops;
|
||||
if (!customzationEnabled) {
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
if (customzationEnabled) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user)
|
||||
.setSlot(customization.getInt("BackButtonSlot", 0)));
|
||||
} else {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteTop.Customization";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (customization == null || (customzationEnabled && !customization.getBoolean("RemoveBottomBar"))) {
|
||||
inv.setPages(true);
|
||||
}
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -8,11 +8,13 @@ import org.bukkit.entity.Player;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
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.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -65,7 +67,7 @@ public class VoteTotal extends GUIHandler {
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()),
|
||||
1000, 1000) {
|
||||
@@ -84,6 +86,22 @@ public class VoteTotal extends GUIHandler {
|
||||
});
|
||||
}
|
||||
|
||||
String guiPath = "VoteTotal";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTotalBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class VoteURL extends GUIHandler {
|
||||
if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builderAll, 5000, 5000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builderAll, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -190,7 +190,7 @@ public class VoteURL extends GUIHandler {
|
||||
startSlot++;
|
||||
}
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 5000, 5000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -221,7 +221,8 @@ public class VoteURL extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(), "CHEST.VoteURL.ExtraItems." + str + ".Rewards")
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteURL.ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class VoteURLVoteSite extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site)),
|
||||
1000, 1000) {
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
@@ -89,6 +91,10 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private boolean globlalDataEnabled = false;
|
||||
|
||||
@ConfigDataListString(path = "BungeeVotePartyGlobalCommands")
|
||||
@Getter
|
||||
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<String>();
|
||||
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceholderCacheLevel;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -49,18 +50,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean preloadSkulls = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCachePlaceholders")
|
||||
@Getter
|
||||
private boolean autoCachePlaceholders = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
@ConfigDataInt(path = "PlayerDataLoadLimit")
|
||||
@Getter
|
||||
private int playerDataLoadLimit = -1;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
@@ -77,14 +70,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean alwaysUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysWaitForCachePlaceholders")
|
||||
@Getter
|
||||
private boolean alwaysWaitForCachePlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysProcessPlaceholders")
|
||||
@Getter
|
||||
private boolean alwaysProcessPlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
@@ -319,6 +304,26 @@ public class Config extends YMLFile {
|
||||
return str;
|
||||
}
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns() {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns").getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<String>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns(String placeholder) {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<String>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
|
||||
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
|
||||
}
|
||||
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
@@ -436,6 +441,10 @@ public class Config extends YMLFile {
|
||||
"%hours% Hours and %minutes% Minutes");
|
||||
}
|
||||
|
||||
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
|
||||
return PlaceholderCacheLevel.getCache(getData().getString("PlaceholderCacheLevel", "AUTO"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next layout.
|
||||
*
|
||||
@@ -578,10 +587,11 @@ public class Config extends YMLFile {
|
||||
}
|
||||
|
||||
public String getFormatShopFailedMsg() {
|
||||
String msg = getData().getString("Format.ShopFailed", "&cYou do not have %Points% points to purhcase this!");
|
||||
|
||||
return msg;
|
||||
return getData().getString("Format.ShopFailed", "&cYou do not have %Points% points to purhcase this!");
|
||||
}
|
||||
|
||||
public String getFormatShopNotPurchasable() {
|
||||
return getData().getString("Format.ShopNotPurchasable", "&cThis item is not buyable!");
|
||||
}
|
||||
|
||||
public String getFormatShopPurchaseMsg() {
|
||||
|
||||
@@ -191,7 +191,6 @@ public class GUI extends YMLFile {
|
||||
|
||||
public String getChestShopIdentifierRewardsPath(String identifier) {
|
||||
return "CHEST.Shop." + identifier + ".Rewards";
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getChestShopIdentifiers() {
|
||||
@@ -248,8 +247,8 @@ public class GUI extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot) {
|
||||
return "CHEST.VoteGUI." + slot + ".Rewards";
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,6 +268,10 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTopCustomization() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTop.Customization");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
@@ -298,6 +301,14 @@ public class GUI extends YMLFile {
|
||||
public String getChestVoteNextName() {
|
||||
return getData().getString("CHEST.VoteNext.Name", "VoteNext: %player%");
|
||||
}
|
||||
|
||||
public String getChestVoteNextLine() {
|
||||
return getData().getString("CHEST.VoteNext.Line", "%time%");
|
||||
}
|
||||
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
public String getChestVoteRewardName() {
|
||||
return getData().getString("CHEST.VoteRewardName", "VoteReward");
|
||||
@@ -404,6 +415,10 @@ public class GUI extends YMLFile {
|
||||
return getData().getBoolean("CHEST.VoteTop.OpenMainGUIOnClick", true);
|
||||
}
|
||||
|
||||
public boolean getChestVoteTopCloseGUIOnClick() {
|
||||
return getData().getBoolean("CHEST.VoteTop.CloseGUIOnClick", true);
|
||||
}
|
||||
|
||||
public int getChestVoteTopSize() {
|
||||
return getData().getInt("CHEST.VoteTop.Size", 27);
|
||||
}
|
||||
@@ -412,6 +427,11 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteTop.SwitchItem");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteTopSwitchItemTopVoters() {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteTop.SwitchItem.TopVoters", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalAllTimeTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.AllTimeTotal.Item");
|
||||
}
|
||||
@@ -499,6 +519,28 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
public Set<String> getChestGUIExtraItems(String gui) {
|
||||
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteShopExtraItems." + item);
|
||||
}
|
||||
|
||||
public Set<String> getChestGUIVoteShopExtraItems() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteShopExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteShopExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL site name.
|
||||
*
|
||||
|
||||
@@ -19,7 +19,7 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
|
||||
@Getter
|
||||
private String allSitesRewardPath = "AllSites";
|
||||
|
||||
|
||||
@Getter
|
||||
private String almostAllSitesRewardPath = "AlmostAllSites";
|
||||
|
||||
@@ -236,8 +236,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotePartyCommands() {
|
||||
return (ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>());
|
||||
public ArrayList<String> getVotePartyGlobalCommands() {
|
||||
return (ArrayList<String>) getData().getList("VoteParty.GlobalCommands",
|
||||
(ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>()));
|
||||
}
|
||||
|
||||
public boolean getVotePartyCountFakeVotes() {
|
||||
|
||||
@@ -113,7 +113,9 @@ public class CoolDownCheck implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkPerSite(uuid);
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
checkPerSite(uuid);
|
||||
}
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
perSiteTasks.put(uuid, scheduledFuture);
|
||||
|
||||
@@ -30,12 +30,26 @@ public class ServerData {
|
||||
|
||||
public void addAutoCachedPlaceholder(String placeholder) {
|
||||
List<String> p = getAutoCachedPlaceholder();
|
||||
if (!p.contains(placeholder)) {
|
||||
|
||||
if (!ArrayUtils.getInstance().containsIgnoreCase(p, placeholder)) {
|
||||
p.add(placeholder);
|
||||
setAutoCachedPlaceholder(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlaceholders() {
|
||||
boolean data = getData().getBoolean("AutoCacheUpdated", false);
|
||||
if (!data) {
|
||||
List<String> placeholders = getAutoCachedPlaceholder();
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
placeholders.set(i, placeholders.get(i).toLowerCase());
|
||||
}
|
||||
setAutoCachedPlaceholder(placeholders);
|
||||
getData().set("AutoCacheUpdated", true);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
|
||||
@@ -47,6 +47,8 @@ public class PlayerJoinEvent implements Listener {
|
||||
|
||||
user.loginRewards();
|
||||
|
||||
plugin.getPlaceholders().onUpdate(user);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()
|
||||
&& plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("Login", user.getPlayerName(), user.getUUID(),
|
||||
|
||||
@@ -122,7 +122,6 @@ public class PlayerVoteListener implements Listener {
|
||||
final String uuid = user.getUUID();
|
||||
|
||||
// reupdate cache
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
user.updateName(true);
|
||||
@@ -228,7 +227,6 @@ public class PlayerVoteListener implements Listener {
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
|
||||
plugin.extraDebug("Finished vote processing: " + playerName + "/" + uuid);
|
||||
|
||||
@@ -47,17 +47,67 @@ public class PlaceHolders {
|
||||
|
||||
public PlaceHolders(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
onUpdate();
|
||||
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
|
||||
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
@Getter
|
||||
private PlaceholderCacheLevel cacheLevel;
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
return getPlaceHolder(p, identifier, true);
|
||||
}
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier, boolean javascript) {
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier1, boolean javascript) {
|
||||
boolean forceProcess = false;
|
||||
boolean useCache = true;
|
||||
String identifier = identifier1.toLowerCase();
|
||||
boolean custom = false;
|
||||
if (identifier.endsWith("_process")) {
|
||||
forceProcess = true;
|
||||
identifier = identifier.replaceAll("_process", "");
|
||||
}
|
||||
if (identifier.endsWith("_nocache")) {
|
||||
useCache = false;
|
||||
identifier = identifier.replaceAll("_nocache", "");
|
||||
}
|
||||
if (getCacheLevel().equals(PlaceholderCacheLevel.NONE)) {
|
||||
useCache = false;
|
||||
}
|
||||
|
||||
if (identifier.startsWith("custom_")) {
|
||||
custom = true;
|
||||
identifier = identifier.replaceAll("custom_", "");
|
||||
}
|
||||
|
||||
if (custom && plugin.getConfigFile().getCustomPlaceholderReturns().contains(identifier)) {
|
||||
String str = getPlaceholderValue(p, identifier, javascript, true, useCache);
|
||||
String returnStr = plugin.getConfigFile().getCustomPlaceholderReturns(identifier, str);
|
||||
if (!returnStr.isEmpty()) {
|
||||
return returnStr;
|
||||
}
|
||||
return str;
|
||||
} else {
|
||||
return getPlaceholderValue(p, identifier, javascript, forceProcess, useCache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getPlaceholderValue(OfflinePlayer p, String identifier, boolean javascript, boolean forceProcess,
|
||||
boolean useCache) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript && p != null) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
@@ -76,18 +126,25 @@ public class PlaceHolders {
|
||||
if (p == null) {
|
||||
return "no player";
|
||||
}
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (!cachedPlaceholders.contains(identifier)) {
|
||||
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
|
||||
user.setWaitForCache(false);
|
||||
if (!user.isCached()) {
|
||||
user.loadCache();
|
||||
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
}
|
||||
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
|
||||
return "..";
|
||||
if (useCache) {
|
||||
if (!cachedPlaceholders.contains(identifier)) {
|
||||
// not cached placeholder
|
||||
if (!forceProcess) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
return "Not a valid placeholder";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,17 +157,36 @@ public class PlaceHolders {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
try {
|
||||
if (placeholder.matches(identifier)) {
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
} else {
|
||||
if (!plugin.getConfigFile().isAlwaysProcessPlaceholders()) {
|
||||
return "....";
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
if (useCache) {
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
|
||||
if (forceProcess) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
} else {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return ".";
|
||||
}
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
@@ -178,6 +254,47 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("User milestonecount").updateDataKey("MilestoneCount"));
|
||||
|
||||
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
for (String vote : mVotes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
|
||||
final int num = Integer.parseInt(vote);
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("milestone_numberofvotesuntil_" + num) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int toGo = num - user.getMilestoneCount();
|
||||
if (toGo >= 0) {
|
||||
return "" + toGo;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
}.withDescription("Get number of votes until milestone").updateDataKey("MilestoneCount"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("nextmilestone_votes_required") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getNextAvailableMileStone();
|
||||
}
|
||||
}.withDescription("Get number of votes required for next available milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("nextmilestone_votes_until") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int toGo = user.getNextAvailableMileStone() - user.getMilestoneCount();
|
||||
if (toGo >= 0) {
|
||||
return "" + toGo;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
}.withDescription("Get number of votes until next available milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestShopIdentifierLimit(identifier) > 0) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
|
||||
@@ -374,6 +491,18 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("EnoughPoints_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int number = Integer.parseInt(identifier.split("_")[1]);
|
||||
if (user.getPoints() >= number) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
}.withDescription("Return true/false if player has said points").updateDataKey("Points").useStartsWith());
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_AllVotes_") {
|
||||
|
||||
@Override
|
||||
@@ -718,43 +847,27 @@ public class PlaceHolders {
|
||||
|
||||
Set<String> placeholdersSet = new HashSet<String>();
|
||||
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
|
||||
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
|
||||
if (getCacheLevel().equals(PlaceholderCacheLevel.AUTO)) {
|
||||
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
|
||||
}
|
||||
|
||||
for (String toCache : placeholdersSet) {
|
||||
if (toCache.startsWith("VotingPlugin")) {
|
||||
toCache = toCache.substring("VotingPlugin_".length());
|
||||
if (toCache.startsWith("votingplugin")) {
|
||||
toCache = toCache.substring("votingplugin_".length());
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -822,27 +935,46 @@ public class PlaceHolders {
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
public void checkNonCachedPlaceholders() {
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll();
|
||||
String toCache = placeholdersToSetCacheOn.poll().toLowerCase();
|
||||
if (toCache.startsWith("votingplugin")) {
|
||||
toCache = toCache.substring("votingplugin_".length());
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
plugin.extraDebug("Auto Caching placeholder " + toCache);
|
||||
}
|
||||
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
plugin.extraDebug("Auto Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void schedulePlaceholderCheck(VotingPluginUser user) {
|
||||
plugin.getTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkNonCachedPlaceholders();
|
||||
onUpdate(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
checkNonCachedPlaceholders();
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.bencodez.votingplugin.placeholders;
|
||||
|
||||
public enum PlaceholderCacheLevel {
|
||||
NONE, SPECIFC, AUTO;
|
||||
|
||||
public static PlaceholderCacheLevel getCache(String str) {
|
||||
for (PlaceholderCacheLevel v : PlaceholderCacheLevel.values()) {
|
||||
if (v.toString().equalsIgnoreCase(str)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return AUTO;
|
||||
}
|
||||
|
||||
public boolean shouldCache() {
|
||||
switch (this) {
|
||||
case AUTO:
|
||||
return true;
|
||||
case NONE:
|
||||
return false;
|
||||
case SPECIFC:
|
||||
return false;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.bencodez.votingplugin.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@@ -8,18 +10,17 @@ import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTester {
|
||||
|
||||
private static VoteTester instance = new VoteTester();
|
||||
|
||||
public static VoteTester getInstance() {
|
||||
return instance;
|
||||
public VoteTester(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public void testRewards(int amount, String name, String rewardName) {
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
@@ -59,6 +60,47 @@ public class VoteTester {
|
||||
|
||||
}
|
||||
|
||||
private String getSaltString() {
|
||||
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
StringBuilder salt = new StringBuilder();
|
||||
Random rnd = new Random();
|
||||
while (salt.length() < 18) { // length of the random string.
|
||||
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
|
||||
salt.append(SALTCHARS.charAt(index));
|
||||
}
|
||||
String saltStr = salt.toString();
|
||||
return saltStr;
|
||||
|
||||
}
|
||||
|
||||
public void generatePlayers(int numberOfPlayers) {
|
||||
if (plugin.getOptions().getDebug().isDebug()) {
|
||||
int num = 1;
|
||||
String salt = getSaltString();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < numberOfPlayers; i++) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
if (!plugin.getUserManager().userExist(uuid)) {
|
||||
String playerName = salt + num;
|
||||
if (!plugin.getUserManager().userExist(playerName)) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid,
|
||||
playerName);
|
||||
user.dontCache();
|
||||
user.setPoints(random.nextInt(100));
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
user.setTotal(top, random.nextInt(1000));
|
||||
}
|
||||
user.setMilestoneCount(random.nextInt(100));
|
||||
user.setPlayerName(playerName);
|
||||
user.updateName(true);
|
||||
num++;
|
||||
plugin.debug("Generated user " + uuid.toString() + "/" + playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testVotes(int amount, String name, String site) {
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ import java.util.ArrayList;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum TopVoter {
|
||||
AllTime, Monthly, Weekly, Daily;
|
||||
|
||||
@@ -45,6 +47,25 @@ public enum TopVoter {
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastColumnName() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return null;
|
||||
case Daily:
|
||||
return "LastDailyTotal";
|
||||
case Monthly:
|
||||
return "LastMonthTotal";
|
||||
case Weekly:
|
||||
return "LastWeeklyTotal";
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ArrayList<TopVoter> switchItems = new ArrayList<TopVoter>();
|
||||
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return VotingPluginMain.plugin.getConfigFile().getFormatTopVoterMonthly();
|
||||
@@ -59,18 +80,23 @@ public enum TopVoter {
|
||||
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
if (switchItems != null && !switchItems.isEmpty()) {
|
||||
list.addAll(switchItems);
|
||||
} else {
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int next = i + 1;
|
||||
@@ -85,17 +111,21 @@ public enum TopVoter {
|
||||
|
||||
public TopVoter prev() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
if (switchItems != null && !switchItems.isEmpty()) {
|
||||
list.addAll(switchItems);
|
||||
} else {
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
if (list.get(i).equals(this)) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.PreDateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
@@ -87,14 +88,26 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
plugin.getLastMonthTopVoter().clear();
|
||||
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user.getTopVoterPlayer(), total);
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getLastMonthTopVoter().putAll(sortByValues(totals, false));
|
||||
|
||||
@@ -113,7 +126,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@@ -125,25 +137,31 @@ public class TopVoterHandler implements Listener {
|
||||
storeTopVoters(TopVoter.Daily);
|
||||
}
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
|
||||
if (user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Daily.getColumnName(), TopVoter.Daily.getLastColumnName());
|
||||
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
|
||||
if (user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestDailyTotal() < user.getTotal(TopVoter.Daily)) {
|
||||
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestDailyTotal() < user.getTotal(TopVoter.Daily)) {
|
||||
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
user.clearTempCache();
|
||||
cols.clear();
|
||||
cols = null;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -156,17 +174,17 @@ public class TopVoterHandler implements Listener {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Daily).clone();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
user.giveDailyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
@@ -182,15 +200,9 @@ public class TopVoterHandler implements Listener {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Thread.sleep(30000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
@@ -205,7 +217,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
@@ -218,34 +229,45 @@ public class TopVoterHandler implements Listener {
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
plugin.getLogger().info("Saving TopVoters Monthly");
|
||||
storeTopVoters(TopVoter.Monthly);
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Monthly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
|
||||
LocalDateTime.now().minusDays(1))) {
|
||||
user.addMonthVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Month",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
if (!bungeeHandleResets()) {
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Monthly.getColumnName(),
|
||||
TopVoter.Monthly.getLastColumnName());
|
||||
}
|
||||
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Monthly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
|
||||
LocalDateTime.now().minusDays(1))) {
|
||||
user.addMonthVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Month",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
|
||||
// using new system
|
||||
// user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
|
||||
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
|
||||
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
user.clearTempCache();
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -259,17 +281,18 @@ public class TopVoterHandler implements Listener {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Monthly).clone();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (places.containsKey(i)) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
user.giveMonthlyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
@@ -293,7 +316,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
if (!bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
@@ -308,7 +331,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
}
|
||||
@@ -329,31 +351,38 @@ public class TopVoterHandler implements Listener {
|
||||
storeTopVoters(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Weekly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementWeek(), null)) {
|
||||
user.addWeekVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Week",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Weekly.getColumnName(),
|
||||
TopVoter.Weekly.getLastColumnName());
|
||||
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(playerData.getKey(), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Weekly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementWeek(), null)) {
|
||||
user.addWeekVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Week",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
|
||||
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
|
||||
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
user.clearTempCache();
|
||||
cols.clear();
|
||||
cols = null;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -366,17 +395,18 @@ public class TopVoterHandler implements Listener {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Weekly).clone();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
|
||||
user.giveWeeklyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
@@ -394,7 +424,7 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
@@ -409,7 +439,6 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
@@ -500,8 +529,19 @@ public class TopVoterHandler implements Listener {
|
||||
file.setup();
|
||||
file.header("Saving top voters for " + top.toString() + ", file also contains other top voter info as backup");
|
||||
for (TopVoter cTop : TopVoter.values()) {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int cTotal = 0;
|
||||
try {
|
||||
ArrayList<Integer> nums = plugin.getUserManager().getNumbersInColumn(cTop.getColumnName());
|
||||
for (Integer num : nums) {
|
||||
cTotal += num.intValue();
|
||||
}
|
||||
topVoters.add("Combined total: " + cTotal);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (plugin.getTopVoter().containsKey(cTop)) {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
|
||||
int count = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(cTop).entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
|
||||
@@ -55,6 +55,8 @@ public class UserManager {
|
||||
manager.addKey(new UserDataKeyInt("HighestMonthlyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("HighestWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastMonthTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastDailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("BestMonthVoteStreak"));
|
||||
if (plugin.getOptions().isPerServerRewards()) {
|
||||
manager.addKey(new UserDataKeyString("OfflineRewards" + plugin.getOptions().getServer())
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -271,10 +272,24 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() || now.getYear() != lastVote.getYear()) {
|
||||
return true;
|
||||
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
|
||||
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
|
||||
if (!now.isBefore(offsetoclocktoday)) {
|
||||
if (!lastVote.isBefore(offsetoclocktoday)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!lastVote.isBefore(offsetoclockyesterday)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -1000,6 +1015,40 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
|
||||
public int getNextAvailableMileStone() {
|
||||
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
int mileStoneCount = getMilestoneCount();
|
||||
HashMap<String, Boolean> gottenMileStones = getHasGottenMilestone();
|
||||
for (String vote : mVotes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
final int num = Integer.parseInt(vote);
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
|
||||
if (gottenMileStones.containsKey("" + num)) {
|
||||
if (!gottenMileStones.get("" + num).booleanValue()) {
|
||||
nums.add(Integer.valueOf(num));
|
||||
}
|
||||
} else {
|
||||
nums.add(Integer.valueOf(num));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int lowestNum = -1;
|
||||
|
||||
for (Integer num : nums) {
|
||||
if (mileStoneCount < num.intValue()) {
|
||||
if (lowestNum == -1 || num.intValue() < lowestNum) {
|
||||
lowestNum = num.intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lowestNum;
|
||||
|
||||
}
|
||||
|
||||
public void setReminded(boolean reminded) {
|
||||
getUserData().setString("Reminded", "" + reminded);
|
||||
}
|
||||
@@ -1380,4 +1429,18 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return shortest;
|
||||
}
|
||||
|
||||
public void resetLastVoted() {
|
||||
HashMap<VoteSite, Long> map = getLastVotes();
|
||||
for (Entry<VoteSite, Long> e : map.entrySet()) {
|
||||
e.setValue(0l);
|
||||
}
|
||||
setLastVotes(map);
|
||||
}
|
||||
|
||||
public void resetLastVoted(VoteSite site) {
|
||||
HashMap<VoteSite, Long> map = getLastVotes();
|
||||
map.put(site, 0l);
|
||||
setLastVotes(map);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.voteparty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -186,15 +187,29 @@ public class VoteParty implements Listener {
|
||||
.setServer(useBungee).send(user);
|
||||
}
|
||||
|
||||
public String getRandomPlayerName() {
|
||||
ArrayList<String> allPlayers = new ArrayList<String>();
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
allPlayers.add(players.getName());
|
||||
}
|
||||
if (allPlayers.size() == 0) {
|
||||
return "No Player";
|
||||
}
|
||||
int random = new Random().nextInt(allPlayers.size());
|
||||
return allPlayers.get(random);
|
||||
}
|
||||
|
||||
public void giveRewards(VotingPluginUser orgUser, boolean forceBungee) {
|
||||
MiscUtils.getInstance().broadcast(plugin.getSpecialRewardsConfig().getVotePartyBroadcast());
|
||||
|
||||
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyCommands()) {
|
||||
String player = getRandomPlayerName();
|
||||
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
|
||||
StringParser.getInstance().replacePlaceHolder(cmd, "randomonlineplayer", player));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -73,7 +73,9 @@ public class VoteReminding {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
checkRemind(user);
|
||||
if (!plugin.getOptions().isTreatVanishAsOffline() || !user.isVanished()) {
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
timer.shutdown();
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
install:
|
||||
- echo "Running a custom install command"
|
||||
- cd VotingPlugin
|
||||
- mvn install -DskipTests -P jitpack
|
||||
Reference in new issue
Block a user