Compare commits

...
29 Commits
Author SHA1 Message Date
BenCodez 8fd206b119 Fixed missing column types for mysql 2023-04-15 20:27:14 -04:00
BenCodez 9c6e514234 Update version number to 6.12 2023-04-15 20:09:36 -04:00
BenCodez eb66ccb90d Fix auto caching placeholders not saving for restarts 2023-04-15 20:07:30 -04:00
BenCodez c004dc6106 Fixed trying to cache invalid placeholders 2023-04-15 19:49:09 -04:00
BenCodez f54ccbd7b2 Improve config some more 2023-04-15 19:35:39 -04:00
BenCodez 8cdd0b713b More optimizations on time changes 2023-04-10 19:34:05 -04:00
BenCodez 2562e749db Optimize time change events even more 2023-04-10 17:49:29 -04:00
BenCodez 1a1e5d84bb Improve time change events performance if settings are disabled 2023-04-10 17:44:15 -04:00
BenCodez d4d23035e3 Update pom.xml 2023-04-07 16:46:56 -04:00
BenCodez 5e334e4a8a Update pom.xml 2023-04-07 16:45:16 -04:00
Ben 22991efccf Delete jitpack.yml 2023-04-07 16:39:51 -04:00
Ben 5341fbc3ba Update README.md 2023-04-07 16:09:53 -04:00
BenCodez 2e0fbd01e6 Check for vanish on vote reminding 2023-04-05 16:44:57 -04:00
BenCodez d1d395d9b3 Reformat config to improve overall look 2023-04-04 19:43:02 -04:00
BenCodez 9aeedac2ad Extra check on background task to make sure plugin is enabled 2023-04-02 19:36:56 -04:00
BenCodez 265ed68e0f Add extra check on background task if plugin is enabled 2023-04-01 15:37:04 -04:00
BenCodez b73daaf917 Improve /vote total all command speeds 2023-04-01 15:36:01 -04:00
BenCodez 39d8e414f4 Fix error on shutdown 2023-03-31 16:58:48 -04:00
BenCodez 693541dd00 Add support for extra items on other GUI's 2023-03-30 20:27:05 -04:00
BenCodez 5dce8031c5 More changes to placeholder caching 2023-03-29 17:32:37 -04:00
BenCodez babef8ccf3 Changes to placeholder caching 2023-03-29 17:10:01 -04:00
BenCodez 7a881206ca Change name of vote party one time commands option to avoid confusion 2023-03-28 19:42:52 -04:00
BenCodez aed8ecca26 Fix command help messages being wrong 2023-03-28 19:15:46 -04:00
BenCodez 25dab3157a Add improved placeholder controls 2023-03-27 20:28:54 -04:00
BenCodez 81d8b535ee Adjust caching setting 2023-03-26 17:47:01 -04:00
BenCodez c94802a141 Add global vote party bungee commands reward and edit commands 2023-03-25 19:56:18 -04:00
BenCodez 85e31f8292 Add config option to always use cache for placeholders - WIP 2023-03-25 19:03:59 -04:00
BenCodez da642cb3b2 Stop background task on plugin disable 2023-03-23 16:44:04 -04:00
BenCodez 96c707eca4 Changes to reloading multiproxy support 2023-03-22 19:26:14 -04:00
36 changed files with 978 additions and 584 deletions

No files matched your search

-17
View File
@@ -2,10 +2,6 @@
Plugin on SpigotMC
https://www.spigotmc.org/resources/votingplugin.15358/
![img](http://badge.henrya.org/spigot/downloads?id=15358&color=green)
![img2](http://badge.henrya.org/spigot/version?id=15358&color=red)
## 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
+13 -7
View File
@@ -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
+246 -216
View File
@@ -4,7 +4,11 @@
# https://github.com/BenCodez/VotingPlugin/wiki
# Config is sorted in sections
# Use Control + F to search with Notepad++
#
###########################################
# User storage
###########################################
# Valid Options:
# - SQLITE
# - FLAT
@@ -33,22 +37,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 +83,9 @@ VoteReminding:
Message: '&cRemember to vote'
Delay: 30
# ------------------------------------------------
# Format
# ------------------------------------------------
###########################################
# Format options
###########################################
# Common PlacesHolders:
# Special PlaceHolders will be commented where available
@@ -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,70 @@ 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
###########################################
# 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 +471,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 +533,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 +591,72 @@ 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
# Limit number of users to load in a second
# Effects background tasks mainly
# set to -1 to disable (default value)
#PlayerDataLoadLimit: 500
##########################################
# 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 +664,28 @@ 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
###########################################
# 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 +696,3 @@ RequestAPI:
DefaultMethod: 'Anvil'
DisabledMethods: []
# Shouldn't need to change this
#AutoKillInvs: true
# Disable checking on world change
# May improve performance
#DisableCheckOnWorldChange: false
+1
View File
@@ -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
+3 -2
View File
@@ -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
+10 -9
View File
@@ -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
View File
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.bencodez</groupId>
<artifactId>votingplugin</artifactId>
<version>6.11.3</version>
<version>6.12</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>
@@ -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);
}
@@ -1389,6 +1389,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
voteReminding.loadRemindChecking();
coolDownCheck.checkEnabled();
placeholders.reload();
setUpdate(true);
}
@@ -1455,57 +1456,64 @@ public class VotingPluginMain extends AdvancedCorePlugin {
int currentDay = LocalDateTime.now().getDayOfMonth();
int currentDataLoad = 0;
for (String uuid : uuids) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = UserManager.getInstance()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.tempCache();
user.getUserData().updateCacheWithTemp();
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
if (plugin != null && plugin.isEnabled()) {
if (uuid != null && !uuid.isEmpty()) {
VotingPluginUser user = UserManager.getInstance()
.getVotingPluginUser(UUID.fromString(uuid), false);
user.dontCache();
user.tempCache();
user.getUserData().updateCacheWithTemp();
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
for (TopVoter top : topVotersToCheck) {
int total = user.getTotal(top);
if (total > 0) {
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
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;
if (dataLoadLimit > 0) {
currentDataLoad++;
if (currentDataLoad >= dataLoadLimit) {
currentDataLoad -= dataLoadLimit;
Thread.sleep(1000);
}
}
}
} else {
return;
}
}
update = false;
@@ -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");
}
@@ -879,6 +888,10 @@ public class VotingPluginBungee extends Plugin implements Listener {
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
}
if (multiproxySocketHandler != null) {
multiproxySocketHandler.getServer().close();
multiproxySocketHandler = null;
}
multiproxySocketHandler = new SocketHandler(getDescription().getVersion(),
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
config.getDebug()) {
@@ -923,10 +936,6 @@ public class VotingPluginBungee extends Plugin implements Listener {
}
getLogger().info("Loaded multi-proxy support");
} else {
if (multiproxySocketHandler != null) {
multiproxySocketHandler.getServer().close();
}
}
}
@@ -1359,7 +1368,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 +1380,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 +1424,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;
}
}
}
@@ -83,6 +83,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 +361,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 +412,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 +469,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");
}
@@ -936,6 +945,10 @@ public class VotingPluginVelocity {
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
}
if (multiproxySocketHandler != null) {
multiproxySocketHandler.getServer().close();
multiproxySocketHandler = null;
}
multiproxySocketHandler = new SocketHandler(
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
config.getMultiProxySocketHostHost(), config.getMultiProxySocketHostPort(), encryptionHandler,
@@ -981,10 +994,6 @@ public class VotingPluginVelocity {
}
getLogger().info("Loaded multi-proxy support");
} else {
if (multiproxySocketHandler != null) {
multiproxySocketHandler.getServer().close();
}
}
}
@@ -1393,9 +1402,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 +1414,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);
@@ -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;
}
}
@@ -30,6 +30,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;
import com.bencodez.advancedcore.api.user.userstorage.DataType;
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
import com.bencodez.advancedcore.api.valuerequest.listeners.BooleanListener;
@@ -255,36 +256,37 @@ 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...");
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 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,
@@ -2205,13 +2207,41 @@ public class CommandLoader {
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);
if (plugin.getOptions().getStorageType().equals(UserStorage.MYSQL)) {
for (TopVoter top : TopVoter.values()) {
int cTotal = 0;
ArrayList<Integer> nums = plugin.getMysql().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;
}
}
} else {
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 (String s : plugin.getConfigFile().getFormatCommandsVoteTotalAll()) {
@@ -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,21 @@ 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 + ".Rewards").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;
@@ -97,6 +99,21 @@ 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 + ".Rewards").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;
@@ -106,6 +108,21 @@ 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 + ".Rewards").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.misc.ArrayUtils;
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
import com.bencodez.votingplugin.VotingPluginMain;
import com.bencodez.votingplugin.user.VotingPluginUser;
@@ -118,6 +119,21 @@ 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 + ".Rewards").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,21 @@ 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 + ".Rewards").setGiveOffline(false)
.send(clickEvent.getPlayer());
}
});
}
if (plugin.getGui().getChestVoteTodayBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
@@ -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;
@@ -84,6 +86,21 @@ 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 + ".Rewards").setGiveOffline(false)
.send(clickEvent.getPlayer());
}
});
}
if (plugin.getGui().getChestVoteTotalBackButton()) {
inv.addButton(plugin.getCommandLoader().getBackButton(user));
}
@@ -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,10 +50,6 @@ 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;
@@ -77,14 +74,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;
@@ -436,6 +425,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.
*
@@ -499,6 +499,17 @@ 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 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,7 +30,7 @@ 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);
}
@@ -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(),
@@ -13,7 +13,6 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@@ -47,17 +46,39 @@ public class PlaceHolders {
public PlaceHolders(VotingPluginMain plugin) {
this.plugin = plugin;
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
}
public void reload() {
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
}
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) {
boolean forceProcess = false;
boolean useCache = true;
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 (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript && p != null) {
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
}
@@ -76,18 +97,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 +128,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);
}
@@ -122,6 +169,7 @@ public class PlaceHolders {
}
return "Not a valid placeholder";
}
public String getPlaceHolder(Player p, String identifier) {
@@ -718,43 +766,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 +854,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;
}
}
}
@@ -44,6 +44,22 @@ 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;
}
}
public String getName() {
if (this.equals(TopVoter.Monthly)) {
@@ -125,25 +125,28 @@ 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()) {
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);
}
}
}
}
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();
}
try {
@@ -156,17 +159,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 +185,18 @@ public class TopVoterHandler implements Listener {
resetVoteShopLimit(shopIdent);
}
}
try {
Thread.sleep(30000);
} catch (InterruptedException e) {
e.printStackTrace();
if (!plugin.getBungeeSettings().isGloblalDataEnabled() && plugin.getBungeeSettings().isUseBungeecoord()) {
// give time for other servers to catch up
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);
@@ -218,34 +224,42 @@ 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()) {
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());
}
}
}
}
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();
}
try {
@@ -259,17 +273,19 @@ 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 +309,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);
@@ -329,31 +345,35 @@ 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()) {
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());
}
}
}
}
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();
}
try {
@@ -366,17 +386,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 +415,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);
@@ -500,8 +521,15 @@ 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;
ArrayList<Integer> nums = plugin.getMysql().getNumbersInColumn(cTop.getColumnName());
for (Integer num : nums) {
cTotal += num.intValue();
}
topVoters.add("Combined total: " + cTotal);
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())
@@ -189,7 +189,7 @@ public class VoteParty implements Listener {
public void giveRewards(VotingPluginUser orgUser, boolean forceBungee) {
MiscUtils.getInstance().broadcast(plugin.getSpecialRewardsConfig().getVotePartyBroadcast());
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyCommands()) {
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
@@ -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();
-4
View File
@@ -1,4 +0,0 @@
install:
- echo "Running a custom install command"
- cd VotingPlugin
- mvn install -DskipTests -P jitpack