Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84e415e4bc | ||
|
|
54bbc8c740 | ||
|
|
7b1ab7e833 | ||
|
|
acb8f8a43f | ||
|
|
279759b52f | ||
|
|
02ca0b1fc8 | ||
|
|
d57e3d1006 | ||
|
|
d54769eb82 | ||
|
|
35f6a3df15 | ||
|
|
46b66466ba | ||
|
|
53fbe4e5e2 | ||
|
|
53ef7a7086 | ||
|
|
b0e08721fa | ||
|
|
29dad6ca25 | ||
|
|
7c3e5eb09b | ||
|
|
a7776ec97c | ||
|
|
d598082c0a | ||
|
|
4539b5b22a | ||
|
|
02fe645d1e | ||
|
|
ee8af6a314 | ||
|
|
a4b78c7d16 | ||
|
|
d22fe462e5 | ||
|
|
c19182a2b4 | ||
|
|
6905c3988b | ||
|
|
23be120adc | ||
|
|
dae863f88f | ||
|
|
d12f73d2fa | ||
|
|
316ee90713 | ||
|
|
1495fad96f | ||
|
|
8e0de1709b | ||
|
|
ad22802e10 | ||
|
|
6de0345f06 | ||
|
|
7338a7d8ba | ||
|
|
3ca12f2c91 | ||
|
|
262e7c48c7 | ||
|
|
0b62d99f9d | ||
|
|
ea30de47d1 | ||
|
|
a76daf3aba | ||
|
|
e1ff13f4bf | ||
|
|
12f941cf83 | ||
|
|
243377a76a | ||
|
|
d7eab03860 | ||
|
|
ddd1f473f1 | ||
|
|
3e52bb0936 | ||
|
|
eb60220b1e | ||
|
|
00902bd597 | ||
|
|
d3606088cd | ||
|
|
ef2512e4e2 | ||
|
|
7f95a1c7c3 | ||
|
|
68a2fe27ff | ||
|
|
b05317c460 | ||
|
|
62fee6f347 | ||
|
|
ef7d4254e1 | ||
|
|
b6720ccc1f | ||
|
|
69d3d33008 | ||
|
|
7a193c87a9 | ||
|
|
f2cf2fb734 | ||
|
|
836079b5ea | ||
|
|
a7f6456480 | ||
|
|
82f25c3899 | ||
|
|
cb2cdbd4fc | ||
|
|
40d2b651a8 | ||
|
|
a999d9e9bb | ||
|
|
b144f2db9c | ||
|
|
24060a10ed | ||
|
|
4c8919804f | ||
|
|
66618260bb | ||
|
|
f441ede6b0 | ||
|
|
593ae76354 | ||
|
|
aa49dc5bc1 | ||
|
|
8941d909ca | ||
|
|
2946792dec | ||
|
|
0567f0ac66 | ||
|
|
fe78992477 | ||
|
|
195e1c82bd | ||
|
|
9479fe06c0 | ||
|
|
0807caed98 | ||
|
|
9fdcf5aa78 | ||
|
|
8d26e66dc0 | ||
|
|
14e61ba6bf | ||
|
|
6d361cc83f | ||
|
|
1e32fd65e0 | ||
|
|
5f0d8fff2f | ||
|
|
0d828a99bc | ||
|
|
0e8bd23784 | ||
|
|
a8af2a49ad | ||
|
|
54b08019ec | ||
|
|
27f01a6c3a | ||
|
|
337aab384f | ||
|
|
a94e1c1dd6 | ||
|
|
1445d97ce0 | ||
|
|
9e8abe0768 | ||
|
|
ca92a76b15 | ||
|
|
637c8a158b | ||
|
|
85b1ed9916 | ||
|
|
389c9a138e | ||
|
|
7dc5c32db3 | ||
|
|
dcc1e375a9 | ||
|
|
176373e2a4 | ||
|
|
2cd7d5db00 | ||
|
|
05fc747557 | ||
|
|
528ca45b26 | ||
|
|
b4b420479e | ||
|
|
10a44f5999 | ||
|
|
03f012eef4 | ||
|
|
e302c29a9e | ||
|
|
9d7454f9c3 | ||
|
|
0731288028 | ||
|
|
bb061c400f | ||
|
|
0ef664efcd | ||
|
|
0a6c64f9a1 | ||
|
|
3fd328ed91 | ||
|
|
4923ca6f64 | ||
|
|
7e88e4350d | ||
|
|
04ea20b2c2 | ||
|
|
8491e2e45b | ||
|
|
88c1d91675 | ||
|
|
c45c9dc970 | ||
|
|
63807f2617 | ||
|
|
bfeb112774 | ||
|
|
d45119ccca | ||
|
|
7d5f64636b | ||
|
|
fbb61808ba | ||
|
|
800c89f240 | ||
|
|
20cc999f0d | ||
|
|
3604abb307 | ||
|
|
4b56d642e5 | ||
|
|
81f0d46aea | ||
|
|
a2f7336b53 | ||
|
|
38ae2c32dc | ||
|
|
d6b2d21e7c | ||
|
|
83bcae4a59 | ||
|
|
b9c862580b | ||
|
|
c30f725ed2 | ||
|
|
ca8eb546a5 | ||
|
|
0335608162 | ||
|
|
593899a434 | ||
|
|
8eb8d746d9 | ||
|
|
b8ef63c9ba | ||
|
|
dfb8610489 | ||
|
|
3801059cf6 | ||
|
|
2b3aea7f83 | ||
|
|
af42aa4b50 | ||
|
|
2d2b35522e | ||
|
|
2a586324d4 | ||
|
|
5bd9c926ba | ||
|
|
e76c30fca2 | ||
|
|
e42bd3725a | ||
|
|
660c8d9501 | ||
|
|
44a65bc347 | ||
|
|
f3d27f4816 | ||
|
|
4c3891fa0a | ||
|
|
5072265549 | ||
|
|
788b58f9cd | ||
|
|
0db34f815f | ||
|
|
900237b7ea | ||
|
|
7fa7c2baf9 | ||
|
|
eec8d706ee | ||
|
|
d292ae4a18 | ||
|
|
f7d04f87db | ||
|
|
59e2f3da99 | ||
|
|
2a5b6c23da | ||
|
|
62560be2ab | ||
|
|
64993b8b53 | ||
|
|
18c4cd6b6d | ||
|
|
35e14f7a76 | ||
|
|
5c6490159b | ||
|
|
29f0c19a74 | ||
|
|
664500d61b | ||
|
|
e208cdf49b | ||
|
|
e295795ec4 | ||
|
|
c9d24b5e88 | ||
|
|
f09311e6fc | ||
|
|
02ea389f12 | ||
|
|
14ccfa3730 | ||
|
|
51ffe88557 | ||
|
|
7daa0545f3 | ||
|
|
ef7b9cb55a | ||
|
|
a410567de0 | ||
|
|
f00aeab649 | ||
|
|
a4494fc2e7 | ||
|
|
6333760508 | ||
|
|
012547f950 | ||
|
|
631d9c9a1c | ||
|
|
a61e3176a8 | ||
|
|
c013835725 | ||
|
|
ea8ed1e950 | ||
|
|
7dcb3a5f62 | ||
|
|
ed70727a76 | ||
|
|
3418d461e4 | ||
|
|
1e5ec8226a | ||
|
|
993fa19f85 | ||
|
|
7d3d777cb5 | ||
|
|
9829864a96 | ||
|
|
eec87f642f | ||
|
|
9cba16814a | ||
|
|
44ebd17356 |
No files matched your search
@@ -8,10 +8,23 @@ https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
https://github.com/BenCodez/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
|
||||
### Maven:
|
||||
|
||||
<repository>
|
||||
<id>BenCodez Repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
BACKUP/OLD WAY
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
@@ -26,6 +39,5 @@ https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/Resources
|
||||
|
||||
Versions:
|
||||
LATEST - latest stable release
|
||||
BRANCH-SNAPHSOT - unstable builds
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="Resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -1,3 +1,7 @@
|
||||
/bin/
|
||||
/target/
|
||||
/doc/
|
||||
/doc/
|
||||
/.idea/
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
@@ -1,7 +0,0 @@
|
||||
add_todo=false
|
||||
eclipse.preferences.version=1
|
||||
include_subpackages=true
|
||||
mode=mode_replace
|
||||
project_specific_settings=true
|
||||
replacements=<?xml version\="1.0" standalone\="yes"?>\n\n<replacements>\n<replacement key\="get" scope\="1" mode\="0">Gets the</replacement>\n<replacement key\="set" scope\="1" mode\="0">Sets the</replacement>\n<replacement key\="add" scope\="1" mode\="0">Adds the</replacement>\n<replacement key\="edit" scope\="1" mode\="0">Edits the</replacement>\n<replacement key\="remove" scope\="1" mode\="0">Removes the</replacement>\n<replacement key\="init" scope\="1" mode\="0">Inits the</replacement>\n<replacement key\="parse" scope\="1" mode\="0">Parses the</replacement>\n<replacement key\="create" scope\="1" mode\="0">Creates the</replacement>\n<replacement key\="build" scope\="1" mode\="0">Builds the</replacement>\n<replacement key\="is" scope\="1" mode\="0">Checks if is</replacement>\n<replacement key\="print" scope\="1" mode\="0">Prints the</replacement>\n<replacement key\="has" scope\="1" mode\="0">Checks for</replacement>\n</replacements>\n\n
|
||||
use_internal_formatter=true
|
||||
@@ -1,4 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=Cp1252
|
||||
encoding/Resources=Cp1252
|
||||
encoding/src=Cp1252
|
||||
@@ -1,30 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
@@ -1,4 +0,0 @@
|
||||
activeProfiles=dev
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -1,3 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
project.repository.kind=github
|
||||
project.repository.url=http\://github.com/Ben12345rocks/VotingPlugin
|
||||
@@ -1,8 +0,0 @@
|
||||
DELEGATES_PREFERENCE=delegateValidatorList
|
||||
USER_BUILD_PREFERENCE=enabledBuildValidatorList
|
||||
USER_MANUAL_PREFERENCE=enabledManualValidatorList
|
||||
USER_PREFERENCE=overrideGlobalPreferencesfalse
|
||||
eclipse.preferences.version=1
|
||||
override=false
|
||||
suspend=false
|
||||
vf.version=3
|
||||
@@ -1,2 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.jboss.ide.eclipse.as.core.singledeployable.deployableList=\n
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -29,12 +29,21 @@ BungeeBroadcast: false
|
||||
# Whether to broadcast on cached votes
|
||||
BungeeBroadcastAlways: false
|
||||
|
||||
# If true, the server won't broadcast votes
|
||||
# To be used in conjuction with Broadcast setting on bungee
|
||||
DisableBroadcast: false
|
||||
|
||||
# If true, offline rewards will be stored per server, rather than global
|
||||
# This shouldn't need to be set unless you get alot of cross server rewards issues
|
||||
# You can also specify the server within the rewards
|
||||
# Requires server name below to be correct
|
||||
PerServerRewards: false
|
||||
|
||||
# If true, milestones work per server
|
||||
# Please note totals still sync, but milestones can be claimed on each server
|
||||
# Needs to be set across all needed servers
|
||||
PerServerMilestones: false
|
||||
|
||||
# If true, points will be given on a per server level
|
||||
# Points will be added when server gets vote from bungee
|
||||
PerServerPoints: false
|
||||
@@ -47,18 +56,14 @@ TriggerVotifierEvent: false
|
||||
# Also can be applied to rewards
|
||||
Server: PleaseSet
|
||||
|
||||
# Rewards from bungee vote party
|
||||
# Gives to only players only
|
||||
# Use regular voteparty rewards otherwise
|
||||
# Can edit via /av gui
|
||||
BungeeVotePartyRewards: {}
|
||||
|
||||
# -----------------------------
|
||||
# For socket setup below only
|
||||
# -----------------------------
|
||||
|
||||
# Bungee communication, add bungee host/port here
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add this to bungee server
|
||||
# For socket method
|
||||
SpigotServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
@@ -22,40 +22,14 @@ MySQL:
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Maxium size of caching mysql
|
||||
# -1 for no limit
|
||||
# Affecting this value may affect performance
|
||||
MaxSize: -1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
# Don't use with PLUGINMESSAGING bungee setup
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#MaxLifeTime: -1
|
||||
#Additional info on connection string
|
||||
#Line: ''
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Mysql cache options
|
||||
# Clearing cache forces the plugin to pull from database
|
||||
# Not needed unless you are using multiple servers
|
||||
# If using a bungee setup most of these options are overriden automatically
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# Clear cache on update, setting to true reduces update speed
|
||||
# Also may require AlwaysUpdate set to true
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clear cache on player join always
|
||||
ClearCacheOnJoin: false
|
||||
|
||||
# Clears cache for the player who voted only
|
||||
# Only effects if using mysql
|
||||
# Would recommend for some bungee setups
|
||||
ClearCacheOnVote: false
|
||||
|
||||
# Clear cache when player leaves
|
||||
ClearCacheOnLeave: false
|
||||
|
||||
ClearCacheOnVoteShopPurchase: true
|
||||
|
||||
# --------------------
|
||||
# AllowUnJoined options
|
||||
@@ -76,33 +50,34 @@ AllowUnJoinedCheckServer: true
|
||||
|
||||
# Configuration for VoteReminding
|
||||
# By default this should be all setup to work
|
||||
# as long as vote delays are done properly
|
||||
# as long as vote delays are done properly in votesites.yml
|
||||
VoteReminding:
|
||||
# Enable vote reminding
|
||||
# This will remind player when he can vote on all sites
|
||||
# Requires VoteDelays to be setup properly
|
||||
# Use /vote next to see when you can be reminded
|
||||
# Players require the perm "VotingPlugin.Login.RemindVotes" or "VotingPlugin.Player"
|
||||
# To remind if any votesite is available (rather than all) use the permission "VotingPlugin.Login.RemindVotes.Any"
|
||||
Enabled: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
RemindOnLogin: true
|
||||
|
||||
# Whether or not to remind only once when the player can vote
|
||||
# Does not apply to login reminds.
|
||||
RemindOnlyOnce: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
# Ignores value above
|
||||
RemindOnLogin: true
|
||||
|
||||
# Delay to remind votes in minutes
|
||||
# Only works if above is false
|
||||
# Set to -1 to disable
|
||||
RemindDelay: 30
|
||||
|
||||
# Run reward files on remind
|
||||
# Run rewards
|
||||
# and have the default message
|
||||
# Can add titles and more in the reward
|
||||
# This can also be edited via /av gui
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aRemember to vote!'
|
||||
Player: '&aYou have %sitesavailable% sites to vote on still!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
@@ -274,6 +249,10 @@ Format:
|
||||
ToggleBroadcasts:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
ToggleReminders:
|
||||
Enabled: '&cVote reminders enabled'
|
||||
Disabled: '&cVote reminders disabled'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
@@ -374,7 +353,7 @@ LoadTopVoter:
|
||||
|
||||
# Maxium number of players to show on top voter
|
||||
# Set to -1 for no limit
|
||||
MaxiumNumberOfTopVotersToLoad: -1
|
||||
MaxiumNumberOfTopVotersToLoad: 1000
|
||||
|
||||
# When top voter awards are given (even if there are none listed) it will store top voters
|
||||
# Files will created in TopVoters folder.
|
||||
@@ -448,6 +427,10 @@ LimitMonthlyVotes: false
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# Close inventory on player vote
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# When enabled the command /vote setprimaryaccount (playername)
|
||||
# will be shown (after restart)
|
||||
# Primary account will be used instead of the players account to get
|
||||
@@ -460,6 +443,16 @@ UsePrimaryAccountForPlaceholders: false
|
||||
# Only affects placeholderapi placeholders
|
||||
AlwaysWaitForCachePlaceholders: false
|
||||
|
||||
# Set which placeholders to cache at all times
|
||||
# Use for placeholders to are pulled constantly or on the main thread
|
||||
# Mainly aimed for scoreboards
|
||||
# Placeholders may auto cache in certain conditions
|
||||
# Will use additional memory, but not a lot
|
||||
# Still in early stages, please report bugs
|
||||
# Please remove VotingPlugin_ from the placeholder listed here
|
||||
CachedPlaceholders: []
|
||||
#- Total_AllTime
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
@@ -576,14 +569,21 @@ LoadCommandAliases: true
|
||||
# Requires AuthMe
|
||||
WaitUntilLoggedIn: true
|
||||
|
||||
# Preload skulls to improve performance
|
||||
# Preload skulls to improve performance for vote top
|
||||
# when using skulls as the item to display players
|
||||
# If false, skulls will be cached as they are used
|
||||
# assuming loadskulls is enabled
|
||||
PreloadSkulls: false
|
||||
|
||||
# Setting to false disables saving skulls in a cache to improve speeds
|
||||
# Will reduce ram usage if disabled
|
||||
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
|
||||
LoadSkulls: true
|
||||
|
||||
# Limit number of users to load in a second
|
||||
# Effects background tasks mainly
|
||||
# set to -1 to disable (default value)
|
||||
#PlayerDataLoadLimit: 500
|
||||
|
||||
# Use vault for permission checks
|
||||
# May not work on some plugins
|
||||
UseVaultPermissions: false
|
||||
@@ -599,6 +599,7 @@ GeyserPrefixSupport: false
|
||||
GeyserPrefix: '*'
|
||||
|
||||
# Enable to true for extra player checks
|
||||
# Recommend leaving this to false
|
||||
ExtraBackgroundUpdate: false
|
||||
|
||||
# This will prevent spam clicking GUI's to prevent exploits
|
||||
|
||||
@@ -12,6 +12,7 @@ GUIMethod:
|
||||
Last: CHEST #BOOK not available (future update?)
|
||||
Next: CHEST
|
||||
Total: CHEST #BOOK not available (future update?)
|
||||
# GUI for /vote
|
||||
URL: CHEST
|
||||
Best: CHEST #BOOK not available (future update?)
|
||||
Streak: CHEST #BOOK not available (future update?)
|
||||
@@ -78,8 +79,8 @@ CHEST:
|
||||
# Name: 'Extra item'
|
||||
## Works on most GUI items
|
||||
# Slot: 10
|
||||
## Send rewards on click, run commands, check conditions, etc
|
||||
# Rewards: []
|
||||
## Send rewards on click, run commands, check conditions, etc
|
||||
# Rewards: []
|
||||
|
||||
# GUI for /vote url, /vote
|
||||
VoteURL:
|
||||
@@ -119,6 +120,7 @@ CHEST:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
# URL when clicking item in /vote (GUI version)
|
||||
URLText: '%VoteUrl%'
|
||||
# #Add Extra items
|
||||
# ExtraItems:
|
||||
@@ -202,6 +204,7 @@ CHEST:
|
||||
Amount: 1
|
||||
VoteBest:
|
||||
Name: 'VoteBest: %player%'
|
||||
BackButton: true
|
||||
DayBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
|
||||
@@ -18,9 +18,14 @@ AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
|
||||
# If true only cumulative reward at a time can be given
|
||||
# The cumulative rewards will go in order as listed under Cumulative, so if true
|
||||
# the first cumulative (in the order as listed) that can be given will, then will ignore the rest
|
||||
OnlyOneCumulative: false
|
||||
# NOTE: This is not a 1 time reward, that's what milestones are for!
|
||||
# If total votes (Can be changed) divided by cumulative amount
|
||||
# and as no remainder (So divides perfectly)then a reward is given
|
||||
# and with no remainder (So divides perfectly) then a reward is given
|
||||
Cumulative:
|
||||
# Number of votes required
|
||||
# Allows multiple cumulative rewards
|
||||
@@ -55,7 +60,7 @@ VoteParty:
|
||||
GiveAllPlayers: false
|
||||
# If true, give online players the vote party reward
|
||||
# Can also use RewardType: ONLINE if you wanted
|
||||
GiveOnlinePlayersOnly: false
|
||||
GiveOnlinePlayersOnly: true
|
||||
# If true, the vote count will reset each day
|
||||
ResetEachDay: false
|
||||
# If true, the vote count will reset each week
|
||||
@@ -145,8 +150,10 @@ VoteStreak:
|
||||
Week: 50
|
||||
Month: 50
|
||||
|
||||
# Reward given when vote cooldown ended
|
||||
# Using this is a little memory intensive
|
||||
# Reward given when all votesites are available to vote on
|
||||
# Don't use this unless you really need it
|
||||
# Little performance intensive
|
||||
# Recommend add RewardType: ONLINE for it to only work online
|
||||
VoteCoolDownEndedReward: []
|
||||
|
||||
# ONLY USE THIS FOR TITLES/SOUNDS AND OTHER EFFECTS
|
||||
@@ -166,6 +173,11 @@ LogoutRewards: {}
|
||||
|
||||
EnableMonthlyAwards: true
|
||||
|
||||
# TopVoter Placeholders:
|
||||
#%place% - place in topvoter
|
||||
#%topvoter% - topvoter type
|
||||
#%votes% - current total votes related to top voter
|
||||
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.bungee.VotingPluginBungee
|
||||
author: BenCodez
|
||||
author: BenCodez
|
||||
softDepends:
|
||||
- RedisBungee
|
||||
@@ -11,10 +11,6 @@ Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Maxium size of caching mysql
|
||||
# -1 for no limit
|
||||
# Affecting this value may affect performance
|
||||
MaxSize: -1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
@@ -25,13 +21,13 @@ Debug: false
|
||||
# If false, will send to online server only
|
||||
SendVotesToAllServers: true
|
||||
# List of servers the plugin won't send the vote to
|
||||
# Uses names from bungeecoord config if not using SOCKETS method
|
||||
# Uses names from bungeecoord config, only needed for non SOCKETS setup
|
||||
BlockedServers:
|
||||
- hub
|
||||
|
||||
# What type of bungee setup
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/Ben12345rocks/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
@@ -43,6 +39,7 @@ BungeeMethod: PLUGINMESSAGING
|
||||
# This requires spigot servers AllowUnJoined to be set to true in Config.yml
|
||||
AllowUnJoined: false
|
||||
|
||||
# Points to give on vote
|
||||
PointsOnVote: 1
|
||||
|
||||
# If true, bungee will handle adding totals
|
||||
@@ -51,37 +48,44 @@ PointsOnVote: 1
|
||||
# Recommened to leave true, setting to false setups are currently unsupported
|
||||
BungeeManageTotals: true
|
||||
|
||||
# Support for redis
|
||||
# experimental
|
||||
RedisSupport: false
|
||||
|
||||
# Tell servers to broadcast
|
||||
# Set DisableBroadcast to true on spigot servers (BungeeSettings.yml) as well
|
||||
Broadcast: true
|
||||
|
||||
VoteParty:
|
||||
# If enabled, will trigger vote party reward
|
||||
# in BungeeSettings.yml under BungeeVotePartyReward
|
||||
# Only runs rewards for online players
|
||||
Enabled: false
|
||||
# Votes required
|
||||
VotesRequired: 100
|
||||
# Increase amount required on each vote party
|
||||
IncreaseVotesRequired: 0
|
||||
# If false, will only send to servers listed below
|
||||
SendToAllServers: true
|
||||
# Servers to send to, if SendToAllServers is false
|
||||
ServersToSend: []
|
||||
# List of commands to run on bungee server
|
||||
# Set spigot commands in BungeeSettings.yml
|
||||
BungeeCommands: []
|
||||
Broadcast: '&aVote party has been reached!'
|
||||
|
||||
|
||||
# ----------------------------
|
||||
# PLUGINMESSAGING Settings
|
||||
# ----------------------------
|
||||
|
||||
# Applies to PLUGINMESSAGING & when SendVotesToAllServers is true
|
||||
# Applies to PLUGINMESSAGING only
|
||||
# Votes will be forwarded when specific player is online
|
||||
WaitForUserOnline: false
|
||||
|
||||
# ----------------------------
|
||||
# SOCKET Settings, do not touch otherwise
|
||||
# SOCKET Settings
|
||||
# ONLY for SOCKET method
|
||||
# ----------------------------
|
||||
|
||||
# Tell servers to broadcast
|
||||
# For socket method
|
||||
Broadcast: true
|
||||
|
||||
# Server to send vote to if player is offline
|
||||
FallBackServer: factions
|
||||
|
||||
# Bungee communication, Add this to each spigot server
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add each spigot server here
|
||||
# For socket method
|
||||
SpigotServers:
|
||||
lobby:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
factions:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1999
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
@@ -8,7 +8,7 @@ softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, P
|
||||
loadbefore: [MCPerks]
|
||||
api-version: 1.13
|
||||
libraries:
|
||||
- org.openjdk.nashorn:nashorn-core:15.2
|
||||
- org.openjdk.nashorn:nashorn-core:15.3
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
@@ -64,6 +64,8 @@ commands:
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votetogglereminders:
|
||||
aliases: [vtogglereminder,vtoggle]
|
||||
votelist:
|
||||
description: A command
|
||||
aliases: vlist
|
||||
@@ -88,9 +90,6 @@ commands:
|
||||
adminvoteperms:
|
||||
description: Command Alias
|
||||
aliases: avperms
|
||||
adminvoteDownload:
|
||||
description: Command Alias
|
||||
aliases: avdownload
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
@@ -130,6 +129,9 @@ commands:
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteConvertToData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
adminvoteBackgroundUpdate:
|
||||
@@ -141,9 +143,9 @@ commands:
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteSetVotePartyCount:
|
||||
adminvoteVoteParty:
|
||||
description: Command Alias
|
||||
aliases: avSetVotePartyCount
|
||||
aliases: avVoteParty
|
||||
adminvoteChoices:
|
||||
description: Command Alias
|
||||
aliases: avChoices
|
||||
@@ -200,9 +202,6 @@ commands:
|
||||
adminvoteDownloadJenkins:
|
||||
description: Command Alias
|
||||
aliases: avDownloadJenkins
|
||||
adminvoteForceVoteParty:
|
||||
description: Command Alias
|
||||
aliases: avForceVoteParty
|
||||
adminvoteSetRequestMethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
@@ -215,13 +214,18 @@ commands:
|
||||
adminvoteResetPoints:
|
||||
description: Command Alias
|
||||
aliases: avResetPoints
|
||||
adminvoteVotePartyExtraRequired:
|
||||
description: Command Alias
|
||||
aliases: avVotePartyExtraRequired
|
||||
adminvoteRunCMD:
|
||||
description: Command Alias
|
||||
aliases: avRunCMD
|
||||
|
||||
adminvoteuseruuidremove:
|
||||
description: Command Alias
|
||||
aliases: avuseruuidremove
|
||||
adminvoteedit:
|
||||
description: Command Alias
|
||||
aliases: avedit
|
||||
adminvoteResetMilestoneCount:
|
||||
description: Command Alias
|
||||
aliases: avResetMilestoneCount
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
@@ -247,7 +251,7 @@ permissions:
|
||||
description: Permission for generating votesite message
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Permission to allow timed reminders
|
||||
VotingPlugin.Login.RemindVotes.Any:
|
||||
description: Remind if player can vote on any website, rather than all
|
||||
VotingPlugin.Login.RemindVotes.All:
|
||||
description: Remind if player can vote on all votesites, rather than any
|
||||
default: false
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
time: '${timestamp}'
|
||||
profile: ${build.profile.id}
|
||||
profile: '${build.profile.id}'
|
||||
version: '${project.version}'
|
||||
buildnumber: '${build.number}'
|
||||
+146
-88
@@ -1,10 +1,8 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>6.4.1</version>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.8</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -12,14 +10,8 @@
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
<build.number>NOTSET</build.number>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
@@ -111,14 +103,10 @@
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>com.bencodez.advancedcore</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore</shadedPattern>
|
||||
</relocation>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin</shadedPattern>
|
||||
@@ -136,13 +124,12 @@
|
||||
<shadedPattern>${project.groupId}.votingplugin.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>xyz.upperlevel.spigot.book</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.upperlevel.book</shadedPattern>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<!-- Replace this with your package! -->
|
||||
<shadedPattern>${project.groupId}.votingplugin.bstats</shadedPattern>
|
||||
<pattern>xyz.upperlevel.spigot</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
@@ -175,50 +162,6 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.github</groupId>
|
||||
<artifactId>site-maven-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc</id>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<message>Maven javadoc for ${project.version}</message>
|
||||
<noJekyll>true</noJekyll>
|
||||
<outputDirectory>${project.build.directory}/apidocs
|
||||
</outputDirectory>
|
||||
<branch>refs/heads/gh-pages</branch>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<repositoryName>VotingPlugin</repositoryName>
|
||||
<repositoryOwner>BenCodez</repositoryOwner>
|
||||
<server>github</server>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
@@ -264,12 +207,26 @@
|
||||
<id>velocity</id>
|
||||
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.limework</groupId>
|
||||
<artifactId>redisbungee</artifactId>
|
||||
<version>0.6.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -281,22 +238,20 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vexsoftware</groupId>
|
||||
<artifactId>nuvotifier-universal</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/nuvotifier.jar</systemPath>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>MVdWPlaceholderAPI</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/MVdWPlaceholderAPI.jar</systemPath>
|
||||
<artifactId>mvdwplaceholderapi</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
@@ -314,39 +269,43 @@
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<build.profile.id>prod</build.profile.id>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<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>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod2</id>
|
||||
<properties>
|
||||
<build.profile.id>prod2</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>AdvancedCore</artifactId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
@@ -360,11 +319,110 @@
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>AdvancedCore</artifactId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</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>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<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>
|
||||
<plugin>
|
||||
<groupId>com.github.github</groupId>
|
||||
<artifactId>site-maven-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc</id>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<message>Maven javadoc for ${project.version}</message>
|
||||
<noJekyll>true</noJekyll>
|
||||
<outputDirectory>${project.build.directory}/apidocs
|
||||
</outputDirectory>
|
||||
<branch>refs/heads/gh-pages</branch>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<repositoryName>VotingPlugin</repositoryName>
|
||||
<repositoryOwner>BenCodez</repositoryOwner>
|
||||
<server>github</server>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -4,7 +4,15 @@ import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
@@ -18,7 +26,7 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeHandler {
|
||||
public class BungeeHandler implements Listener {
|
||||
@Getter
|
||||
private ClientHandler clientHandler;
|
||||
|
||||
@@ -29,6 +37,12 @@ public class BungeeHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyCurrent = 0;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyRequired = 0;
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
@@ -39,6 +53,16 @@ public class BungeeHandler {
|
||||
public void close() {
|
||||
socketHandler.closeConnection();
|
||||
clientHandler.stopConnection();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDateChange(DateChangedEvent event) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("timeupdate", plugin.getServerDataFile().getPrevMonth() + "//"
|
||||
+ plugin.getServerDataFile().getPrevDay() + "//" + plugin.getServerDataFile().getPrevWeekDay());
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -53,6 +77,11 @@ public class BungeeHandler {
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
|
||||
|
||||
plugin.getPluginMessaging().setDebug(plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
@@ -75,24 +104,41 @@ public class BungeeHandler {
|
||||
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
@@ -119,6 +165,11 @@ public class BungeeHandler {
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
|
||||
plugin.debug(
|
||||
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
@@ -133,17 +184,34 @@ public class BungeeHandler {
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline);
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
if (Boolean.valueOf(args.get(4)) || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (Boolean.valueOf(args.get(4))
|
||||
|| plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
@@ -165,6 +233,11 @@ public class BungeeHandler {
|
||||
|
||||
user.offVote();
|
||||
|
||||
if (args.size() > 2) {
|
||||
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
|
||||
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
@@ -172,14 +245,17 @@ public class BungeeHandler {
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(1);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(2);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
args.get(1));
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -193,6 +269,23 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String broadcast = args.get(0);
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
@@ -259,7 +352,7 @@ public class BungeeHandler {
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1]);
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[3];
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
@@ -291,6 +384,25 @@ public class BungeeHandler {
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBungee") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
String broadcast = data[0];
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -49,9 +50,8 @@ import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection;
|
||||
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.UUID;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.logger.Logger;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
@@ -82,6 +82,7 @@ import com.bencodez.votingplugin.signs.Signs;
|
||||
import com.bencodez.votingplugin.specialrewards.SpecialRewards;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterHandler;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.updater.CheckUpdate;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -134,7 +135,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
private GUI gui;
|
||||
|
||||
@Getter
|
||||
private LinkedHashMap<VotingPluginUser, Integer> lastMonthTopVoter;
|
||||
private LinkedHashMap<TopVoterPlayer, Integer> lastMonthTopVoter;
|
||||
|
||||
@Getter
|
||||
private MVdWPlaceholders mvdwPlaceholders;
|
||||
@@ -145,6 +146,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Getter
|
||||
private String profile = "";
|
||||
|
||||
@Getter
|
||||
private String buildNumber = "NOTSET";
|
||||
|
||||
@Getter
|
||||
private ServerData serverData;
|
||||
|
||||
@@ -162,7 +166,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
private String time = "";
|
||||
|
||||
@Getter
|
||||
private LinkedHashMap<TopVoter, LinkedHashMap<VotingPluginUser, Integer>> topVoter;
|
||||
@Setter
|
||||
private LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> topVoter;
|
||||
|
||||
@Getter
|
||||
private TopVoterHandler topVoterHandler;
|
||||
@@ -195,13 +200,17 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
private List<VoteSite> voteSites;
|
||||
|
||||
@Getter
|
||||
private LinkedHashMap<VotingPluginUser, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
@Setter
|
||||
private LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
|
||||
private boolean votifierLoaded = true;
|
||||
|
||||
@Getter
|
||||
private boolean ymlError = false;
|
||||
|
||||
@Getter
|
||||
private UserManager votingPluginUserManager;
|
||||
|
||||
private void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
|
||||
RewardHandler.getInstance().addDirectlyDefined(directlyDefinedReward);
|
||||
}
|
||||
@@ -251,79 +260,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void convertDataStorage(UserStorage from, UserStorage to) {
|
||||
if (from == null || to == null) {
|
||||
throw new RuntimeException("Invalid Storage Method");
|
||||
}
|
||||
UserStorage cur = getStorageType();
|
||||
getOptions().setStorageType(from);
|
||||
if (getStorageType().equals(UserStorage.MYSQL) && getMysql() != null) {
|
||||
getMysql().clearCache();
|
||||
}
|
||||
ArrayList<String> uuids = new ArrayList<String>(UserManager.getInstance().getAllUUIDs());
|
||||
|
||||
while (uuids.size() > 0) {
|
||||
HashMap<VotingPluginUser, HashMap<String, String>> data = new HashMap<VotingPluginUser, HashMap<String, String>>();
|
||||
getOptions().setStorageType(from);
|
||||
loadUserAPI(getOptions().getStorageType());
|
||||
// setStorageType(to);
|
||||
|
||||
if (getStorageType().equals(UserStorage.MYSQL) && getMysql() != null) {
|
||||
getMysql().clearCache();
|
||||
}
|
||||
|
||||
ArrayList<String> converted = new ArrayList<String>();
|
||||
int i = 0;
|
||||
while (i < configFile.getConvertAmount() && i < uuids.size()) {
|
||||
String uuid = uuids.get(i);
|
||||
try {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
String value = user.getData().getValue(key);
|
||||
if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
|
||||
values.put(key, value);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
converted.add(uuid);
|
||||
data.put(user, values);
|
||||
debug("[Convert] Added " + uuid);
|
||||
} catch (Exception e) {
|
||||
debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
wait(configFile.getConvertDelay());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
uuids.removeAll(converted);
|
||||
|
||||
plugin.getLogger().info("Finished getting data from " + from.toString() + " Converting " + data.size()
|
||||
+ " users, " + uuids.size() + " left to convert");
|
||||
|
||||
getOptions().setStorageType(to);
|
||||
loadUserAPI(getOptions().getStorageType());
|
||||
if (getStorageType().equals(UserStorage.MYSQL) && getMysql() != null) {
|
||||
getMysql().clearCache();
|
||||
}
|
||||
|
||||
writeConvertData(data);
|
||||
}
|
||||
|
||||
getOptions().setStorageType(cur);
|
||||
reload();
|
||||
|
||||
plugin.getLogger().info("Finished convertting");
|
||||
}
|
||||
|
||||
public ArrayList<VotingPluginUser> convertSet(Set<VotingPluginUser> set) {
|
||||
return new ArrayList<VotingPluginUser>(set);
|
||||
public ArrayList<TopVoterPlayer> convertSet(Set<TopVoterPlayer> set) {
|
||||
return new ArrayList<TopVoterPlayer>(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -331,8 +269,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
return configFile.getData();
|
||||
}
|
||||
|
||||
public LinkedHashMap<VotingPluginUser, Integer> getTopVoter(TopVoter top) {
|
||||
return topVoter.get(top);
|
||||
public LinkedHashMap<TopVoterPlayer, Integer> getTopVoter(TopVoter top) {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> top1 = topVoter.get(top);
|
||||
if (top1 == null) {
|
||||
top1 = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
}
|
||||
return top1;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,20 +315,14 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site.
|
||||
*
|
||||
* @param site the site name
|
||||
* @return the vote site
|
||||
*/
|
||||
public VoteSite getVoteSite(String site) {
|
||||
String siteName = getVoteSiteName(site);
|
||||
public VoteSite getVoteSite(String site, boolean checkEnabled) {
|
||||
String siteName = getVoteSiteName(checkEnabled, site);
|
||||
for (VoteSite voteSite : getVoteSites()) {
|
||||
if (voteSite.getKey().equalsIgnoreCase(siteName) || voteSite.getDisplayName().equals(siteName)) {
|
||||
return voteSite;
|
||||
}
|
||||
}
|
||||
if (configFile.isAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames().contains(siteName)) {
|
||||
if (configFile.isAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames(false).contains(siteName)) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
return new VoteSite(plugin, siteName.replace(".", "_"));
|
||||
}
|
||||
@@ -394,14 +330,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site name.
|
||||
*
|
||||
* @param urls the url
|
||||
* @return the vote site name
|
||||
*/
|
||||
public String getVoteSiteName(String... urls) {
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames();
|
||||
public String getVoteSiteName(boolean checkEnabled, String... urls) {
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(checkEnabled);
|
||||
for (String url : urls) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
@@ -431,7 +361,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
public String getVoteSiteServiceSite(String name) {
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames();
|
||||
ArrayList<String> sites = getConfigVoteSites().getVoteSitesNames(true);
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -452,12 +382,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
}
|
||||
|
||||
public UserManager getVotingPluginUserManager() {
|
||||
return UserManager.getInstance();
|
||||
}
|
||||
|
||||
public boolean hasVoteSite(String site) {
|
||||
String siteName = getVoteSiteName(site);
|
||||
String siteName = getVoteSiteName(false, site);
|
||||
for (VoteSite voteSite : getVoteSites()) {
|
||||
if (voteSite.getKey().equalsIgnoreCase(siteName) || voteSite.getDisplayName().equals(siteName)) {
|
||||
return true;
|
||||
@@ -524,7 +450,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getSpecialRewardsConfig().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("FirstVoteToday") {
|
||||
|
||||
@Override
|
||||
@@ -924,6 +850,28 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
});
|
||||
}
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("BungeeVotePartyRewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
getBungeeSettings().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return getBungeeSettings().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getBungeeSettings().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
getBungeeSettings().setValue(path, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
@@ -943,8 +891,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}, 1000, 1000 * 60 * configFile.getDelayBetweenUpdates());
|
||||
|
||||
coolDownCheck.load();
|
||||
|
||||
getTimer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
@@ -967,6 +913,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
if (conf != null) {
|
||||
time = conf.getString("time", "");
|
||||
profile = conf.getString("profile", "");
|
||||
buildNumber = conf.getString("buildnumber", "NOTSET");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1034,6 +981,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
specialRewards = new SpecialRewards(this);
|
||||
signs = new Signs(this);
|
||||
|
||||
coolDownCheck.checkEnabled();
|
||||
coolDownCheck.load();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -1043,7 +993,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
});
|
||||
|
||||
topVoterHandler = new TopVoterHandler(this);
|
||||
lastMonthTopVoter = new LinkedHashMap<VotingPluginUser, Integer>();
|
||||
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -1052,11 +1002,11 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
debug("Loaded last month top voters");
|
||||
}
|
||||
});
|
||||
topVoter = new LinkedHashMap<TopVoter, LinkedHashMap<VotingPluginUser, Integer>>();
|
||||
topVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
topVoter.put(top, new LinkedHashMap<VotingPluginUser, Integer>());
|
||||
topVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
|
||||
}
|
||||
voteToday = new LinkedHashMap<VotingPluginUser, HashMap<VoteSite, LocalDateTime>>();
|
||||
voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
|
||||
voteLog = new Logger(plugin, new File(plugin.getDataFolder() + File.separator + "Log", "votelog.txt"));
|
||||
|
||||
new AdminGUI(this).loadHook();
|
||||
@@ -1090,36 +1040,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
mvdwPlaceholders.loadMVdWPlaceholders();
|
||||
}
|
||||
|
||||
// set columns
|
||||
if (getStorageType().equals(UserStorage.MYSQL) && configFile.isAlterColumns()) {
|
||||
getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("Reminded", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("DisableBroadcast", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("LastOnline", "VARCHAR(20)");
|
||||
getMysql().alterColumnType("PlayerName", "VARCHAR(30)");
|
||||
getMysql().alterColumnType("DailyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("WeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("DayVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("BestDayVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("WeekVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("BestWeekVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("VotePartyVotes", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("MonthVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("Points", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestDailyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("AllTimeTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestMonthlyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("MilestoneCount", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
|
||||
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
|
||||
if (getOptions().isPerServerRewards()) {
|
||||
getMysql().alterColumnType("OfflineRewards" + getOptions().getServer(), "MEDIUMTEXT");
|
||||
}
|
||||
}
|
||||
// Add rewards
|
||||
RewardHandler.getInstance().addInjectedReward(new RewardInjectInt("Points", 0) {
|
||||
|
||||
@@ -1183,7 +1103,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
if (getProfile().contains("dev")) {
|
||||
plugin.getLogger().warning("Using dev build, this is not a stable build, use at your own risk");
|
||||
plugin.getLogger().info(
|
||||
"Using dev build, this is not a stable build, use at your own risk. Build number: " + buildNumber);
|
||||
}
|
||||
|
||||
boolean hasRewards = RewardHandler.getInstance().hasRewards(getConfigVoteSites().getData(),
|
||||
@@ -1195,7 +1116,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
if (!site.hasRewards() && !hasRewards) {
|
||||
issues = false;
|
||||
plugin.getLogger().warning("No rewards detected for the site: " + site.getKey()
|
||||
+ ". See https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards on how to add rewards");
|
||||
+ ". See https://github.com/BenCodez/VotingPlugin/wiki/Rewards");
|
||||
}
|
||||
|
||||
boolean contains = false;
|
||||
@@ -1217,7 +1138,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().warning(
|
||||
"Detected an issue with voting sites, check the server startup log for more details");
|
||||
"Detected an issue with voting sites, check the server startup log for more details: https://github.com/BenCodez/VotingPlugin/wiki/Votifier-Troubleshooting");
|
||||
}
|
||||
}, 30l);
|
||||
}
|
||||
@@ -1250,7 +1171,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
loadVoteSites();
|
||||
|
||||
setJenkinsSite("ben12345rocks.com");
|
||||
votingPluginUserManager = UserManager.getInstance();
|
||||
votingPluginUserManager.addCachingKeys();
|
||||
|
||||
setJenkinsSite("bencodez.com");
|
||||
updateAdvancedCoreHook();
|
||||
|
||||
}
|
||||
@@ -1291,8 +1215,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
// /adminvote, /av
|
||||
getCommand("adminvote").setExecutor(new CommandAdminVote(this));
|
||||
getCommand("adminvote").setTabCompleter(new AdminVoteTabCompleter());
|
||||
getCommand("adminvote").setPermission("VotingPlugin.Commands.AdminVote");
|
||||
getCommand("av").setExecutor(new CommandAdminVote(this));
|
||||
getCommand("av").setTabCompleter(new AdminVoteTabCompleter());
|
||||
getCommand("av").setPermission("VotingPlugin.Commands.AdminVote");
|
||||
|
||||
Permission perm = Bukkit.getPluginManager().getPermission("VotingPlugin.Player");
|
||||
if (perm != null) {
|
||||
@@ -1373,7 +1299,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
loadDirectlyDefined();
|
||||
reloadAdvancedCore(userStorage);
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
placeholders.load();
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
}
|
||||
|
||||
voteReminding.loadRemindChecking();
|
||||
coolDownCheck.checkEnabled();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@@ -1405,12 +1336,8 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
checkYMLError();
|
||||
|
||||
plugin.debug("Loaded Files");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*/
|
||||
public void update() {
|
||||
if (update || configFile.isAlwaysUpdate()) {
|
||||
if (!updateStarted && plugin != null) {
|
||||
@@ -1419,48 +1346,111 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
update = false;
|
||||
|
||||
synchronized (plugin) {
|
||||
if (getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else if (configFile.isClearCacheOnUpdate() || bungeeSettings.isUseBungeecoord()) {
|
||||
getMysql().clearCache();
|
||||
} else {
|
||||
getMysql().clearCacheBasic();
|
||||
}
|
||||
}
|
||||
getUserManager().getDataManager().clearCacheBasic();
|
||||
|
||||
plugin.debug("Starting background task");
|
||||
long time = System.currentTimeMillis();
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
placeholders.onUpdate();
|
||||
|
||||
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
|
||||
try {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>> voteToday = new LinkedHashMap<TopVoterPlayer, HashMap<VoteSite, LocalDateTime>>();
|
||||
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter = new LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>>();
|
||||
|
||||
ArrayList<TopVoter> topVotersToCheck = new ArrayList<TopVoter>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (plugin.getConfigFile().getLoadTopVoter(top)) {
|
||||
topVotersToCheck.add(top);
|
||||
tempTopVoter.put(top, new LinkedHashMap<TopVoterPlayer, Integer>());
|
||||
}
|
||||
}
|
||||
boolean topVoterIgnorePermissionUse = plugin.getConfigFile().getTopVoterIgnorePermission();
|
||||
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
ArrayList<VotingPluginUser> users = new ArrayList<VotingPluginUser>();
|
||||
int currentDay = LocalDateTime.now().getDayOfMonth();
|
||||
int currentDataLoad = 0;
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(new UUID(uuid));
|
||||
users.add(user);
|
||||
// extraDebug("Loading " + uuid);
|
||||
// java.lang.Thread.sleep(5000);
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance()
|
||||
.getYearFromMili(time))) {
|
||||
|
||||
times.put(entry.getKey(), LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (!extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
plugin.getPlaceholders().onUpdate(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
if (dataLoadLimit > 0) {
|
||||
currentDataLoad++;
|
||||
if (currentDataLoad >= dataLoadLimit) {
|
||||
currentDataLoad -= dataLoadLimit;
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + users.size()
|
||||
+ " users");
|
||||
topVoterHandler.updateTopVoters(users);
|
||||
updateVoteToday(users);
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + uuids.size()
|
||||
+ " users, " + plugin.getStorageType().toString() + ", data load limit: "
|
||||
+ dataLoadLimit);
|
||||
time1 = System.currentTimeMillis();
|
||||
|
||||
topVoterHandler.updateTopVoters(tempTopVoter);
|
||||
setVoteToday(voteToday);
|
||||
serverData.updateValues();
|
||||
getSigns().updateSigns();
|
||||
|
||||
if (!configFile.isExtraBackgroundUpdate()) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Background task finished in " + time1 + " seconds");
|
||||
tempTopVoter = null;
|
||||
|
||||
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
plugin.extraDebug("Current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
checkFirstTimeLoaded();
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger().info("Looks like something went wrong");
|
||||
ex.printStackTrace();
|
||||
@@ -1473,65 +1463,34 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean firstTimeLoaded = false;
|
||||
|
||||
public void checkFirstTimeLoaded() {
|
||||
if (!firstTimeLoaded) {
|
||||
if (getGui().isChestVoteTopUseSkull()) {
|
||||
int maxToLoad = 200;
|
||||
for (TopVoter top : topVoter.keySet()) {
|
||||
int num = 1;
|
||||
Set<TopVoterPlayer> players = topVoter.get(top).keySet();
|
||||
for (TopVoterPlayer p : players) {
|
||||
if (num <= maxToLoad) {
|
||||
SkullHandler.getInstance().loadSkull(p.getPlayerName());
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
firstTimeLoaded = true;
|
||||
}
|
||||
|
||||
public void updateAdvancedCoreHook() {
|
||||
getJavascriptEngine().put("VotingPlugin", this);
|
||||
allowDownloadingFromSpigot(15358);
|
||||
setConfigData(configFile.getData());
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
getOptions().setClearCacheOnJoin(true);
|
||||
getOptions().setPerServerRewards(getBungeeSettings().isPerServerRewards());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateVoteToday(ArrayList<VotingPluginUser> users) {
|
||||
plugin.getVoteToday().clear();
|
||||
|
||||
for (VotingPluginUser user : users) {
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if ((LocalDateTime.now().getDayOfMonth() == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance().getYearFromMili(time))) {
|
||||
|
||||
times.put(voteSite,
|
||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
plugin.getVoteToday().put(user, times);
|
||||
}
|
||||
|
||||
}
|
||||
plugin.debug("Updated VoteToday");
|
||||
}
|
||||
|
||||
private void writeConvertData(HashMap<VotingPluginUser, HashMap<String, String>> data) {
|
||||
boolean checkInt = getStorageType().equals(UserStorage.MYSQL);
|
||||
for (Entry<VotingPluginUser, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
String value = values.getValue();
|
||||
if (value != null && !value.equalsIgnoreCase("null")) {
|
||||
if (checkInt) {
|
||||
if (StringParser.getInstance().isInt(value)) {
|
||||
entry.getKey().getData().setInt(values.getKey(), Integer.parseInt(value));
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger()
|
||||
.warning("Exception occoured for '" + entry.getKey().getUUID() + "': " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -188,6 +188,28 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
int users = UserManager.getInstance().getAllUUIDs().size();
|
||||
if (users > 1000) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users_in_thousands", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
|
||||
return "" + total;
|
||||
}
|
||||
}));
|
||||
}
|
||||
if (users > 10000) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users_in_thousands_plus_10", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
|
||||
return "" + total;
|
||||
}
|
||||
}));
|
||||
}
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -295,5 +317,32 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getProfile().contains("dev");
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votepointtransfering", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isAllowVotePointTransfers();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votecooldown_check_enabled", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + (!plugin.getConfigFile().isDisableCoolDownCheck() && RewardHandler.getInstance()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward"));
|
||||
}
|
||||
}));
|
||||
|
||||
if (!plugin.getBuildNumber().equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("dev_build_number", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBuildNumber();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import lombok.Getter;
|
||||
public class BungeeMessageData {
|
||||
|
||||
// Message string
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
|
||||
|
||||
@Getter
|
||||
private int allTimeTotal = 0;
|
||||
@@ -21,15 +21,21 @@ public class BungeeMessageData {
|
||||
private int points = 0;
|
||||
@Getter
|
||||
private int weeklyTotal = 0;
|
||||
@Getter
|
||||
private int votePartyCurrent = 0;
|
||||
@Getter
|
||||
private int votePartyRequired = 0;
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
int milestoneCount) {
|
||||
int milestoneCount, int votePartyCurrent, int votePartyRequired) {
|
||||
this.allTimeTotal = allTimeTotal;
|
||||
this.monthTotal = monthTotal;
|
||||
this.weeklyTotal = weeklyTotal;
|
||||
this.dailyTotal = dailyTotal;
|
||||
this.points = points;
|
||||
this.milestoneCount = milestoneCount;
|
||||
this.votePartyCurrent = votePartyCurrent;
|
||||
this.votePartyRequired = votePartyRequired;
|
||||
}
|
||||
|
||||
public BungeeMessageData(String str) {
|
||||
@@ -42,12 +48,16 @@ public class BungeeMessageData {
|
||||
points = Integer.parseInt(data[4]);
|
||||
milestoneCount = Integer.parseInt(data[5]);
|
||||
}
|
||||
if (data.length >= 8) {
|
||||
votePartyCurrent = Integer.parseInt(data[6]);
|
||||
votePartyRequired = Integer.parseInt(data[7]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allTimeTotal + "//" + monthTotal + "//" + weeklyTotal + "//" + dailyTotal + "//" + points + "//"
|
||||
+ milestoneCount;
|
||||
+ milestoneCount + "//" + votePartyCurrent + "//" + votePartyRequired;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,485 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.queries.Query;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.DataType;
|
||||
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
public class BungeeMySQL {
|
||||
private List<String> columns = Collections.synchronizedList(new ArrayList<String>());
|
||||
|
||||
private List<String> intColumns = new ArrayList<String>();
|
||||
|
||||
// private HashMap<String, ArrayList<Column>> table;
|
||||
|
||||
// ConcurrentMap<String, ArrayList<Column>> table = new
|
||||
// ConcurrentHashMap<String, ArrayList<Column>>();
|
||||
|
||||
private com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL mysql;
|
||||
|
||||
private String name;
|
||||
|
||||
private Object object2 = new Object();
|
||||
|
||||
private Object object3 = new Object();
|
||||
|
||||
private Object object4 = new Object();
|
||||
|
||||
private Set<String> uuids = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
public BungeeMySQL(VotingPluginBungee bungee, String tableName, Configuration section) {
|
||||
String tablePrefix = section.getString("Prefix");
|
||||
String hostName = section.getString("Host");
|
||||
int port = section.getInt("Port");
|
||||
String user = section.getString("Username");
|
||||
String pass = section.getString("Password");
|
||||
String database = section.getString("Database");
|
||||
long lifeTime = section.getLong("MaxLifeTime", -1);
|
||||
int maxThreads = section.getInt("MaxConnections", 1);
|
||||
String str = section.getString("Line", "");
|
||||
if (maxThreads < 1) {
|
||||
maxThreads = 1;
|
||||
}
|
||||
boolean useSSL = section.getBoolean("UseSSL", false);
|
||||
boolean publicKeyRetrieval = section.getBoolean("PublicKeyRetrieval", false);
|
||||
if (!section.getString("Name", "").isEmpty()) {
|
||||
tableName = section.getString("Name", "");
|
||||
}
|
||||
|
||||
name = tableName;
|
||||
if (tablePrefix != null) {
|
||||
name = tablePrefix + tableName;
|
||||
}
|
||||
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads) {
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
bungee.getLogger().severe(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (bungee.getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!mysql.connect(hostName, "" + port, user, pass, database, useSSL, lifeTime, str, publicKeyRetrieval)) {
|
||||
|
||||
}
|
||||
try {
|
||||
Query q = new Query(mysql, "USE " + database + ";");
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String sql = "CREATE TABLE IF NOT EXISTS " + getName() + " (";
|
||||
sql += "uuid VARCHAR(37),";
|
||||
sql += "PRIMARY KEY ( uuid )";
|
||||
sql += ");";
|
||||
Query query;
|
||||
try {
|
||||
query = new Query(mysql, sql);
|
||||
|
||||
query.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
loadData();
|
||||
|
||||
// tempoary to improve performance from old tables
|
||||
// addToQue("ALTER TABLE " + getName() + " MODIFY uuid VARCHAR(37);");
|
||||
alterColumnType("uuid", "VARCHAR(37)");
|
||||
}
|
||||
|
||||
public void addColumn(String column, DataType dataType) {
|
||||
synchronized (object3) {
|
||||
String sql = "ALTER TABLE " + getName() + " ADD COLUMN " + column + " text" + ";";
|
||||
try {
|
||||
Query query = new Query(mysql, sql);
|
||||
query.executeUpdate();
|
||||
|
||||
getColumns().add(column);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void alterColumnType(String column, String newType) {
|
||||
checkColumn(column, DataType.STRING);
|
||||
if (newType.contains("INT")) {
|
||||
try {
|
||||
new Query(mysql, "UPDATE " + getName() + " SET " + column + " = '0' where trim(coalesce(" + column
|
||||
+ ", '')) = '';").executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
;
|
||||
if (!intColumns.contains(column)) {
|
||||
intColumns.add(column);
|
||||
}
|
||||
}
|
||||
try {
|
||||
new Query(mysql, "ALTER TABLE " + getName() + " MODIFY " + column + " " + newType + ";")
|
||||
.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkColumn(String column, DataType dataType) {
|
||||
synchronized (object4) {
|
||||
if (!getColumns().contains(column)) {
|
||||
if (!getColumnsQueury().contains(column)) {
|
||||
addColumn(column, dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
clearCacheBasic();
|
||||
}
|
||||
|
||||
public void clearCacheBasic() {
|
||||
columns.clear();
|
||||
columns.addAll(getColumnsQueury());
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
}
|
||||
|
||||
public void close() {
|
||||
mysql.disconnect();
|
||||
}
|
||||
|
||||
public boolean containsKeyQuery(String index) {
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
while (rs.next()) {
|
||||
if (rs.getString("uuid").equals(index)) {
|
||||
rs.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> getColumns() {
|
||||
if (columns == null || columns.size() == 0) {
|
||||
loadData();
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
public ArrayList<String> getColumnsQueury() {
|
||||
ArrayList<String> columns = new ArrayList<String>();
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement("SELECT * FROM " + getName() + ";")) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, "SELECT * FROM " + getName() + ";"); ResultSet
|
||||
* rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
ResultSetMetaData metadata = rs.getMetaData();
|
||||
int columnCount = 0;
|
||||
if (metadata != null) {
|
||||
columnCount = metadata.getColumnCount();
|
||||
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = metadata.getColumnName(i);
|
||||
columns.add(columnName);
|
||||
}
|
||||
rs.close();
|
||||
return columns;
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return columns;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Column> getExactQuery(Column column) {
|
||||
ArrayList<Column> result = new ArrayList<>();
|
||||
String query = "SELECT * FROM " + getName() + " WHERE `" + column.getName() + "`='"
|
||||
+ column.getValue().toString() + "';";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); sql.setParameter(1,
|
||||
* column.getValue().toString()); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
String columnName = rs.getMetaData().getColumnLabel(i);
|
||||
Column rCol = null;
|
||||
if (intColumns.contains(columnName)) {
|
||||
rCol = new Column(columnName, DataType.INTEGER);
|
||||
} else {
|
||||
rCol = new Column(columnName, DataType.STRING);
|
||||
}
|
||||
// System.out.println(i + " " +
|
||||
// rs.getMetaData().getColumnLabel(i));
|
||||
rCol.setValue(rs.getString(i));
|
||||
// System.out.println(rCol.getValue());
|
||||
result.add(rCol);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
|
||||
for (String col : getColumns()) {
|
||||
result.add(new Column(col, DataType.STRING));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<String> getNamesQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
|
||||
checkColumn("PlayerName", DataType.STRING);
|
||||
ArrayList<Column> rows = getRowsNameQuery();
|
||||
if (rows != null) {
|
||||
for (Column c : rows) {
|
||||
uuids.add((String) c.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsNameQuery() {
|
||||
ArrayList<Column> result = new ArrayList<Column>();
|
||||
String sqlStr = "SELECT PlayerName FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("PlayerName", rs.getString("PlayerName"), DataType.STRING);
|
||||
result.add(rCol);
|
||||
}
|
||||
sql.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsQuery() {
|
||||
ArrayList<Column> result = new ArrayList<Column>();
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("uuid", rs.getString("uuid"), DataType.STRING);
|
||||
result.add(rCol);
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
String query = "SELECT uuid FROM " + getName() + " WHERE " + "PlayerName" + "='" + playerName + "';";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
String uuid = rs.getString("uuid");
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
rs.close();
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getUuids() {
|
||||
if (uuids == null || uuids.size() == 0) {
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
return uuids;
|
||||
}
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<String> getUuidsQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
|
||||
ArrayList<Column> rows = getRowsQuery();
|
||||
for (Column c : rows) {
|
||||
uuids.add((String) c.getValue());
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public void insert(String index, String column, Object value, DataType dataType) {
|
||||
insertQuery(index, Arrays.asList(new Column(column, value, dataType)));
|
||||
}
|
||||
|
||||
public void insertQuery(String index, List<Column> cols) {
|
||||
String query = "INSERT " + getName() + " ";
|
||||
|
||||
query += "set uuid='" + index + "', ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "';";
|
||||
} else {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "', ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
uuids.add(index);
|
||||
new Query(mysql, query).executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isIntColumn(String key) {
|
||||
return intColumns.contains(key);
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
columns = getColumnsQueury();
|
||||
}
|
||||
|
||||
public void update(String index, List<Column> cols, boolean queue) {
|
||||
for (Column col : cols) {
|
||||
checkColumn(col.getName(), col.getDataType());
|
||||
}
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
if (col.getDataType().equals(DataType.STRING)) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "';";
|
||||
} else {
|
||||
query += col.getName() + "=" + col.getValue().toString() + ";";
|
||||
}
|
||||
} else {
|
||||
if (col.getDataType().equals(DataType.STRING)) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "', ";
|
||||
} else {
|
||||
query += col.getName() + "=" + col.getValue().toString() + ", ";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
insertQuery(index, cols);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String index, String column, Object value, DataType dataType) {
|
||||
checkColumn(column, dataType);
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
if (dataType == DataType.STRING) {
|
||||
query += column + "='" + value.toString() + "'";
|
||||
} else {
|
||||
query += column + "=" + value;
|
||||
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
insert(index, column, value, dataType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,10 @@ public class Config {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public boolean getRedisSupport() {
|
||||
return getData().getBoolean("RedisSupport", false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getData().getString("BungeeServer.Host", "");
|
||||
}
|
||||
@@ -77,6 +81,34 @@ public class Config {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getData().getBoolean("VoteParty.SendToAllServers", true);
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired", 100);
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getData().getStringList("VoteParty.BungeeCommands");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class RedisBungee implements Listener {
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
private VotingPluginBungee plugin;
|
||||
|
||||
public RedisBungee(VotingPluginBungee plugin) {
|
||||
this.plugin = plugin;
|
||||
if (plugin.getConfig().getRedisSupport()) {
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, this);
|
||||
plugin.getLogger().info("Loaded expiremental redis support");
|
||||
enabled = true;
|
||||
} else {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerJoinedNetworkEvent(PlayerJoinedNetworkEvent event) {
|
||||
plugin.login(plugin.getProxy().getPlayer(event.getUuid()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerChangedServerNetworkEventt(PlayerChangedServerNetworkEvent event) {
|
||||
plugin.login(plugin.getProxy().getPlayer(event.getUuid()));
|
||||
}
|
||||
|
||||
public boolean isOnline(ProxiedPlayer p) {
|
||||
return RedisBungeeAPI.getRedisBungeeApi().isPlayerOnline(p.getUniqueId());
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
plugin.getProxy().getPluginManager().unregisterListener(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public abstract class TimeHandle {
|
||||
@Getter
|
||||
@Setter
|
||||
private String month;
|
||||
@Getter
|
||||
@Setter
|
||||
private int day;
|
||||
@Getter
|
||||
@Setter
|
||||
private int week;
|
||||
|
||||
public TimeHandle(String month, int day, int week) {
|
||||
this.month = month;
|
||||
this.day = day;
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public abstract void save();
|
||||
}
|
||||
@@ -18,6 +18,30 @@ public class VoteCache {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getData().getInt("VoteParty.CurrentVotes", 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotes", 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
getData().set("VoteParty.CurrentVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
getData().set("VoteParty.IncreaseVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
getData().set("VoteParty.Cache." + server, amount);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getData().getInt("VoteParty.Cache." + server, 0);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
Configuration section = getData().getSection("VoteCache." + server + "." + num);
|
||||
section.set("Name", voteData.getPlayerName());
|
||||
@@ -26,7 +50,6 @@ public class VoteCache {
|
||||
section.set("Time", voteData.getTime());
|
||||
section.set("Real", voteData.isRealVote());
|
||||
section.set("Text", voteData.getText());
|
||||
save();
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
@@ -37,7 +60,6 @@ public class VoteCache {
|
||||
section.set("Time", voteData.getTime());
|
||||
section.set("Real", voteData.isRealVote());
|
||||
section.set("Text", voteData.getText());
|
||||
save();
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
|
||||
@@ -14,10 +14,21 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onVote(VotifierEvent event) {
|
||||
Vote vote = event.getVote();
|
||||
plugin.getLogger().info("Vote received " + vote.getUsername() + " from service site " + vote.getServiceName());
|
||||
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
|
||||
|
||||
plugin.vote(vote.getUsername(), vote.getServiceName(), true);
|
||||
@Override
|
||||
public void run() {
|
||||
Vote vote = event.getVote();
|
||||
String serviceSite = vote.getServiceName();
|
||||
plugin.getLogger().info("Vote received " + vote.getUsername() + " from service site " + serviceSite);
|
||||
|
||||
if (serviceSite.isEmpty()) {
|
||||
serviceSite = "Empty";
|
||||
}
|
||||
|
||||
plugin.vote(vote.getUsername(), serviceSite, true);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,11 @@ import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.security.CodeSource;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
@@ -18,31 +21,40 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.DataType;
|
||||
import com.bencodez.advancedcore.api.misc.jsonparser.JsonParser;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueString;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.bungeeapi.mysql.BungeeMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class VotingPluginBungee extends Plugin {
|
||||
public class VotingPluginBungee extends Plugin implements Listener {
|
||||
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
@@ -69,7 +81,13 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
private boolean votifierEnabled = true;
|
||||
|
||||
public void checkCachedVotes(String server) {
|
||||
@Getter
|
||||
private RedisBungee redis;
|
||||
|
||||
@Getter
|
||||
private TimeHandle timeHandle;
|
||||
|
||||
public synchronized void checkCachedVotes(String server) {
|
||||
if (getProxy().getServerInfo(server) != null) {
|
||||
if (!getProxy().getServerInfo(server).getPlayers().isEmpty()) {
|
||||
if (cachedVotes.containsKey(server) && !config.getBlockedServers().contains(server)) {
|
||||
@@ -80,7 +98,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
boolean toSend = true;
|
||||
if (getConfig().getWaitForUserOnline()) {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(cache.getUuid()));
|
||||
if (p == null || !p.isConnected()) {
|
||||
if (isOnline(p)) {
|
||||
toSend = false;
|
||||
} else if (p != null && p.isConnected()
|
||||
&& !p.getServer().getInfo().getName().equals(server)) {
|
||||
@@ -93,7 +111,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
} else {
|
||||
debug("Not sending vote because user isn't on server " + server + ": "
|
||||
+ cache.toString());
|
||||
@@ -108,8 +126,8 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
}
|
||||
|
||||
public void checkOnlineVotes(ProxiedPlayer player, String uuid, String server) {
|
||||
if (player != null && player.isConnected() && cachedOnlineVotes.containsKey(uuid)) {
|
||||
public synchronized void checkOnlineVotes(ProxiedPlayer player, String uuid, String server) {
|
||||
if (isOnline(player) && cachedOnlineVotes.containsKey(uuid)) {
|
||||
ArrayList<OfflineBungeeVote> c = cachedOnlineVotes.get(uuid);
|
||||
if (!c.isEmpty()) {
|
||||
if (server == null) {
|
||||
@@ -120,7 +138,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
sendPluginMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
@@ -149,7 +167,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
// Parse JSON response and get UUID
|
||||
JsonElement element = new JsonParser().parse(bufferedReader);
|
||||
JsonElement element = JsonParser.parseReader(bufferedReader);
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
String uuidAsString = object.get("id").getAsString();
|
||||
|
||||
@@ -182,61 +200,36 @@ public class VotingPluginBungee extends Plugin {
|
||||
return "";
|
||||
}
|
||||
|
||||
private int getValue(ArrayList<Column> cols, String column) {
|
||||
private int getValue(ArrayList<Column> cols, String column, int toAdd) {
|
||||
for (Column d : cols) {
|
||||
if (d.getName().equalsIgnoreCase(column)) {
|
||||
|
||||
Object value = d.getValue();
|
||||
DataValue value = d.getValue();
|
||||
int num = 0;
|
||||
if (value instanceof Integer) {
|
||||
if (value.isInt()) {
|
||||
num = value.getInt();
|
||||
} else if (value.isString()) {
|
||||
try {
|
||||
num = (int) value;
|
||||
} catch (ClassCastException | NullPointerException ex) {
|
||||
}
|
||||
} else if (value instanceof String) {
|
||||
try {
|
||||
num = Integer.parseInt((String) value);
|
||||
num = Integer.parseInt(value.getString());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return num;
|
||||
return num + toAdd;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int mysqlUpdate(ArrayList<Column> cols, String uuid, String column, int toAdd) {
|
||||
int num = getValue(cols, column) + toAdd;
|
||||
debug("Setting " + column + " to " + num + " for " + uuid);
|
||||
mysql.update(uuid, column, num, DataType.INTEGER);
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
|
||||
String server = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVote(server, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
}
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
mysql = new BungeeMySQL(this, "VotingPlugin_Users", config.getData());
|
||||
mysql = new BungeeMySQL(this, "VotingPlugin_Users", config.getData()) {
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// column types
|
||||
getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
@@ -265,6 +258,79 @@ public class VotingPluginBungee extends Plugin {
|
||||
getMysql().alterColumnType("DayVoteStreakLastUpdate", "MEDIUMTEXT");
|
||||
}
|
||||
|
||||
private String buildNumber = "NOTSET";
|
||||
|
||||
public void loadVersionFile() {
|
||||
Configuration conf = getVersionFile();
|
||||
if (conf != null) {
|
||||
buildNumber = conf.get("buildnumber", "NOTSET");
|
||||
}
|
||||
}
|
||||
|
||||
private Configuration getVersionFile() {
|
||||
try {
|
||||
CodeSource src = this.getClass().getProtectionDomain().getCodeSource();
|
||||
if (src != null) {
|
||||
URL jar = src.getLocation();
|
||||
ZipInputStream zip = null;
|
||||
zip = new ZipInputStream(jar.openStream());
|
||||
while (true) {
|
||||
ZipEntry e = zip.getNextEntry();
|
||||
if (e != null) {
|
||||
String name = e.getName();
|
||||
if (name.equals("votingpluginversion.yml")) {
|
||||
Reader defConfigStream = new InputStreamReader(zip);
|
||||
if (defConfigStream != null) {
|
||||
Configuration conf = ConfigurationProvider
|
||||
.getProvider(net.md_5.bungee.config.YamlConfiguration.class)
|
||||
.load(defConfigStream);
|
||||
|
||||
defConfigStream.close();
|
||||
return conf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
getLogger().info("VotingPlugin saving vote cache: " + cachedVotes.size() + "/" + cachedOnlineVotes.size());
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
|
||||
String server = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVote(server, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
timeHandle.save();
|
||||
voteCacheFile.save();
|
||||
nonVotedPlayersCache.save();
|
||||
if (mysql != null) {
|
||||
mysql.shutdown();
|
||||
}
|
||||
if (redis != null) {
|
||||
redis.destroy();
|
||||
}
|
||||
getLogger().info("VotingPlugin disabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
@@ -276,12 +342,20 @@ public class VotingPluginBungee extends Plugin {
|
||||
if (votifierEnabled) {
|
||||
try {
|
||||
getProxy().getPluginManager().registerListener(this, new VoteEventBungee(this));
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
config = new Config(this);
|
||||
config.load();
|
||||
|
||||
try {
|
||||
redis = new RedisBungee(this);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
|
||||
|
||||
boolean mysqlLoaded = true;
|
||||
@@ -305,15 +379,24 @@ public class VotingPluginBungee extends Plugin {
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
if (mysqlLoaded) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
voteCacheFile = new VoteCache(this);
|
||||
voteCacheFile.load();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
voteCacheFile = new VoteCache(this);
|
||||
voteCacheFile.load();
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(this);
|
||||
nonVotedPlayersCache.load();
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(this);
|
||||
nonVotedPlayersCache.load();
|
||||
timeHandle = new TimeHandle(voteCacheFile.getData().getString("Time.Month", ""),
|
||||
voteCacheFile.getData().getInt("Time.Day"), voteCacheFile.getData().getInt("Time.Week")) {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
voteCacheFile.getData().set("Time.Month", timeHandle.getMonth());
|
||||
voteCacheFile.getData().set("Time.Day", timeHandle.getDay());
|
||||
voteCacheFile.getData().set("Time.Week", timeHandle.getWeek());
|
||||
}
|
||||
};
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
try {
|
||||
for (String server : voteCacheFile.getServers()) {
|
||||
@@ -418,6 +501,10 @@ public class VotingPluginBungee extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
votePartyVotes = voteCacheFile.getVotePartyCurrentVotes();
|
||||
|
||||
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
|
||||
|
||||
metrics.addCustomChart(
|
||||
@@ -438,14 +525,59 @@ public class VotingPluginBungee extends Plugin {
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("waitforuseronline", () -> "" + getConfig().getWaitForUserOnline()));
|
||||
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("dev_build_number", () -> "" + buildNumber));
|
||||
}
|
||||
|
||||
loadVersionFile();
|
||||
|
||||
getLogger().info("VotingPlugin loaded, using method: " + method.toString() + ", PluginMessagingVersion: "
|
||||
+ BungeeVersion.getPluginMessageVersion());
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
getLogger().info("Detected using dev build number: " + buildNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PostLoginEvent event) {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayer(event.getPlayer());
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public boolean isOnline(ProxiedPlayer p) {
|
||||
if (p != null) {
|
||||
if (redis != null && redis.isEnabled()) {
|
||||
return redis.isOnline(p);
|
||||
} else {
|
||||
return p.isConnected();
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void login(ProxiedPlayer p) {
|
||||
if (isOnline(p)) {
|
||||
if (p.getServer() != null && p.getServer().getInfo() != null) {
|
||||
final String server = p.getServer().getInfo().getName();
|
||||
final ProxiedPlayer proixedPlayer = p;
|
||||
getProxy().getScheduler().runAsync(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(proixedPlayer, proixedPlayer.getUniqueId().toString(), server);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,6 +590,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
ev.setCancelled(true);
|
||||
|
||||
if (!(ev.getSender() instanceof Server)) {
|
||||
debug("Ignore plugin message");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -469,6 +602,8 @@ public class VotingPluginBungee extends Plugin {
|
||||
String subchannel = in.readUTF();
|
||||
int size = in.readInt();
|
||||
|
||||
debug("Received plugin message, processing...");
|
||||
|
||||
// check for status message returns
|
||||
if (subchannel.equalsIgnoreCase("statusokay")) {
|
||||
String server = in.readUTF();
|
||||
@@ -476,13 +611,19 @@ public class VotingPluginBungee extends Plugin {
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
String player = in.readUTF();
|
||||
debug("Login: " + player);
|
||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
||||
String server = p.getServer().getInfo().getName();
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(p, p.getUniqueId().toString(), server);
|
||||
login(p);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("timeupdate")) {
|
||||
String str = in.readUTF();
|
||||
String[] data = str.split(Pattern.quote("//"));
|
||||
if (data.length == 3) {
|
||||
timeHandle.setMonth(data[0]);
|
||||
timeHandle.setDay(Integer.parseInt(data[1]));
|
||||
timeHandle.setWeek(Integer.parseInt(data[2]));
|
||||
}
|
||||
} else {
|
||||
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
@@ -500,21 +641,6 @@ public class VotingPluginBungee extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
final String server = event.getServer().getInfo().getName();
|
||||
final String uuid = event.getPlayer().getUniqueId().toString();
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(event.getPlayer(), uuid, server);
|
||||
}
|
||||
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private UUID parseUUIDFromString(String uuidAsString) {
|
||||
String[] parts = { "0x" + uuidAsString.substring(0, 8), "0x" + uuidAsString.substring(8, 12),
|
||||
"0x" + uuidAsString.substring(12, 16), "0x" + uuidAsString.substring(16, 20),
|
||||
@@ -535,6 +661,8 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
public void reload(boolean loadMysql) {
|
||||
config.load();
|
||||
currentVotePartyVotesRequired = getConfig().getVotePartyVotesRequired()
|
||||
+ voteCacheFile.getVotePartyInreaseVotesRequired();
|
||||
if (loadMysql) {
|
||||
try {
|
||||
if (!config.getData().getString("Host", "").isEmpty()) {
|
||||
@@ -635,7 +763,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
public void vote(String player, String service, boolean realVote) {
|
||||
public synchronized void vote(String player, String service, boolean realVote) {
|
||||
try {
|
||||
if (player == null || player.isEmpty()) {
|
||||
getLogger().info("No name from vote on " + service);
|
||||
@@ -645,6 +773,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
String uuid = getUUID(player);
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getAllowUnJoined()) {
|
||||
debug("Fetching UUID online, since allowunjoined is enabled");
|
||||
UUID u = null;
|
||||
try {
|
||||
u = fetchUUID(player);
|
||||
@@ -659,7 +788,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
}
|
||||
uuid = u.toString();
|
||||
} else {
|
||||
getLogger().info("Ignoring vote from " + player);
|
||||
getLogger().info("Ignoring vote from " + player + " since player hasn't joined before");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -668,6 +797,8 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
BungeeMessageData text = null;
|
||||
|
||||
addVoteParty();
|
||||
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
if (mysql == null) {
|
||||
@@ -676,28 +807,32 @@ public class VotingPluginBungee extends Plugin {
|
||||
}
|
||||
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", player, DataType.STRING);
|
||||
mysql.update(uuid, "PlayerName", new DataValueString(player));
|
||||
}
|
||||
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", uuid, DataType.STRING));
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", new DataValueString(uuid)));
|
||||
|
||||
text = new BungeeMessageData(mysqlUpdate(data, uuid, "AllTimeTotal", 1),
|
||||
mysqlUpdate(data, uuid, "MonthTotal", 1), mysqlUpdate(data, uuid, "WeeklyTotal", 1),
|
||||
mysqlUpdate(data, uuid, "DailyTotal", 1),
|
||||
mysqlUpdate(data, uuid, "Points", getConfig().getPointsOnVote()),
|
||||
mysqlUpdate(data, uuid, "MilestoneCount", 1));
|
||||
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
|
||||
int monthTotal = getValue(data, "MonthTotal", 1);
|
||||
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
|
||||
int dailyTotal = getValue(data, "DailyTotal", 1);
|
||||
int points = getValue(data, "Points", getConfig().getPointsOnVote());
|
||||
int milestoneCount = getValue(data, "MilestoneCount", 1);
|
||||
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points, milestoneCount,
|
||||
votePartyVotes, currentVotePartyVotesRequired);
|
||||
ArrayList<Column> update = new ArrayList<Column>();
|
||||
update.add(new Column("AllTimeTotal", new DataValueInt(allTimeTotal)));
|
||||
update.add(new Column("MonthTotal", new DataValueInt(monthTotal)));
|
||||
update.add(new Column("WeeklyTotal", new DataValueInt(weeklyTotal)));
|
||||
update.add(new Column("DailyTotal", new DataValueInt(dailyTotal)));
|
||||
update.add(new Column("Points", new DataValueInt(points)));
|
||||
update.add(new Column("MilestoneCount", new DataValueInt(milestoneCount)));
|
||||
debug("Setting totals " + text.toString());
|
||||
mysql.update(uuid, update);
|
||||
} else {
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0);
|
||||
text = new BungeeMessageData(0, 0, 0, 0, 0, 0, votePartyVotes, currentVotePartyVotesRequired);
|
||||
}
|
||||
|
||||
/*
|
||||
* String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" +
|
||||
* mysqlUpdate(data, uuid, "MonthTotal", 1) + "//" + mysqlUpdate(data, uuid,
|
||||
* "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1) + "//" +
|
||||
* mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid,
|
||||
* "MilestoneCount", 1);
|
||||
*/
|
||||
|
||||
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
@@ -708,7 +843,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
ServerInfo info = getProxy().getServerInfo(s);
|
||||
boolean forceCache = false;
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if ((p == null || !p.isConnected()) && getConfig().getWaitForUserOnline()) {
|
||||
if (!isOnline(p) && getConfig().getWaitForUserOnline()) {
|
||||
forceCache = true;
|
||||
debug("Forcing vote to cache");
|
||||
}
|
||||
@@ -728,17 +863,20 @@ public class VotingPluginBungee extends Plugin {
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + BungeeVersion.getPluginMessageVersion(), "" + config.getBroadcast());
|
||||
}
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if (p != null && p.isConnected()
|
||||
&& !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
|
||||
if (isOnline(p) && !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
|
||||
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion());
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion(),
|
||||
"" + config.getBroadcast());
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
@@ -751,6 +889,13 @@ public class VotingPluginBungee extends Plugin {
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid, "" + votePartyVotes,
|
||||
"" + currentVotePartyVotesRequired);
|
||||
if (config.getBroadcast()) {
|
||||
sendPluginMessageServer(s, "VoteBroadcast", uuid, player, service);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
@@ -761,4 +906,63 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
}
|
||||
|
||||
private int votePartyVotes = 0;
|
||||
private int currentVotePartyVotesRequired = 0;
|
||||
|
||||
public void addCurrentVotePartyVotes(int amount) {
|
||||
votePartyVotes += amount;
|
||||
voteCacheFile.setVotePartyCurrentVotes(votePartyVotes);
|
||||
debug("Current vote party total: " + votePartyVotes);
|
||||
}
|
||||
|
||||
public void addVoteParty() {
|
||||
if (getConfig().getVotePartyEnabled()) {
|
||||
addCurrentVotePartyVotes(1);
|
||||
|
||||
if (votePartyVotes >= currentVotePartyVotesRequired) {
|
||||
debug("Vote party reached");
|
||||
addCurrentVotePartyVotes(-currentVotePartyVotesRequired);
|
||||
|
||||
currentVotePartyVotesRequired += getConfig().getVotePartyIncreaseVotesRequired();
|
||||
voteCacheFile.setVotePartyInreaseVotesRequired(voteCacheFile.getVotePartyInreaseVotesRequired()
|
||||
+ getConfig().getVotePartyIncreaseVotesRequired());
|
||||
|
||||
if (!getConfig().getVotePartyBroadcast().isEmpty()) {
|
||||
getProxy().broadcast(new TextComponent(
|
||||
ChatColor.translateAlternateColorCodes('&', getConfig().getVotePartyBroadcast())));
|
||||
}
|
||||
|
||||
for (String command : getConfig().getVotePartyBungeeCommands()) {
|
||||
getProxy().getPluginManager().dispatchCommand(getProxy().getConsole(), command);
|
||||
}
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
if (getConfig().getVotePartySendToAllServers()) {
|
||||
for (Entry<String, ServerInfo> entry : getProxy().getServers().entrySet()) {
|
||||
sendVoteParty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
} else {
|
||||
for (String server : getConfig().getVotePartyServersToSend()) {
|
||||
ServerInfo serverInfo = getProxy().getServerInfo(server);
|
||||
if (serverInfo != null) {
|
||||
sendVoteParty(server, serverInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
voteCacheFile.save();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendVoteParty(String server, ServerInfo serverInfo) {
|
||||
if (!serverInfo.getPlayers().isEmpty()) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sendPluginMessageServer(server, "VotePartyBungee");
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessageServer(server, "VotePartyBungee");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -29,7 +29,7 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
bungee.vote(user, site, false);
|
||||
sender.sendMessage(new TextComponent("&aSending vote"));
|
||||
sender.sendMessage(new TextComponent("Sending vote"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
|
||||
@@ -1,483 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.queries.Query;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.DataType;
|
||||
|
||||
public class BungeeMySQL {
|
||||
private List<String> columns = Collections.synchronizedList(new ArrayList<String>());
|
||||
|
||||
private List<String> intColumns = new ArrayList<String>();
|
||||
|
||||
// private HashMap<String, ArrayList<Column>> table;
|
||||
|
||||
// ConcurrentMap<String, ArrayList<Column>> table = new
|
||||
// ConcurrentHashMap<String, ArrayList<Column>>();
|
||||
|
||||
private com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL mysql;
|
||||
|
||||
private String name;
|
||||
|
||||
private Object object2 = new Object();
|
||||
|
||||
private Object object3 = new Object();
|
||||
|
||||
private Object object4 = new Object();
|
||||
|
||||
private Set<String> uuids = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
public BungeeMySQL(VotingPluginVelocity plugin, String tableName, Config config) {
|
||||
String tablePrefix = config.getString(config.getNode("Prefix"), "");
|
||||
String hostName = config.getString(config.getNode("Host"), "");
|
||||
int port = config.getInt(config.getNode("Port"), 0);
|
||||
String user = config.getString(config.getNode("Username"), "");
|
||||
String pass = config.getString(config.getNode("Password"), "");
|
||||
String database = config.getString(config.getNode("Database"), "");
|
||||
long lifeTime = config.getLong(config.getNode("MaxLifeTime"), -1);
|
||||
int maxThreads = config.getInt(config.getNode("MaxConnections"), 1);
|
||||
String str = config.getString(config.getNode("Line"), "");
|
||||
if (maxThreads < 1) {
|
||||
maxThreads = 1;
|
||||
}
|
||||
boolean useSSL = config.getBoolean(config.getNode("UseSSL"), false);
|
||||
boolean publicKeyRetrieval = config.getBoolean(config.getNode("PublicKeyRetrieval"), false);
|
||||
name = config.getString(config.getNode("Name"), "");
|
||||
if (!name.isEmpty()) {
|
||||
name = tableName;
|
||||
}
|
||||
|
||||
if (tablePrefix != null) {
|
||||
name = tablePrefix + tableName;
|
||||
}
|
||||
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads) {
|
||||
|
||||
@Override
|
||||
public void severe(String string) {
|
||||
plugin.getLogger().error(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (plugin.getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!mysql.connect(hostName, "" + port, user, pass, database, useSSL, lifeTime, str, publicKeyRetrieval)) {
|
||||
|
||||
}
|
||||
try {
|
||||
Query q = new Query(mysql, "USE " + database + ";");
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String sql = "CREATE TABLE IF NOT EXISTS " + getName() + " (";
|
||||
sql += "uuid VARCHAR(37),";
|
||||
sql += "PRIMARY KEY ( uuid )";
|
||||
sql += ");";
|
||||
Query query;
|
||||
try {
|
||||
query = new Query(mysql, sql);
|
||||
|
||||
query.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
loadData();
|
||||
|
||||
// tempoary to improve performance from old tables
|
||||
// addToQue("ALTER TABLE " + getName() + " MODIFY uuid VARCHAR(37);");
|
||||
alterColumnType("uuid", "VARCHAR(37)");
|
||||
}
|
||||
|
||||
public void addColumn(String column, DataType dataType) {
|
||||
synchronized (object3) {
|
||||
String sql = "ALTER TABLE " + getName() + " ADD COLUMN " + column + " text" + ";";
|
||||
try {
|
||||
Query query = new Query(mysql, sql);
|
||||
query.executeUpdate();
|
||||
|
||||
getColumns().add(column);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void alterColumnType(String column, String newType) {
|
||||
checkColumn(column, DataType.STRING);
|
||||
if (newType.contains("INT")) {
|
||||
try {
|
||||
new Query(mysql, "UPDATE " + getName() + " SET " + column + " = '0' where trim(coalesce(" + column
|
||||
+ ", '')) = '';").executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
;
|
||||
if (!intColumns.contains(column)) {
|
||||
intColumns.add(column);
|
||||
}
|
||||
}
|
||||
try {
|
||||
new Query(mysql, "ALTER TABLE " + getName() + " MODIFY " + column + " " + newType + ";")
|
||||
.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkColumn(String column, DataType dataType) {
|
||||
synchronized (object4) {
|
||||
if (!getColumns().contains(column)) {
|
||||
if (!getColumnsQueury().contains(column)) {
|
||||
addColumn(column, dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
clearCacheBasic();
|
||||
}
|
||||
|
||||
public void clearCacheBasic() {
|
||||
columns.clear();
|
||||
columns.addAll(getColumnsQueury());
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
}
|
||||
|
||||
public void close() {
|
||||
mysql.disconnect();
|
||||
}
|
||||
|
||||
public boolean containsKeyQuery(String index) {
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
while (rs.next()) {
|
||||
if (rs.getString("uuid").equals(index)) {
|
||||
rs.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> getColumns() {
|
||||
if (columns == null || columns.size() == 0) {
|
||||
loadData();
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
public ArrayList<String> getColumnsQueury() {
|
||||
ArrayList<String> columns = new ArrayList<String>();
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement("SELECT * FROM " + getName() + ";")) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, "SELECT * FROM " + getName() + ";"); ResultSet
|
||||
* rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
ResultSetMetaData metadata = rs.getMetaData();
|
||||
int columnCount = 0;
|
||||
if (metadata != null) {
|
||||
columnCount = metadata.getColumnCount();
|
||||
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = metadata.getColumnName(i);
|
||||
columns.add(columnName);
|
||||
}
|
||||
rs.close();
|
||||
return columns;
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return columns;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Column> getExactQuery(Column column) {
|
||||
ArrayList<Column> result = new ArrayList<>();
|
||||
String query = "SELECT * FROM " + getName() + " WHERE `" + column.getName() + "`='"
|
||||
+ column.getValue().toString() + "';";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); sql.setParameter(1,
|
||||
* column.getValue().toString()); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
String columnName = rs.getMetaData().getColumnLabel(i);
|
||||
Column rCol = null;
|
||||
if (intColumns.contains(columnName)) {
|
||||
rCol = new Column(columnName, DataType.INTEGER);
|
||||
} else {
|
||||
rCol = new Column(columnName, DataType.STRING);
|
||||
}
|
||||
// System.out.println(i + " " +
|
||||
// rs.getMetaData().getColumnLabel(i));
|
||||
rCol.setValue(rs.getString(i));
|
||||
// System.out.println(rCol.getValue());
|
||||
result.add(rCol);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
|
||||
for (String col : getColumns()) {
|
||||
result.add(new Column(col, DataType.STRING));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<String> getNamesQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
|
||||
checkColumn("PlayerName", DataType.STRING);
|
||||
ArrayList<Column> rows = getRowsNameQuery();
|
||||
if (rows != null) {
|
||||
for (Column c : rows) {
|
||||
uuids.add((String) c.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsNameQuery() {
|
||||
ArrayList<Column> result = new ArrayList<Column>();
|
||||
String sqlStr = "SELECT PlayerName FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("PlayerName", rs.getString("PlayerName"), DataType.STRING);
|
||||
result.add(rCol);
|
||||
}
|
||||
sql.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsQuery() {
|
||||
ArrayList<Column> result = new ArrayList<Column>();
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("uuid", rs.getString("uuid"), DataType.STRING);
|
||||
result.add(rCol);
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
String query = "SELECT uuid FROM " + getName() + " WHERE " + "PlayerName" + "='" + playerName + "';";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
String uuid = rs.getString("uuid");
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
rs.close();
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getUuids() {
|
||||
if (uuids == null || uuids.size() == 0) {
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
return uuids;
|
||||
}
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<String> getUuidsQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
|
||||
ArrayList<Column> rows = getRowsQuery();
|
||||
for (Column c : rows) {
|
||||
uuids.add((String) c.getValue());
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public void insert(String index, String column, Object value, DataType dataType) {
|
||||
insertQuery(index, Arrays.asList(new Column(column, value, dataType)));
|
||||
}
|
||||
|
||||
public void insertQuery(String index, List<Column> cols) {
|
||||
String query = "INSERT " + getName() + " ";
|
||||
|
||||
query += "set uuid='" + index + "', ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "';";
|
||||
} else {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "', ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
uuids.add(index);
|
||||
new Query(mysql, query).executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isIntColumn(String key) {
|
||||
return intColumns.contains(key);
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
columns = getColumnsQueury();
|
||||
}
|
||||
|
||||
public void update(String index, List<Column> cols, boolean queue) {
|
||||
for (Column col : cols) {
|
||||
checkColumn(col.getName(), col.getDataType());
|
||||
}
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
if (col.getDataType().equals(DataType.STRING)) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "';";
|
||||
} else {
|
||||
query += col.getName() + "=" + col.getValue().toString() + ";";
|
||||
}
|
||||
} else {
|
||||
if (col.getDataType().equals(DataType.STRING)) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "', ";
|
||||
} else {
|
||||
query += col.getName() + "=" + col.getValue().toString() + ", ";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
insertQuery(index, cols);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String index, String column, Object value, DataType dataType) {
|
||||
checkColumn(column, dataType);
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
if (dataType == DataType.STRING) {
|
||||
query += column + "='" + value.toString() + "'";
|
||||
} else {
|
||||
query += column + "=" + value;
|
||||
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
insert(index, column, value, dataType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,10 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class Config extends VelocityYMLFile {
|
||||
@@ -13,6 +17,10 @@ public class Config extends VelocityYMLFile {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getBoolean(getNode("AllowUnJoined"), false);
|
||||
}
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getStringList(getNode("BlockedServers"), new ArrayList<String>());
|
||||
}
|
||||
@@ -21,22 +29,14 @@ public class Config extends VelocityYMLFile {
|
||||
return getBoolean(getNode("Broadcast"), false);
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
public boolean getBungeeManageTotals() {
|
||||
return getBoolean(getNode("BungeeManageTotals"), true);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getBoolean(getNode("AllowUnJoined"), false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
public String getBungeeMethod() {
|
||||
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
|
||||
}
|
||||
@@ -53,31 +53,59 @@ public class Config extends VelocityYMLFile {
|
||||
return getString(getNode("FallBackServer"), "");
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getBoolean(getNode("SendVotesToAllServers"), true);
|
||||
}
|
||||
|
||||
public ConfigurationNode getSpigotServerConfiguration(String s) {
|
||||
return getNode("SpigotServers", s);
|
||||
public ConfigurationNode getMysqlNode() {
|
||||
return getNode("MySQL");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getInt(getNode("PointsOnVote"), 1);
|
||||
}
|
||||
|
||||
public Collection<String> getSpigotServers() {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (ConfigurationNode conf : getNode("SpigotServers").getChildrenList()) {
|
||||
list.add(conf.getKey().toString());
|
||||
}
|
||||
return list;
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getBoolean(getNode("SendVotesToAllServers"), true);
|
||||
}
|
||||
|
||||
public ConfigurationNode getMysqlNode() {
|
||||
return getNode("MySQL");
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getBoolean(getVotePartyNode().getNode("Enabled"), false);
|
||||
}
|
||||
|
||||
public long getLong(ConfigurationNode node, long def) {
|
||||
return node.getLong(def);
|
||||
public ConfigurationNode getVotePartyNode() {
|
||||
return getNode("VoteParty");
|
||||
}
|
||||
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getBoolean(getVotePartyNode().getNode("SendToAllServers"), false);
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("VotesRequired"), 100);
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("IncreaseVotesRequired"), 0);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getString(getVotePartyNode().getNode("Broadcast"), "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getStringList(getVotePartyNode().getNode("ServersToSend"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getStringList(getVotePartyNode().getNode("BungeeCommands"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public ConfigurationNode getSpigotServerConfiguration(String s) {
|
||||
return getNode("SpigotServers", s);
|
||||
}
|
||||
|
||||
public @NonNull Collection<? extends ConfigurationNode> getSpigotServers() {
|
||||
return getNode("SpigotServers").getChildrenMap().values();
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
public class NonVotedPlayersCache extends VelocityYMLFile {
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
import lombok.Getter;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
|
||||
public class VelocityYMLFile {
|
||||
@Getter
|
||||
private File file;
|
||||
@Getter
|
||||
private ConfigurationNode conf;
|
||||
private YAMLConfigurationLoader loader;
|
||||
|
||||
public VelocityYMLFile(File file) {
|
||||
|
||||
this.file = file;
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
loader = YAMLConfigurationLoader.builder().setPath(file.toPath()).build();
|
||||
|
||||
try {
|
||||
conf = loader.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ConfigurationNode getData() {
|
||||
return conf;
|
||||
}
|
||||
|
||||
public ConfigurationNode getNode(Object... path) {
|
||||
return getData().getNode(path);
|
||||
}
|
||||
|
||||
public List<String> getStringList(ConfigurationNode node, ArrayList<String> def) {
|
||||
try {
|
||||
return node.getList(TypeToken.of(String.class), def);
|
||||
} catch (ObjectMappingException e) {
|
||||
e.printStackTrace();
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public String getString(ConfigurationNode node, String def) {
|
||||
return node.getString(def);
|
||||
}
|
||||
|
||||
public boolean getBoolean(ConfigurationNode node, boolean def) {
|
||||
return node.getBoolean(def);
|
||||
}
|
||||
|
||||
public int getInt(ConfigurationNode node, int def) {
|
||||
return node.getInt(def);
|
||||
}
|
||||
|
||||
public ArrayList<String> getKeys(ConfigurationNode node) {
|
||||
ArrayList<String> keys = new ArrayList<String>();
|
||||
for (ConfigurationNode key : node.getChildrenList()) {
|
||||
keys.add(key.getKey().toString());
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
loader = YAMLConfigurationLoader.builder().setPath(file.toPath()).build();
|
||||
|
||||
try {
|
||||
conf = loader.load();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
loader.save(conf);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
@@ -13,6 +14,30 @@ public class VoteCache extends VelocityYMLFile {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getInt(getNode("VoteParty").getNode("CurrentVotes"), 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getInt(getNode("VoteParty").getNode("IncreaseVotes"), 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
getNode("VoteParty").getNode("CurrentVotes").setValue(amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
getNode("VoteParty").getNode("IncreaseVotes").setValue(amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
getNode("VoteParty").getNode("Cache").getNode(server).setValue(amount);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getNode("VoteParty").getNode("Cache").getNode(server).getInt(0);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
String[] path = new String[] { "VoteCache", server, "" + num };
|
||||
|
||||
@@ -22,8 +47,6 @@ public class VoteCache extends VelocityYMLFile {
|
||||
getNode(path, "Time").setValue(voteData.getTime());
|
||||
getNode(path, "Real").setValue(voteData.isRealVote());
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
@@ -35,8 +58,6 @@ public class VoteCache extends VelocityYMLFile {
|
||||
getNode(path, "Time").setValue(voteData.getTime());
|
||||
getNode(path, "Real").setValue(voteData.isRealVote());
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
|
||||
+591
-332
File diff suppressed because it is too large.
Load diff
@@ -4,6 +4,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -30,8 +31,7 @@ import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
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;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
@@ -263,10 +263,11 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting...");
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
user.setMilestoneCount(user.getTotal(TopVoter.AllTime));
|
||||
}
|
||||
sendMessage(sender, "&cFinished");
|
||||
sendMessage(sender, "&cFinished sync milestonecount with all time total");
|
||||
|
||||
}
|
||||
});
|
||||
@@ -279,10 +280,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting to clear milestonecounts...");
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setMilestoneCount(0);
|
||||
}
|
||||
plugin.getTopVoterHandler().resetMilestoneCount();
|
||||
sendMessage(sender, "&cFinished");
|
||||
|
||||
}
|
||||
@@ -306,7 +304,9 @@ public class CommandLoader {
|
||||
}
|
||||
}
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
for (int num : nums) {
|
||||
if (milestoneCount >= num) {
|
||||
@@ -318,6 +318,16 @@ public class CommandLoader {
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, true);
|
||||
}
|
||||
} else {
|
||||
if (user.hasGottenMilestone(num)) {
|
||||
sendMessage(sender,
|
||||
"&cMilestone " + num + " for " + user.getPlayerName()
|
||||
+ " already given when it shouldn't be, Current AllTimeTotal: "
|
||||
+ user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: "
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -334,10 +344,8 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cStarting...");
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setPoints(0);
|
||||
}
|
||||
plugin.getUserManager().removeAllKeyValues("Points", DataType.INTEGER);
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
sendMessage(sender, "&cFinished");
|
||||
|
||||
}
|
||||
@@ -365,6 +373,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.clearCache();
|
||||
synchronized (pointLock) {
|
||||
user.addPoints(Integer.parseInt(args[3]));
|
||||
}
|
||||
@@ -380,6 +389,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.clearCache();
|
||||
user.removePoints(Integer.parseInt(args[3]));
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cRemoved " + args[3] + " points from "
|
||||
+ args[1] + ", " + args[1] + " now has " + user.getPoints() + " points"));
|
||||
@@ -408,7 +418,7 @@ public class CommandLoader {
|
||||
for (String serviceSite : serviceSites) {
|
||||
boolean hasSite = plugin.hasVoteSite(serviceSite);
|
||||
if (hasSite) {
|
||||
String siteName = plugin.getVoteSiteName(serviceSite);
|
||||
String siteName = plugin.getVoteSiteName(true, serviceSite);
|
||||
sendMessage(sender, serviceSite + " : Current site = " + siteName);
|
||||
} else {
|
||||
sendMessage(sender, serviceSite
|
||||
@@ -428,7 +438,7 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int page = Integer.parseInt(args[1]);
|
||||
new AdminVoteHelp(plugin, sender, page).open();
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
@@ -624,6 +634,12 @@ public class CommandLoader {
|
||||
|
||||
sendMessage(sender,
|
||||
"Using AdvancedCore " + plugin.getVersion() + "' built on '" + plugin.getBuildTime());
|
||||
if (!plugin.getAdvancedCoreBuildNumber().equals("NOTSET")) {
|
||||
sendMessage(sender, "AdvancedCore Jenkins build number: " + plugin.getAdvancedCoreBuildNumber());
|
||||
}
|
||||
if (!plugin.getBuildNumber().equals("NOTSET")) {
|
||||
sendMessage(sender, "Using votingplugin jenkins build: " + plugin.getBuildNumber());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -652,7 +668,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
new AdminGUI(plugin).openAdminGUIVoteSiteSite((Player) sender, plugin.getVoteSite(args[1]));
|
||||
new AdminGUI(plugin).openAdminGUIVoteSiteSite((Player) sender, plugin.getVoteSite(args[1], false));
|
||||
} else {
|
||||
sender.sendMessage("Must be a player to do this");
|
||||
}
|
||||
@@ -678,7 +694,7 @@ public class CommandLoader {
|
||||
try {
|
||||
sender.sendMessage(ChatColor.GREEN + "PlayerName of player " + ChatColor.DARK_GREEN + args[1]
|
||||
+ ChatColor.GREEN + " is: " + PlayerUtils.getInstance().getPlayerName(
|
||||
UserManager.getInstance().getVotingPluginUser(new UUID(args[1])), args[1]));
|
||||
UserManager.getInstance().getVotingPluginUser(UUID.fromString(args[1])), args[1]));
|
||||
} catch (IllegalArgumentException e) {
|
||||
sendMessage(sender, "&cInvalid uuid");
|
||||
}
|
||||
@@ -697,16 +713,16 @@ public class CommandLoader {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.clearTotals();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
plugin.getUserManager().removeAllKeyValues(top.getColumnName(), DataType.INTEGER);
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cCleared totals for everyone"));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ClearOfflineRewards" },
|
||||
"VotingPlugin.Commands.AdminVote.ClearOfflineRewards|" + adminPerm, "Reset offline votes/rewards") {
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ClearOfflineVoteRewards" },
|
||||
"VotingPlugin.Commands.AdminVote.ClearOfflineVoteRewards|" + adminPerm, "Reset offline votes/rewards") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
@@ -715,37 +731,14 @@ public class CommandLoader {
|
||||
StringParser.getInstance().colorize("&cThis command can not be done from ingame"));
|
||||
return;
|
||||
}
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.clearOfflineRewards();
|
||||
}
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cCleared totals for everyone"));
|
||||
plugin.getUserManager().removeAllKeyValues("OfflineVotes", DataType.STRING);
|
||||
plugin.getUserManager().removeAllKeyValues(plugin.getUserManager().getOfflineRewardsPath(),
|
||||
DataType.STRING);
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cCleared offline votes/rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "ConvertFromData", "(userstorage)" },
|
||||
"VotingPlugin.Commands.AdminVote.ConvertFromData",
|
||||
"Convert from selected user storage to current user storage") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cThis can not be done ingame"));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
sender.sendMessage("Starting to convert");
|
||||
UserStorage prevStorage = UserStorage.valueOf(args[1].toUpperCase());
|
||||
plugin.convertDataStorage(prevStorage, VotingPluginMain.plugin.getStorageType());
|
||||
sender.sendMessage("Finished converting!");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "DAY", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVoteStreak.Day|" + adminPerm, "Set votestreak for player") {
|
||||
@@ -855,6 +848,20 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "ClearGottenMilestones" },
|
||||
"VotingPlugin.Commands.AdminVote.ClearGottenMilestones|" + adminPerm,
|
||||
"Clears received milestones") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.setHasGottenMilestone(new HashMap<String, Boolean>());
|
||||
sender.sendMessage(
|
||||
StringParser.getInstance().colorize("&cClearing gotten milestones for " + args[1]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", "All" },
|
||||
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {
|
||||
|
||||
@@ -885,7 +892,8 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2]), args[1], args[2], false);
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[2], true), args[1], args[2],
|
||||
false);
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
@@ -951,8 +959,8 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[3]), args[1], args[3],
|
||||
false);
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(args[3], true), args[1],
|
||||
args[3], false);
|
||||
sendMessage(sender, "&cTriggering vote...");
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
@@ -1007,7 +1015,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
String voteSite = plugin.getVoteSiteName(args[1]);
|
||||
String voteSite = plugin.getVoteSiteName(true, args[1]);
|
||||
String serviceSite = args[3];
|
||||
plugin.getConfigVoteSites().setServiceSite(voteSite, serviceSite);
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
@@ -1021,7 +1029,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
String voteSite = plugin.getVoteSiteName(args[1]);
|
||||
String voteSite = plugin.getVoteSiteName(true, args[1]);
|
||||
String url = args[3];
|
||||
plugin.getConfigVoteSites().setVoteURL(voteSite, url);
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
@@ -1035,7 +1043,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
String voteSite = plugin.getVoteSiteName(args[1]);
|
||||
String voteSite = plugin.getVoteSiteName(true, args[1]);
|
||||
int value = Integer.parseInt(args[3]);
|
||||
plugin.getConfigVoteSites().setPriority(voteSite, value);
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
@@ -1050,7 +1058,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
String voteSite = plugin.getVoteSiteName(args[1]);
|
||||
String voteSite = plugin.getVoteSiteName(true, args[1]);
|
||||
int delay = Integer.parseInt(args[3]);
|
||||
plugin.getConfigVoteSites().setVoteDelay(voteSite, delay);
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
@@ -1106,7 +1114,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
String voteSite = plugin.getVoteSiteName(args[1]);
|
||||
String voteSite = plugin.getVoteSiteName(false, args[1]);
|
||||
boolean value = Boolean.parseBoolean(args[3]);
|
||||
|
||||
plugin.getConfigVoteSites().setEnabled(voteSite, value);
|
||||
@@ -1155,26 +1163,14 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "SetVotePartyCount", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVotePartyCount|" + adminPerm, "Set voteparty count") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
plugin.getVoteParty().setTotalVotes(Integer.parseInt(args[1]));
|
||||
sendMessage(sender, "&cSet vote party count to " + args[1]);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "ClearOfflineVotes" },
|
||||
"VotingPlugin.Commands.AdminVote.ClearOfflineVotes|" + adminPerm, "Clear all offline votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setOfflineVotes(new ArrayList<String>());
|
||||
}
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cCleared"));
|
||||
plugin.getUserManager().removeAllKeyValues("OfflineVotes", DataType.STRING);
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cOffline votes Cleared"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1216,8 +1212,8 @@ public class CommandLoader {
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "ForceVoteParty" },
|
||||
"VotingPlugin.Commands.AdminVote.ForceVoteParty|" + adminPerm,
|
||||
.add(new CommandHandler(new String[] { "VoteParty", "Force" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.Force|" + adminPerm,
|
||||
"Force a voteparty reward, resets vote count") {
|
||||
|
||||
@Override
|
||||
@@ -1226,8 +1222,34 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "SetVoteCount", "(Number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.SetVoteCount|" + adminPerm, "Set voteparty count") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int num = Integer.parseInt(args[2]);
|
||||
if (num == 0) {
|
||||
plugin.getVoteParty().reset(true);
|
||||
sendMessage(sender, "&cVoteparty totals have been set to 0 and all been reset");
|
||||
} else {
|
||||
plugin.getVoteParty().setTotalVotes(num);
|
||||
sendMessage(sender, "&cVoteparty total votes has been set to " + args[2]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "VoteParty", "AddVoteCount", "(Number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.SetVoteCount|" + adminPerm, "Add voteparty count") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int num = plugin.getVoteParty().getTotalVotes() + Integer.parseInt(args[2]);
|
||||
plugin.getVoteParty().setTotalVotes(num);
|
||||
sendMessage(sender, "&cVoteparty total votes has been set to " + num);
|
||||
}
|
||||
});
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "VotePartyExtraRequired", "(Number)" },
|
||||
.add(new CommandHandler(new String[] { "VoteParty", "SetExtraRequired", "(Number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.SetExtraRequired|" + adminPerm,
|
||||
"Set VotePartyExtraRequired value") {
|
||||
|
||||
@@ -1384,7 +1406,7 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
new AdminVotePlaceholdersPlayer(plugin, sender,
|
||||
UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1503,7 +1525,6 @@ public class CommandLoader {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1541,7 +1562,7 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(value),
|
||||
plugin.getVoteSite(value, true),
|
||||
UserGUI.getInstance().getCurrentPlayer(player),
|
||||
plugin.getVoteSiteServiceSite(value), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
@@ -1738,6 +1759,26 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getVoteCommand().add(new CommandHandler(new String[] { "ToggleReminders" },
|
||||
"VotingPlugin.Commands.Vote.ToggleReminders", "Enable/disable vote reminders", false) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player p = (Player) sender;
|
||||
boolean value = false;
|
||||
if (plugin.getVoteReminding().getRemindersEnabled().containsKey(p.getUniqueId())) {
|
||||
value = !plugin.getVoteReminding().getRemindersEnabled().get(p.getUniqueId());
|
||||
}
|
||||
plugin.getVoteReminding().getRemindersEnabled().put(p.getUniqueId(), value);
|
||||
|
||||
if (value) {
|
||||
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleRemindersEnabled());
|
||||
} else {
|
||||
sendMessage(sender, plugin.getConfigFile().getFormatCommandsVoteToggleRemindersDisabled());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteShopEnabled()) {
|
||||
plugin.getVoteCommand().add(new CommandHandler(new String[] { "Shop" },
|
||||
"VotingPlugin.Commands.Vote.Shop|" + playerPerm, "Open VoteShop GUI", false) {
|
||||
@@ -1852,7 +1893,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
new VoteLast(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
} else {
|
||||
sendMessage(sender, StringParser.getInstance()
|
||||
@@ -1894,7 +1935,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
new VoteNext(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
} else {
|
||||
sendMessage(sender, StringParser.getInstance()
|
||||
@@ -1908,7 +1949,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
String msg = plugin.getConfigFile().getFormatCommandVotePoints()
|
||||
.replace("%Player%", user.getPlayerName()).replace("%Points%", "" + user.getPoints());
|
||||
@@ -1951,7 +1992,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
new VoteGUI(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
} else {
|
||||
sendMessage(sender, StringParser.getInstance()
|
||||
@@ -2007,7 +2048,8 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
new VoteTopVoter(plugin, sender, null, top, 1).open(GUIMethod.CHAT);
|
||||
new VoteTopVoter(plugin, sender, null, top, 1)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2017,7 +2059,8 @@ public class CommandLoader {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int page = Integer.parseInt(args[2]);
|
||||
new VoteTopVoter(plugin, sender, null, top, page).open(GUIMethod.CHAT);
|
||||
new VoteTopVoter(plugin, sender, null, top, page)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -2029,7 +2072,8 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
int page = Integer.parseInt(args[1]);
|
||||
|
||||
new VoteTopVoter(plugin, sender, null, TopVoter.getDefault(), page).open(GUIMethod.CHAT);
|
||||
new VoteTopVoter(plugin, sender, null, TopVoter.getDefault(), page)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -2077,7 +2121,8 @@ public class CommandLoader {
|
||||
int all = 0;
|
||||
|
||||
for (String uuid : uuids) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
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);
|
||||
@@ -2103,7 +2148,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
new VoteTotal(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
} else {
|
||||
sendMessage(sender, StringParser.getInstance()
|
||||
@@ -2136,7 +2181,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
new VoteBest(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
} else {
|
||||
sendMessage(sender, StringParser.getInstance()
|
||||
@@ -2159,7 +2204,7 @@ public class CommandLoader {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (com.bencodez.advancedcore.api.user.UserManager.getInstance().userExist(args[1])) {
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
new VoteStreak(plugin, sender, UserManager.getInstance().getVotingPluginUser(args[1])).open();
|
||||
} else {
|
||||
sendMessage(sender, StringParser.getInstance()
|
||||
@@ -2176,21 +2221,28 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (plugin.getConfigFile().isAllowVotePointTransfers()) {
|
||||
VotingPluginUser cPlayer = UserManager.getInstance().getVotingPluginUser((Player) sender);
|
||||
cPlayer.cache();
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
int pointsToGive = Integer.parseInt(args[2]);
|
||||
if (pointsToGive > 0) {
|
||||
if (cPlayer.getPoints() >= pointsToGive) {
|
||||
user.addPoints(pointsToGive);
|
||||
cPlayer.removePoints(pointsToGive);
|
||||
sendMessage(sender, "&c" + pointsToGive + " points given to " + user.getPlayerName());
|
||||
user.sendMessage(
|
||||
"&cYou received " + pointsToGive + " points from " + cPlayer.getPlayerName());
|
||||
if (plugin.getUserManager().userExist(args[1])) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.dontCache();
|
||||
int pointsToGive = Integer.parseInt(args[2]);
|
||||
if (pointsToGive > 0) {
|
||||
if (cPlayer.getPoints() >= pointsToGive) {
|
||||
user.addPoints(pointsToGive);
|
||||
cPlayer.removePoints(pointsToGive);
|
||||
sendMessage(sender,
|
||||
"&c" + pointsToGive + " points given to " + user.getPlayerName());
|
||||
user.sendMessage("&cYou received " + pointsToGive + " points from "
|
||||
+ cPlayer.getPlayerName());
|
||||
} else {
|
||||
sendMessage(sender, "&cNot enough points");
|
||||
}
|
||||
} else {
|
||||
sendMessage(sender, "&cNot enough points");
|
||||
sendMessage(sender, "&cNumber of points needs to be greater than 0");
|
||||
}
|
||||
} else {
|
||||
sendMessage(sender, "&cNumber of points needs to be greater than 0");
|
||||
sendMessage(sender, "&c" + args[1] + " has not joined the server");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +149,15 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit BungeeVotePartyRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("BungeeVotePartyRewards"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml")) {
|
||||
|
||||
@Override
|
||||
|
||||
+10
-1
@@ -18,7 +18,7 @@ public class AdminVoteBungeeSettings extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteBungeeSettings(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -95,6 +95,15 @@ public class AdminVoteBungeeSettings extends GUIHandler {
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerMilestones", plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerPoints", plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public abstract class AdminVoteConfirmation extends GUIHandler {
|
||||
private String title;
|
||||
|
||||
public AdminVoteConfirmation(VotingPluginMain plugin, CommandSender player, String title) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@@ -22,13 +22,13 @@ public class AdminVotePerms extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page, String playerName) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
this.playerName = playerName;
|
||||
|
||||
+4
-4
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -19,11 +20,10 @@ import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVotePlaceholders(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
@@ -93,7 +93,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
|
||||
+8
-10
@@ -11,6 +11,7 @@ import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -20,12 +21,11 @@ import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public AdminVotePlaceholdersPlayer(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user.getOfflinePlayer(), user, identifier);
|
||||
String value = placeholder.placeholderRequest(user, identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
@@ -52,13 +52,13 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user.getOfflinePlayer(), user, identifier);
|
||||
String value = placeholder.placeholderRequest(identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -82,18 +82,16 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
msg.add("VotingPlugin_" + identifier + " = "
|
||||
+ placeholder.placeholderRequest(user.getOfflinePlayer(), placeholderUser, identifier));
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
|
||||
msg.add("VotingPlugin_" + identifier + " = "
|
||||
+ placeholder.placeholderRequest(user.getOfflinePlayer(), placeholderUser, identifier));
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVoteParty(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}, new Number[] { 0, 10, 50, 100 })
|
||||
.currentValue("" + plugin.getServerData().getVotePartyExtraRequired()).allowCustomOption(true)
|
||||
.request(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -16,11 +16,11 @@ import com.bencodez.votingplugin.objects.VoteSite;
|
||||
|
||||
public class AdminVoteVotePlayer extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVotePlayer(VotingPluginMain plugin, CommandSender player, String playerName) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class AdminVoteCumulative extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteCumulative(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class AdminVoteCumulative extends GUIHandler {
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
|
||||
.request(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ public class AdminVoteCumulativeRemove extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteCumulativeRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class AdminVoteCumulativeRemove extends GUIHandler {
|
||||
new AdminVoteCumulative(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteMilestoneRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
new AdminVoteMilestones(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+2
-2
@@ -26,7 +26,7 @@ public class AdminVoteMilestones extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteMilestones(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class AdminVoteMilestones extends GUIHandler {
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
|
||||
.request(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ public class AdminVoteVoteShop extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVoteShop(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVoteShopItem(VotingPluginMain plugin, CommandSender player, String identifier) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVoteShopItemRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
new AdminVoteVoteShop(plugin, p).open();
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@ public class AdminVoteVoteShopItems extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVoteShopItems(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AdminVoteVoteShopItems extends GUIHandler {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteShopItem(plugin, clickEvent.getPlayer(), (String) getData("ident"))
|
||||
.open(GUIMethod.CHEST);
|
||||
;
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
}
|
||||
|
||||
@@ -18,12 +18,11 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteBest extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteBest(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -88,6 +87,10 @@ public class VoteBest extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteBestBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public class VoteGUI extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteGUI(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -128,6 +128,12 @@ public class VoteGUI extends GUIHandler {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (player.getUniqueId().toString().equals(user.getUUID())) {
|
||||
inv.requirePermission("VotingPlugin.Commands.Vote.GUI");
|
||||
} else {
|
||||
inv.requirePermission("VotingPlugin.Commands.Vote.GUI.Other");
|
||||
}
|
||||
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
@@ -171,6 +177,10 @@ public class VoteGUI extends GUIHandler {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class VoteHelp extends GUIHandler {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public VoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ public class VoteLast extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteLast(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class VoteNext extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteNext(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -43,7 +43,6 @@ public class VoteNext extends GUIHandler {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
|
||||
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
|
||||
|
||||
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%info%",
|
||||
@@ -63,12 +62,14 @@ public class VoteNext extends GUIHandler {
|
||||
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
.onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build());
|
||||
book.addLayout(nextLayout);
|
||||
if (!site.isHidden()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
.onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build());
|
||||
book.addLayout(nextLayout);
|
||||
}
|
||||
}
|
||||
book.addLine();
|
||||
|
||||
@@ -85,20 +86,24 @@ public class VoteNext extends GUIHandler {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandNextInfo(site))
|
||||
.setAmountNone(1).addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1)
|
||||
.addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteNextBackButton()) {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class VoteShop extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteShop(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -51,7 +51,11 @@ public class VoteShop extends GUIHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
@@ -68,7 +72,6 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
@@ -85,10 +88,8 @@ public class VoteShop extends GUIHandler {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (plugin.getConfigFile().isClearCacheOnVoteShopPurchase()
|
||||
|| plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
user.clearCache();
|
||||
}
|
||||
user.clearCache();
|
||||
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
@@ -113,6 +114,8 @@ public class VoteShop extends GUIHandler {
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/"
|
||||
+ user.getUUID() + " bought " + identifier + " for " + points);
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
@@ -131,7 +134,7 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
} else {
|
||||
new VoteShopConfirm(plugin, player, user, identifier).open(GUIMethod.CHEST);
|
||||
;
|
||||
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
|
||||
@@ -26,7 +26,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteShopConfirm(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, String identifier) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.identifier = identifier;
|
||||
@@ -49,10 +49,12 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
|
||||
inv.dontClose();
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.clearCache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
@@ -60,6 +62,8 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought "
|
||||
+ identifier + " for " + points);
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
@@ -77,7 +81,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user);
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -89,7 +93,7 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user);
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ public class VoteStreak extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteStreak(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,10 +18,10 @@ 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.user.UUID;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -31,7 +32,7 @@ public class VoteToday extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteToday(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int page) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.page = page;
|
||||
@@ -84,7 +85,7 @@ public class VoteToday extends GUIHandler {
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
for (VotingPluginUser user : plugin.getVoteToday().keySet()) {
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
@@ -103,12 +104,12 @@ public class VoteToday extends GUIHandler {
|
||||
item.setName(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
|
||||
"player", user.getPlayerName()));
|
||||
item.setLore(msg);
|
||||
final String uuid = user.getUUID();
|
||||
final UUID uuid = user.getUuid();
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
new VoteGUI(plugin, player, user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
@@ -129,7 +130,7 @@ public class VoteToday extends GUIHandler {
|
||||
|
||||
public String[] voteToday() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
for (VotingPluginUser user : plugin.getVoteToday().keySet()) {
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
@@ -150,7 +151,7 @@ public class VoteToday extends GUIHandler {
|
||||
|
||||
public String[] voteTodayGUI() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
for (VotingPluginUser user : plugin.getVoteToday().keySet()) {
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
LocalDateTime mostRecent = null;
|
||||
VoteSite mostRecentSite = null;
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTopVoter extends GUIHandler {
|
||||
@@ -29,7 +30,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTopVoter(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, TopVoter top, int page) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.top = top;
|
||||
@@ -69,11 +70,11 @@ public class VoteTopVoter extends GUIHandler {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
Set<Entry<VotingPluginUser, Integer>> users = null;
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
|
||||
String topVoter = top.getName();
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<VotingPluginUser, Integer> topVotes = (LinkedHashMap<VotingPluginUser, Integer>) plugin
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topVotes = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(top).clone();
|
||||
users = topVotes.entrySet();
|
||||
|
||||
@@ -84,7 +85,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : users) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
@@ -103,8 +104,8 @@ public class VoteTopVoter extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (plugin.getGui().getChestVoteTopOpenMainGUIOnClick()) {
|
||||
VotingPluginUser user = (VotingPluginUser) getData("User");
|
||||
new VoteGUI(plugin, player, user)
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
} else {
|
||||
getInv().forceClose(clickEvent.getPlayer());
|
||||
|
||||
+6
-5
@@ -15,6 +15,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.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
@@ -23,7 +24,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTopVoterLastMonth(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -44,7 +45,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
Set<Entry<VotingPluginUser, Integer>> users = null;
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
|
||||
users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
@@ -55,7 +56,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : users) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
@@ -73,8 +74,8 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = (VotingPluginUser) getData("User");
|
||||
new VoteGUI(plugin, player, user)
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
|
||||
@@ -19,12 +19,11 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTotal extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTotal(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class VoteURL extends GUIHandler {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteURL(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, boolean json) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.json = json;
|
||||
@@ -165,7 +165,7 @@ public class VoteURL extends GUIHandler {
|
||||
if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builderAll, 1000, 1000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(builderAll, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -190,7 +190,7 @@ public class VoteURL extends GUIHandler {
|
||||
startSlot++;
|
||||
}
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 1000, 1000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -223,7 +223,7 @@ public class VoteURL extends GUIHandler {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(), "CHEST.VoteURL.ExtraItems." + str + ".Rewards")
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class VoteURLVoteSite extends GUIHandler {
|
||||
private String voteSite;
|
||||
|
||||
public VoteURLVoteSite(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, String voteSite) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
@@ -51,7 +51,7 @@ public class VoteURLVoteSite extends GUIHandler {
|
||||
player.sendMessage("Not a valid votesite");
|
||||
return;
|
||||
}
|
||||
VoteSite site = plugin.getVoteSite(voteSite);
|
||||
VoteSite site = plugin.getVoteSite(voteSite, true);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLSiteName());
|
||||
inv.addPlaceholder("site", site.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", site);
|
||||
|
||||
@@ -41,6 +41,10 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private boolean perServerPoints = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerMilestones")
|
||||
@Getter
|
||||
private boolean perServerMilestones = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerRewards")
|
||||
@Getter
|
||||
private boolean perServerRewards = false;
|
||||
@@ -52,10 +56,6 @@ public class BungeeSettings extends YMLFile {
|
||||
@ConfigDataString(path = "Server")
|
||||
@Getter
|
||||
private String server = "PleaseSet";
|
||||
|
||||
public String getServerNameStorage() {
|
||||
return getServer().replace("-", "_");
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "SpigotServer.Host")
|
||||
@Getter
|
||||
@@ -77,10 +77,18 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private boolean votifierBypass = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableBroadcast")
|
||||
@Getter
|
||||
private boolean disableBroadcast = false;
|
||||
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
}
|
||||
|
||||
public String getServerNameStorage() {
|
||||
return getServer().replace("-", "_");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
|
||||
@@ -37,18 +37,22 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PreloadSkulls")
|
||||
@Getter
|
||||
private boolean preloadSkulls = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
@ConfigDataInt(path = "PlayerDataLoadLimit")
|
||||
@Getter
|
||||
private int playerDataLoadLimit = -1;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlterColumns")
|
||||
@Getter
|
||||
private boolean alterColumns = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AlternateUUIDLookup")
|
||||
@Getter
|
||||
private boolean alternateUUIDLookup = false;
|
||||
@@ -73,26 +77,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean broadcastVotesEnabled = true;
|
||||
|
||||
@ConfigDataBoolean(path = "clearCacheOnUpdate")
|
||||
@Getter
|
||||
private boolean clearCacheOnUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ClearCacheOnVote")
|
||||
@Getter
|
||||
private boolean clearCacheOnVote = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ClearCacheOnVoteShopPurchase")
|
||||
@Getter
|
||||
private boolean clearCacheOnVoteShopPurchase = true;
|
||||
|
||||
@ConfigDataInt(path = "ConvertAmount")
|
||||
@Getter
|
||||
private int convertAmount = 150;
|
||||
|
||||
@ConfigDataInt(path = "ConvertDelay", defaultValue = 30000)
|
||||
@Getter
|
||||
private int convertDelay;
|
||||
|
||||
@ConfigDataBoolean(path = "CountFakeVotes")
|
||||
@Getter
|
||||
private boolean countFakeVotes = true;
|
||||
@@ -121,6 +105,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<String>();
|
||||
|
||||
@ConfigDataListString(path = "CachedPlaceholders")
|
||||
@Getter
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
|
||||
@ConfigDataBoolean(path = "DisableInteractEvent")
|
||||
@Getter
|
||||
private boolean disableInteractEvent = false;
|
||||
@@ -137,6 +125,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean extraAllSitesCheck = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CloseInventoryOnVote")
|
||||
@Getter
|
||||
private boolean closeInventoryOnVote = true;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraBackgroundUpdate")
|
||||
@Getter
|
||||
private boolean extraBackgroundUpdate = false;
|
||||
@@ -190,6 +182,14 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastEnabled = "&cYou will now see vote broadcasts";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleReminders.Disabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleRemindersDisabled = "&cVote reminders disabled";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleReminders.Enabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleRemindersEnabled = "&cVote reminders enabled";
|
||||
|
||||
@Getter
|
||||
private int formatPageSize = 10;
|
||||
|
||||
@@ -239,7 +239,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataInt(path = "MaxiumNumberOfTopVotersToLoad")
|
||||
@Getter
|
||||
private int MaxiumNumberOfTopVotersToLoad = -1;
|
||||
private int MaxiumNumberOfTopVotersToLoad = 1000;
|
||||
|
||||
@ConfigDataBoolean(path = "OverrideVersionDisable")
|
||||
@Getter
|
||||
@@ -341,6 +341,10 @@ public class Config extends YMLFile {
|
||||
return getData().getString("Format.Commands.Vote.Best.Title", "&3&l%player% Best Votes");
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteHelpHoverColor() {
|
||||
return getData().getString("Format.Commands.Vote.Help.HoverColor", "AQUA");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help line.
|
||||
*
|
||||
@@ -349,10 +353,6 @@ public class Config extends YMLFile {
|
||||
public String getFormatCommandsVoteHelpLine() {
|
||||
return getData().getString("Format.Commands.Vote.Help.Line", "&6%Command% - &6%HelpMessage%");
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteHelpHoverColor() {
|
||||
return getData().getString("Format.Commands.Vote.Help.HoverColor", "AQUA");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help require permission.
|
||||
|
||||
@@ -41,8 +41,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName
|
||||
+ " does not exist, creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
plugin.getLogger().warning("VoteSite " + siteName + " does not exist with the servicesite '" + org
|
||||
+ "', creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
setEnabled(siteName, true);
|
||||
setServiceSite(siteName, org);
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
@@ -192,7 +192,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
*/
|
||||
public ArrayList<VoteSite> getVoteSitesLoad() {
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames(true);
|
||||
if (voteSiteNames != null) {
|
||||
for (String site : voteSiteNames) {
|
||||
if (getVoteSiteEnabled(site) && !site.equalsIgnoreCase("null")) {
|
||||
@@ -225,12 +225,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote sites names.
|
||||
*
|
||||
* @return the vote sites names
|
||||
*/
|
||||
public ArrayList<String> getVoteSitesNames() {
|
||||
public ArrayList<String> getVoteSitesNames(boolean checkEnabled) {
|
||||
ArrayList<String> siteNames = new ArrayList<String>();
|
||||
if (getData().isConfigurationSection("VoteSites")) {
|
||||
siteNames = ArrayUtils.getInstance().convert(getData().getConfigurationSection("VoteSites").getKeys(false));
|
||||
@@ -242,8 +237,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
plugin.getLogger()
|
||||
.warning("VoteSites." + siteNames.get(i) + " is not a configuration section, please remove");
|
||||
siteNames.remove(i);
|
||||
} else if (siteNames.get(i).equalsIgnoreCase("null") || !getVoteSiteEnabled(siteNames.get(i))
|
||||
|| !siteCheck(siteNames.get(i))) {
|
||||
} else if (siteNames.get(i).equalsIgnoreCase("null")
|
||||
|| (!getVoteSiteEnabled(siteNames.get(i)) && checkEnabled) || !siteCheck(siteNames.get(i))) {
|
||||
// plugin.getLogger().info("Removed: " + siteNames.get(i));
|
||||
siteNames.remove(i);
|
||||
}
|
||||
|
||||
@@ -74,6 +74,10 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private boolean chestVoteShopRequireConfirmation = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteBest.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteBestBackButton = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteToday.IconTitle")
|
||||
@Getter
|
||||
private String chestVoteTodayIconTitle = "%player%";
|
||||
|
||||
@@ -34,9 +34,13 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private boolean enableWeeklyAwards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "OnlyOneCumulative")
|
||||
@Getter
|
||||
private boolean onlyOneCumulative = false;
|
||||
|
||||
@Getter
|
||||
private String firstVoteRewardsPath = "FirstVote";
|
||||
|
||||
|
||||
@Getter
|
||||
private String firstVoteTodayRewardsPath = "FirstVoteToday";
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package com.bencodez.votingplugin.cooldown;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -8,79 +12,105 @@ import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteReminding.
|
||||
*/
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
private Set<UUID> uuids = new HashSet<UUID>();
|
||||
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = new Timer();
|
||||
}
|
||||
|
||||
public void checkAll() {
|
||||
private Timer timer;
|
||||
|
||||
private boolean cooldownCheckEnabled = false;
|
||||
|
||||
public void checkEnabled() {
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && RewardHandler.getInstance()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
|
||||
plugin.getTimer().schedule(new TimerTask() {
|
||||
cooldownCheckEnabled = true;
|
||||
} else {
|
||||
cooldownCheckEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void check(UUID uuid) {
|
||||
check(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user) {
|
||||
if (cooldownCheckEnabled) {
|
||||
UUID uuid = UUID.fromString(user.getUUID());
|
||||
if (!uuids.contains(uuid)) {
|
||||
schedule(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void check(VotingPluginUser user) {
|
||||
boolean coolDownCheck = user.getCoolDownCheck();
|
||||
if (user.canVoteAll() && coolDownCheck) {
|
||||
user.setCoolDownCheck(false);
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
uuids.remove(UUID.fromString(user.getUUID()));
|
||||
} else if (!coolDownCheck) {
|
||||
schedule(user);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void schedule(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
uuids.add(uuid);
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (VotingPluginMain.plugin != null) {
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && RewardHandler.getInstance()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
if (VotingPluginMain.plugin != null) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getUserData().hasData() && user.hasLoggedOnBefore()) {
|
||||
user.checkCoolDownEvents();
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Not enabling cooldown check reward");
|
||||
cancel();
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
check(uuid);
|
||||
}
|
||||
}, 1000 * 60 * 5, 1000 * 60 * 30);
|
||||
} else {
|
||||
plugin.debug("Not enabling cooldown check reward");
|
||||
}, time * 1000 + 1500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
checkAll();
|
||||
if (cooldownCheckEnabled) {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
check(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
RewardHandler.getInstance().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward",
|
||||
new RewardOptions().addPlaceholder("Votesite", event.getVoteSite().getDisplayName()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChangeEnd(DateChangedEvent event) {
|
||||
checkAll();
|
||||
"VoteCoolDownEndedReward", new RewardOptions());
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.bencodez.votingplugin.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -24,6 +25,23 @@ public class ServerData {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addAutoCachedPlaceholder(String placeholder) {
|
||||
List<String> p = getAutoCachedPlaceholder();
|
||||
if (!p.contains(placeholder)) {
|
||||
p.add(placeholder);
|
||||
setAutoCachedPlaceholder(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public List<String> getAutoCachedPlaceholder() {
|
||||
return getData().getStringList("AutoCachePlaceholders");
|
||||
}
|
||||
|
||||
public synchronized void addServiceSite(String site) {
|
||||
ArrayList<String> l = getServiceSites();
|
||||
if (!getServiceSites().contains(site)) {
|
||||
@@ -246,6 +264,24 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyRequired() {
|
||||
return getData().getInt("BungeeVotePartyRequired");
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyCurrent(int current) {
|
||||
getData().set("BungeeVotePartyCurrent", current);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyRequired(int required) {
|
||||
getData().set("BungeeVotePartyRequired", required);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin.events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -35,14 +34,9 @@ public class PlayerVoteCoolDownEndEvent extends Event {
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
public PlayerVoteCoolDownEndEvent(VotingPluginUser user, VoteSite site) {
|
||||
public PlayerVoteCoolDownEndEvent(VotingPluginUser user) {
|
||||
super(true);
|
||||
player = user;
|
||||
voteSite = site;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -76,6 +76,10 @@ public class PlayerVoteEvent extends Event {
|
||||
@Setter
|
||||
private boolean wasOnline;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean broadcast = true;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
this.player = voteUsername;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bencodez.votingplugin.events;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, MILESTONE, VOTESTREAK, FIRSTVOTETODAY;
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
@@ -8,8 +10,14 @@ import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
public class BungeeVotifierEvent {
|
||||
public void send(VotingPluginMain plugin, PlayerVoteEvent event) {
|
||||
plugin.debug("Triggering vote event");
|
||||
VotifierEvent e = new VotifierEvent(
|
||||
new Vote(event.getServiceSite(), event.getPlayer(), "VotingPlugin", "" + event.getTime()));
|
||||
plugin.getServer().getPluginManager().callEvent(e);
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotifierEvent e = new VotifierEvent(
|
||||
new Vote(event.getServiceSite(), event.getPlayer(), "VotingPlugin", "" + event.getTime()));
|
||||
plugin.getServer().getPluginManager().callEvent(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -72,6 +72,10 @@ public class PlayerVoteListener implements Listener {
|
||||
|
||||
VoteSite voteSite = event.getVoteSite();
|
||||
|
||||
if (voteSite == null) {
|
||||
voteSite = plugin.getVoteSite(plugin.getVoteSiteName(true, event.getServiceSite()), true);
|
||||
}
|
||||
|
||||
// check valid service sites
|
||||
if (voteSite == null) {
|
||||
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
@@ -87,17 +91,17 @@ public class PlayerVoteListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!voteSite.isEnabled()) {
|
||||
plugin.debug("Votesite: " + voteSite.getKey() + " is not enabled");
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser user = null;
|
||||
if (event.getVotingPluginUser() != null) {
|
||||
user = event.getVotingPluginUser();
|
||||
} else {
|
||||
user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
}
|
||||
user.updateName(true);
|
||||
|
||||
if (plugin.getConfigFile().isClearCacheOnVote() || plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
user.clearCache();
|
||||
}
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
@@ -105,15 +109,22 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
// reupdate cache
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
user.updateName(true);
|
||||
|
||||
// vote party
|
||||
plugin.getVoteParty().vote(user, event.isRealVote(), event.isForceBungee());
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& (plugin.getBungeeSettings().isBungeeBroadcast() || !event.isBungee())) {
|
||||
if (!plugin.getConfigFile().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
if (event.isBroadcast() && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
// broadcast vote if enabled in config
|
||||
if (plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& (plugin.getBungeeSettings().isBungeeBroadcast() || !event.isBungee())) {
|
||||
if (!plugin.getConfigFile().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,7 +138,7 @@ public class PlayerVoteListener implements Listener {
|
||||
} else {
|
||||
user.setTime(voteSite);
|
||||
}
|
||||
user.setLastVoteCoolDownCheck(false, voteSite);
|
||||
plugin.getCoolDownCheck().vote(user);
|
||||
|
||||
// try logging to file
|
||||
if (plugin.getConfigFile().isLogVotesToFile()) {
|
||||
@@ -144,7 +155,7 @@ public class PlayerVoteListener implements Listener {
|
||||
plugin.getSpecialRewards().checkFirstVote(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkFirstVoteToday(user, event.isForceBungee());
|
||||
|
||||
if (user.isReminded()) {
|
||||
if (user.isReminded() && plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
@@ -158,7 +169,9 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
user.playerVote(voteSite, online, false, event.isForceBungee());
|
||||
user.sendVoteEffects(online);
|
||||
user.closeInv();
|
||||
if (plugin.getConfigFile().isCloseInventoryOnVote()) {
|
||||
user.closeInv();
|
||||
}
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
plugin.debug(
|
||||
@@ -190,13 +203,15 @@ public class PlayerVoteListener implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(
|
||||
PlayerUtils.getInstance().getRandomOnlinePlayer(), "VoteUpdate", uuid);
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
}
|
||||
}
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
|
||||
@@ -41,20 +41,17 @@ public class VotiferEvent implements Listener {
|
||||
public void onVotiferEvent(VotifierEvent event) {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
final String voteSite = vote.getServiceName();
|
||||
String str = vote.getServiceName();
|
||||
if (str.isEmpty()) {
|
||||
str = "Empty";
|
||||
}
|
||||
final String voteSite = str;
|
||||
final String IP = vote.getAddress();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
if (IP.equals("VotingPlugin")) {
|
||||
// ignore own plugin calls of event
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServerData().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
@@ -72,20 +69,20 @@ public class VotiferEvent implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
plugin.getServerData().addServiceSite(voteSite);
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getBungeeSettings().isVotifierBypass()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
|
||||
plugin.getLogger().severe(
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled");
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
|
||||
return;
|
||||
}
|
||||
String voteSiteName = plugin.getVoteSiteName(voteSite);
|
||||
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite);
|
||||
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames();
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
|
||||
boolean createSite = false;
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteName)) {
|
||||
if (!sites.contains(voteSiteNameStr)) {
|
||||
createSite = true;
|
||||
}
|
||||
} else {
|
||||
@@ -93,15 +90,17 @@ public class VotiferEvent implements Listener {
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
|
||||
plugin.getLogger().warning("VoteSite with service site '" + voteSiteName
|
||||
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr
|
||||
+ "' does not exist, attempting to generaterate...");
|
||||
plugin.getConfigVoteSites().generateVoteSite(voteSiteName);
|
||||
plugin.getConfigVoteSites().generateVoteSite(voteSiteNameStr);
|
||||
|
||||
plugin.getLogger().info("Current known service sites: "
|
||||
+ ArrayUtils.getInstance().makeStringList(plugin.getServerData().getServiceSites()));
|
||||
}
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName), voteUsername,
|
||||
String voteSiteName = plugin.getVoteSiteName(true, voteSite);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName, true), voteUsername,
|
||||
voteSite, true);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
@@ -119,8 +118,7 @@ public class VoteSite {
|
||||
String service = getServiceSite();
|
||||
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(PlayerUtils.getInstance().getRandomOnlinePlayer(),
|
||||
"VoteBroadcast", uuid, service);
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteBroadcast", uuid, service);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.bencodez.votingplugin.placeholders;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -46,7 +47,7 @@ public class MVdWPlaceholders {
|
||||
&& user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
return place.placeholderRequest(event.getOfflinePlayer(), user,
|
||||
return place.placeholderRequest(user,
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
}
|
||||
|
||||
@@ -55,7 +56,7 @@ public class MVdWPlaceholders {
|
||||
|
||||
}
|
||||
|
||||
for (final PlaceHolder<VotingPluginUser> place : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
for (final NonPlayerPlaceHolder<VotingPluginUser> place : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String str = place.getIdentifier();
|
||||
if (!str.endsWith("_")) {
|
||||
PlaceholderAPI.registerPlaceholder(VotingPluginMain.plugin, "VotingPlugin_" + str,
|
||||
@@ -63,7 +64,7 @@ public class MVdWPlaceholders {
|
||||
|
||||
@Override
|
||||
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
|
||||
return place.placeholderRequest(event.getOfflinePlayer(), null,
|
||||
return place.placeholderRequest(
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
}
|
||||
|
||||
|
||||
@@ -5,18 +5,27 @@ import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserDataChanged;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -29,7 +38,7 @@ import lombok.Getter;
|
||||
public class PlaceHolders {
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<PlaceHolder<VotingPluginUser>>();
|
||||
private ArrayList<NonPlayerPlaceHolder<VotingPluginUser>> nonPlayerPlaceholders = new ArrayList<NonPlayerPlaceHolder<VotingPluginUser>>();
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder<VotingPluginUser>> placeholders = new ArrayList<PlaceHolder<VotingPluginUser>>();
|
||||
@@ -40,33 +49,55 @@ public class PlaceHolders {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
|
||||
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
|
||||
return getPlaceHolder(p, identifier, true);
|
||||
}
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier, boolean javascript) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, null, identifier);
|
||||
return placeholder.placeholderRequest(identifier);
|
||||
}
|
||||
}
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
|
||||
user.setWaitForCache(false);
|
||||
if (!user.isCached()) {
|
||||
user.loadCache();
|
||||
return "";
|
||||
if (!cachedPlaceholders.contains(identifier)) {
|
||||
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
|
||||
user.setWaitForCache(false);
|
||||
if (!user.isCached()) {
|
||||
user.loadCache();
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()) {
|
||||
if (user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
try {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, user, identifier);
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
} else {
|
||||
return "....";
|
||||
}
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.debug(e);
|
||||
@@ -81,7 +112,7 @@ public class PlaceHolders {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
return getPlaceHolder(p, identifier, false);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -92,54 +123,54 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("total") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getTotal(TopVoter.Monthly));
|
||||
}
|
||||
}.withDescription("Month total"));
|
||||
}.withDescription("Month total").updateDataKey("MonthTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("alltimetotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getTotal(TopVoter.AllTime));
|
||||
}
|
||||
}.withDescription("Alltime total"));
|
||||
}.withDescription("Alltime total").updateDataKey("AllTimeTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("lastmonthtotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getLastMonthTotal());
|
||||
}
|
||||
}.withDescription("Last month total"));
|
||||
}.withDescription("Last month total").updateDataKey("LastMonthTotal"));
|
||||
|
||||
// end of older placeholders
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("DisableBroadcast") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getDisableBroadcast();
|
||||
}
|
||||
}.withDescription("Returns true/false if user has broadcast disabled"));
|
||||
}.withDescription("Returns true/false if user has broadcast disabled").updateDataKey("DisableBroadcast"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("MilestoneCount") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getMilestoneCount();
|
||||
}
|
||||
}.withDescription("User milestonecount"));
|
||||
}.withDescription("User milestonecount").updateDataKey("MilestoneCount"));
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestShopIdentifierLimit(identifier) > 0) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String ident) {
|
||||
public String placeholderRequest(VotingPluginUser user, String ident) {
|
||||
return "" + user.getVoteShopIdentifierLimit(identifier);
|
||||
}
|
||||
}.withDescription("User voteshop limit for " + identifier));
|
||||
}.withDescription("User voteshop limit for " + identifier).updateDataKey("VoteShopLimit" + identifier));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,113 +178,121 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Total_" + top.toString()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getTotal(top));
|
||||
}
|
||||
}.withDescription("User total for " + top.getName()));
|
||||
}.withDescription("User total for " + top.getName()).updateDataKey(top.getColumnName()));
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestDailyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getHighestDailyTotal());
|
||||
}
|
||||
}.withDescription("Best daily total"));
|
||||
}.withDescription("Best daily total").updateDataKey("HighestDailyTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestWeeklyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getHighestWeeklyTotal());
|
||||
}
|
||||
}.withDescription("Best weekly total"));
|
||||
}.withDescription("Best weekly total").updateDataKey("HighestWeeklyTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestMonthlyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getHighestMonthlyTotal());
|
||||
}
|
||||
}.withDescription("Best monthly total"));
|
||||
}.withDescription("Best monthly total").updateDataKey("HighestMonthlyTotal"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("DailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getDayVoteStreak());
|
||||
}
|
||||
}.withDescription("Current daily votestreak"));
|
||||
}.withDescription("Current daily votestreak").updateDataKey("DayVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("WeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getWeekVoteStreak());
|
||||
}
|
||||
}.withDescription("Current weekly votestreak"));
|
||||
}.withDescription("Current weekly votestreak").updateDataKey("WeekVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("MonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getMonthVoteStreak());
|
||||
}
|
||||
}.withDescription("Current month votestreak"));
|
||||
}.withDescription("Current month votestreak").updateDataKey("MonthVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestDailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getBestDayVoteStreak());
|
||||
}
|
||||
}.withDescription("Best daily votestreak"));
|
||||
}.withDescription("Best daily votestreak").updateDataKey("BestDayVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestWeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getBestWeekVoteStreak());
|
||||
}
|
||||
}.withDescription("Best weekly votestreak"));
|
||||
}.withDescription("Best weekly votestreak").updateDataKey("BestWeekVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("BestMonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getBestMonthVoteStreak());
|
||||
}
|
||||
}.withDescription("Best month votestreak"));
|
||||
}.withDescription("Best month votestreak").updateDataKey("BestMonthVoteStreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Points") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
}.withDescription("User points"));
|
||||
}.withDescription("User points").updateDataKey("Points"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Points_Format") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||
return numberFormat.format(user.getPoints());
|
||||
}
|
||||
}.withDescription("User points"));
|
||||
}.withDescription("User points").updateDataKey("Points"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVote") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return Boolean.toString(user.canVoteAll());
|
||||
}
|
||||
}.withDescription("Return true/false if player can vote on all sites"));
|
||||
}.withDescription("Return true/false if player can vote on all sites").updateDataKey("LastVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVoteSites") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getSitesNotVotedOn();
|
||||
}
|
||||
}.withDescription("Return number of votesites available").updateDataKey("LastVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_AnySite") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
if (user.canVoteAny()) {
|
||||
return plugin.getConfigFile().getFormatCommandsVoteNextInfoCanVote();
|
||||
}
|
||||
@@ -277,39 +316,40 @@ public class PlaceHolders {
|
||||
|
||||
return "Error";
|
||||
}
|
||||
}.withDescription("How long until user can vote on anysite"));
|
||||
}.withDescription("How long until user can vote on anysite").updateDataKey("LastVotes"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return user.voteCommandNextInfo(voteSite);
|
||||
}
|
||||
}.withDescription("How long until user can vote on " + voteSite.getKey()));
|
||||
}.withDescription("How long until user can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Last_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return user.voteCommandLastDuration(voteSite);
|
||||
}
|
||||
}.withDescription("How long ago user voted on " + voteSite.getKey()));
|
||||
}.withDescription("How long ago user voted on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVote_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.canVoteSite(voteSite);
|
||||
}
|
||||
}.withDescription("Whether or not player can vote on " + voteSite.getKey()));
|
||||
}.withDescription("Whether or not player can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_All_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -318,15 +358,15 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_AllVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_AllVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.AllTime);
|
||||
return "" + entry.getValue().intValue();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
@@ -334,13 +374,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_All_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_All_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
@@ -353,10 +393,11 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Month_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -365,13 +406,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Month_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Month_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
@@ -381,15 +422,15 @@ public class PlaceHolders {
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_MonthVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_MonthVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.Monthly);
|
||||
return "" + entry.getValue().intValue();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
@@ -400,10 +441,11 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Week_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -412,13 +454,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Week_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Week_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
@@ -428,15 +470,15 @@ public class PlaceHolders {
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_WeekVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_WeekVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.Weekly);
|
||||
return "" + entry.getValue().intValue();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
@@ -447,10 +489,11 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Daily_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
UUID toMatch = UUID.fromString(user.getUUID());
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(toMatch)) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -459,13 +502,13 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_Daily_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_Daily_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
@@ -478,20 +521,20 @@ public class PlaceHolders {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VotePartyContributedVotes") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getVotePartyVotes();
|
||||
}
|
||||
}.useStartsWith().withDescription("See vote party placeholders contributed"));
|
||||
}.useStartsWith().withDescription("See vote party placeholders contributed").updateDataKey("VotePartyVotes"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Top_DailyVotes_") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_DailyVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.Daily);
|
||||
return "" + entry.getValue().intValue();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
@@ -501,34 +544,68 @@ public class PlaceHolders {
|
||||
|
||||
// non players
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("VotePartyVotesCurrent") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("VotePartyVotesCurrent") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
return Integer.toString(plugin.getVoteParty().getTotalVotes());
|
||||
}
|
||||
}.withDescription("Current amount of voteparty votes"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("VotePartyVotesNeeded") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("VotePartyVotesNeeded") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
return Integer.toString(plugin.getVoteParty().getNeededVotes());
|
||||
}
|
||||
}.withDescription("Voteparty votes needed"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("VotePartyVotesRequired") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("VotePartyVotesRequired") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
return Integer.toString(plugin.getVoteParty().getVotesRequired());
|
||||
}
|
||||
}.withDescription("Amount of votes needed for voteparty"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalMonthTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("BungeeVotePartyVotesCurrent") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyCurrent());
|
||||
}
|
||||
return "" + 0;
|
||||
}
|
||||
}.withDescription("Current amount of bungee voteparty votes"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("BungeeVotePartyVotesNeeded") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired()
|
||||
- plugin.getBungeeHandler().getBungeeVotePartyCurrent());
|
||||
}
|
||||
return "" + 0;
|
||||
}
|
||||
}.withDescription("Voteparty bungee votes needed"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("BungeeVotePartyVotesRequired") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired());
|
||||
}
|
||||
return "" + 0;
|
||||
}
|
||||
}.withDescription("Amount of votes needed for bungee voteparty"));
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalMonthTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.Monthly).values()) {
|
||||
total += num;
|
||||
@@ -537,10 +614,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global month total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalAllTimeTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalAllTimeTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.AllTime).values()) {
|
||||
total += num;
|
||||
@@ -549,10 +626,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global alltime total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalWeeklyTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalWeeklyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.Weekly).values()) {
|
||||
total += num;
|
||||
@@ -561,10 +638,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global weekly total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("GlobalDailyTotal") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("GlobalDailyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
int total = 0;
|
||||
for (int num : VotingPluginMain.plugin.getTopVoter(TopVoter.Daily).values()) {
|
||||
total += num;
|
||||
@@ -573,10 +650,10 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Global daily total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("TimeUntilDayReset") {
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("TimeUntilDayReset") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
public String placeholderRequest(String identifier) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0);
|
||||
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0)
|
||||
@@ -610,5 +687,153 @@ public class PlaceHolders {
|
||||
|
||||
}
|
||||
}.withDescription("Time until plugin time day changes"));
|
||||
|
||||
Set<String> placeholdersSet = new HashSet<String>();
|
||||
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
|
||||
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
|
||||
|
||||
for (String toCache : placeholdersSet) {
|
||||
if (toCache.startsWith("VotingPlugin")) {
|
||||
toCache = toCache.substring("VotingPlugin_".length());
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getUserManager().getUserDataChange().add(new UserDataChanged() {
|
||||
|
||||
@Override
|
||||
public void onChange(AdvancedCoreUser user, String... keys) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String key : keys) {
|
||||
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
|
||||
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(),
|
||||
placeholder.placeholderRequest(vpUser, ident));
|
||||
plugin.devDebug("Updated cache for " + vpUser.getUUID() + " on " + key);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onVotePartyUpdate() {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("VoteParty")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onBungeeVotePartyUpdate() {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("BungeeVoteParty")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate(VotingPluginUser user) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (!placeholder.getIdentifier().startsWith("Top_") || placeholder.getCache().isEmpty()
|
||||
|| placeholder.getUpdateDataKey().isEmpty()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll();
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
}
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String uuid : uuids) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("Top_")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -79,9 +79,11 @@ public class SignHandler {
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean checkSkull(Block block) {
|
||||
if (block.getState() instanceof Skull) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
if (!playerName.equals("No Player")) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -91,7 +93,7 @@ public class SignHandler {
|
||||
* Check skulls.
|
||||
*/
|
||||
public void checkSkulls() {
|
||||
if (playerName.equalsIgnoreCase("No Player") || playerName.equals("")) {
|
||||
if (noNameAvailable()) {
|
||||
return;
|
||||
}
|
||||
if (skullLocation != null) {
|
||||
@@ -151,6 +153,10 @@ public class SignHandler {
|
||||
return skullLocation != null;
|
||||
}
|
||||
|
||||
public boolean noNameAvailable() {
|
||||
return playerName.equalsIgnoreCase("No Player") || playerName.equals("");
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*/
|
||||
@@ -181,7 +187,7 @@ public class SignHandler {
|
||||
lines.add(line3);
|
||||
lines.add(line4);
|
||||
|
||||
ArrayList<VotingPluginUser> users = null;
|
||||
ArrayList<TopVoterPlayer> users = null;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.AllTime).keySet());
|
||||
} else if (data.equalsIgnoreCase("monthly")) {
|
||||
@@ -193,7 +199,7 @@ public class SignHandler {
|
||||
}
|
||||
|
||||
if (users != null && users.size() >= position) {
|
||||
VotingPluginUser user = users.get(position - 1);
|
||||
TopVoterPlayer user = users.get(position - 1);
|
||||
playerName = user.getPlayerName();
|
||||
|
||||
votes = 0;
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Signs {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Signs updated");
|
||||
plugin.debug(getSigns().size() + " Signs updated");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,10 +94,14 @@ public class SpecialRewards {
|
||||
}
|
||||
|
||||
if (gotCumulative) {
|
||||
gotCumulativeAny = true;
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired + ", total: "
|
||||
+ top.toString() + ", current total: " + total);
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired, forceBungee);
|
||||
if (!plugin.getSpecialRewardsConfig().isOnlyOneCumulative() || !gotCumulativeAny) {
|
||||
gotCumulativeAny = true;
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired + ", total: "
|
||||
+ top.toString() + ", current total: " + total);
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired, forceBungee);
|
||||
} else {
|
||||
plugin.debug("Already got one cumulative");
|
||||
}
|
||||
} else {
|
||||
plugin.devDebug(user.getPlayerName() + " not able to get cumulative " + votesRequired
|
||||
+ ", total required: " + top.toString() + ", current player total: " + total);
|
||||
@@ -187,6 +191,8 @@ public class SpecialRewards {
|
||||
plugin.debug(user.getPlayerName() + " got milestone " + votesRequired);
|
||||
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Milestone " + votesRequired + " not enabled or has no rewards");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -52,7 +52,7 @@ public class VoteTester {
|
||||
ArrayList<Long> timesPerVote = new ArrayList<Long>();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long start1 = System.currentTimeMillis();
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(site), name,
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(site, false), name,
|
||||
plugin.getVoteSiteServiceSite(site), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
long start2 = System.currentTimeMillis();
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public enum TopVoter {
|
||||
AllTime, Daily, Monthly, Weekly;
|
||||
AllTime, Monthly, Weekly, Daily;
|
||||
|
||||
public static TopVoter getDefault() {
|
||||
TopVoter top = getTopVoter(VotingPluginMain.plugin.getConfigFile().getVoteTopDefault());
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -24,8 +25,8 @@ import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
|
||||
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.UUID;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -51,7 +52,7 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
public String[] getTopVotersWeekly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<VotingPluginUser> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
|
||||
ArrayList<TopVoterPlayer> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine().replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
@@ -85,13 +86,13 @@ public class TopVoterHandler implements Listener {
|
||||
public void loadLastMonth() {
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
plugin.getLastMonthTopVoter().clear();
|
||||
|
||||
LinkedHashMap<VotingPluginUser, Integer> totals = new LinkedHashMap<VotingPluginUser, Integer>();
|
||||
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user, total);
|
||||
totals.put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,15 +111,20 @@ public class TopVoterHandler implements Listener {
|
||||
loadLastMonth();
|
||||
}
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
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) {
|
||||
@@ -132,11 +138,7 @@ public class TopVoterHandler implements Listener {
|
||||
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
|
||||
}
|
||||
}
|
||||
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestVoteShopResetDaily(shopIdent)) {
|
||||
user.setVoteShopIdentifierLimit(shopIdent, 0);
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().getStoreTopVotersDaily()) {
|
||||
@@ -151,12 +153,14 @@ public class TopVoterHandler implements Listener {
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<VotingPluginUser, Integer> clone = (LinkedHashMap<VotingPluginUser, Integer>) plugin
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Daily).clone();
|
||||
for (VotingPluginUser user : clone.keySet()) {
|
||||
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 (user.getTotal(TopVoter.Daily) != lastTotal) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
@@ -166,26 +170,42 @@ public class TopVoterHandler implements Listener {
|
||||
user.giveDailyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getTotal(TopVoter.Daily);
|
||||
lastTotal = entry.getValue().intValue();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestVoteShopResetDaily(shopIdent)) {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
|
||||
resetTotals(TopVoter.Daily);
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
plugin.getLogger().info("Saving TopVoters Monthly");
|
||||
storeTopVoters(TopVoter.Monthly);
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
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);
|
||||
@@ -201,12 +221,6 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestVoteShopResetMonthly(shopIdent)) {
|
||||
user.setVoteShopIdentifierLimit(shopIdent, 0);
|
||||
}
|
||||
}
|
||||
|
||||
user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
@@ -214,11 +228,9 @@ public class TopVoterHandler implements Listener {
|
||||
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Saving TopVoters Monthly");
|
||||
storeTopVoters(TopVoter.Monthly);
|
||||
|
||||
try {
|
||||
if (plugin.getSpecialRewardsConfig().isEnableMonthlyAwards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(
|
||||
@@ -227,13 +239,14 @@ public class TopVoterHandler implements Listener {
|
||||
int lastTotal = -1;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<VotingPluginUser, Integer> clone = (LinkedHashMap<VotingPluginUser, Integer>) plugin
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Monthly).clone();
|
||||
for (VotingPluginUser user : clone.keySet()) {
|
||||
|
||||
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 (user.getTotal(TopVoter.Monthly) != lastTotal) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
@@ -243,7 +256,7 @@ public class TopVoterHandler implements Listener {
|
||||
user.giveMonthlyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getTotal(TopVoter.Monthly);
|
||||
lastTotal = entry.getValue().intValue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -252,19 +265,23 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getResetMilestonesMonthly()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setMilestoneCount(0);
|
||||
user.setHasGottenMilestone(new HashMap<String, Boolean>());
|
||||
}
|
||||
|
||||
resetMilestoneCount();
|
||||
resetGottenMilestones();
|
||||
}
|
||||
|
||||
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestVoteShopResetMonthly(shopIdent)) {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
resetTotals(TopVoter.Monthly);
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,9 +293,13 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
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);
|
||||
@@ -293,17 +314,12 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestVoteShopResetWeekly(shopIdent)) {
|
||||
user.setVoteShopIdentifierLimit(shopIdent, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
|
||||
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().getStoreTopVotersWeekly()) {
|
||||
@@ -318,12 +334,14 @@ public class TopVoterHandler implements Listener {
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<VotingPluginUser, Integer> clone = (LinkedHashMap<VotingPluginUser, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Weekly).clone();
|
||||
for (VotingPluginUser user : clone.keySet()) {
|
||||
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 (user.getTotal(TopVoter.Weekly) != lastTotal) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
@@ -333,17 +351,27 @@ public class TopVoterHandler implements Listener {
|
||||
user.giveWeeklyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getTotal(TopVoter.Weekly);
|
||||
lastTotal = entry.getValue().intValue();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for (String shopIdent : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestVoteShopResetWeekly(shopIdent)) {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
resetTotals(TopVoter.Weekly);
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCache();
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -351,29 +379,31 @@ public class TopVoterHandler implements Listener {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void resetTotals(TopVoter topVoter) {
|
||||
if (!plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getTotal(topVoter) != 0) {
|
||||
user.resetTotals(topVoter);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.getMysql().wipeColumnData(topVoter.getColumnName());
|
||||
}
|
||||
public void resetMilestoneCount() {
|
||||
plugin.getUserManager().removeAllKeyValues("MilestoneCount", DataType.INTEGER);
|
||||
}
|
||||
|
||||
public LinkedHashMap<VotingPluginUser, Integer> sortByValues(
|
||||
LinkedHashMap<VotingPluginUser, Integer> topVoterAllTime, final boolean order) {
|
||||
public void resetGottenMilestones() {
|
||||
plugin.getUserManager().removeAllKeyValues("GottenMileStones", DataType.STRING);
|
||||
}
|
||||
|
||||
List<Entry<VotingPluginUser, Integer>> list = new LinkedList<Entry<VotingPluginUser, Integer>>(
|
||||
topVoterAllTime.entrySet());
|
||||
public void resetVoteShopLimit(String shopIdent) {
|
||||
plugin.getUserManager().removeAllKeyValues("VoteShopLimit" + shopIdent, DataType.INTEGER);
|
||||
}
|
||||
|
||||
public void resetTotals(TopVoter topVoter) {
|
||||
plugin.getUserManager().removeAllKeyValues(topVoter.getColumnName(), DataType.INTEGER);
|
||||
}
|
||||
|
||||
public LinkedHashMap<TopVoterPlayer, Integer> sortByValues(LinkedHashMap<TopVoterPlayer, Integer> map,
|
||||
final boolean order) {
|
||||
|
||||
List<Entry<TopVoterPlayer, Integer>> list = new LinkedList<Entry<TopVoterPlayer, Integer>>(map.entrySet());
|
||||
|
||||
// Sorting the list based on values
|
||||
Collections.sort(list, new Comparator<Entry<VotingPluginUser, Integer>>() {
|
||||
Collections.sort(list, new Comparator<Entry<TopVoterPlayer, Integer>>() {
|
||||
@Override
|
||||
public int compare(Entry<VotingPluginUser, Integer> o1, Entry<VotingPluginUser, Integer> o2) {
|
||||
public int compare(Entry<TopVoterPlayer, Integer> o1, Entry<TopVoterPlayer, Integer> o2) {
|
||||
if (order) {
|
||||
return o1.getValue().compareTo(o2.getValue());
|
||||
} else {
|
||||
@@ -384,8 +414,8 @@ public class TopVoterHandler implements Listener {
|
||||
});
|
||||
|
||||
// Maintaining insertion order with the help of LinkedList
|
||||
LinkedHashMap<VotingPluginUser, Integer> sortedMap = new LinkedHashMap<VotingPluginUser, Integer>();
|
||||
for (Entry<VotingPluginUser, Integer> entry : list) {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> sortedMap = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
@@ -409,14 +439,17 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
YMLFileHandler file = new YMLFileHandler(plugin, new File(plugin.getDataFolder(), fileName));
|
||||
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 count = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(cTop).entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
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());
|
||||
count++;
|
||||
}
|
||||
file.getData().set(cTop.toString(), topVoters);
|
||||
}
|
||||
file.getData().set(cTop.toString(), topVoters);
|
||||
}
|
||||
file.saveData();
|
||||
}
|
||||
@@ -432,7 +465,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -471,7 +504,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -510,7 +543,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -545,10 +578,10 @@ public class TopVoterHandler implements Listener {
|
||||
*/
|
||||
public String[] topVotersAllTime() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<VotingPluginUser, Integer>> list = new LinkedList<Entry<VotingPluginUser, Integer>>(
|
||||
List<Entry<TopVoterPlayer, Integer>> list = new LinkedList<Entry<TopVoterPlayer, Integer>>(
|
||||
plugin.getTopVoter(TopVoter.AllTime).entrySet());
|
||||
int i = 0;
|
||||
for (Entry<VotingPluginUser, Integer> entry : list) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
@@ -574,7 +607,7 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
public String[] topVotersDaily() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<VotingPluginUser> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Daily).keySet());
|
||||
ArrayList<TopVoterPlayer> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Daily).keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
@@ -598,10 +631,10 @@ public class TopVoterHandler implements Listener {
|
||||
*/
|
||||
public String[] topVotersMonthly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<VotingPluginUser, Integer>> list = new LinkedList<Entry<VotingPluginUser, Integer>>(
|
||||
List<Entry<TopVoterPlayer, Integer>> list = new LinkedList<Entry<TopVoterPlayer, Integer>>(
|
||||
plugin.getTopVoter(TopVoter.Monthly).entrySet());
|
||||
int i = 0;
|
||||
for (Entry<VotingPluginUser, Integer> entry : list) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
@@ -630,7 +663,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -658,46 +691,26 @@ public class TopVoterHandler implements Listener {
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public synchronized void updateTopVoters(ArrayList<VotingPluginUser> users1) {
|
||||
ArrayList<VotingPluginUser> users = new ArrayList<VotingPluginUser>();
|
||||
ArrayList<String> blackList = getTopVoterBlackList();
|
||||
for (VotingPluginUser user : users1) {
|
||||
if (!blackList.contains(user.getPlayerName())) {
|
||||
if ((!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore())
|
||||
&& !user.isBanned()) {
|
||||
users.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
public synchronized void updateTopVoters(
|
||||
LinkedHashMap<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> tempTopVoter) {
|
||||
|
||||
plugin.debug("Number of users to check top voter: " + users.size());
|
||||
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (plugin.getConfigFile().getLoadTopVoter(top)) {
|
||||
LinkedHashMap<VotingPluginUser, Integer> map = new LinkedHashMap<VotingPluginUser, Integer>();
|
||||
|
||||
for (VotingPluginUser user : users) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
map.put(user, total);
|
||||
int limitSize = plugin.getConfigFile().getMaxiumNumberOfTopVotersToLoad();
|
||||
for (Entry<TopVoter, LinkedHashMap<TopVoterPlayer, Integer>> entry : tempTopVoter.entrySet()) {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> map = entry.getValue();
|
||||
map = sortByValues(map, false);
|
||||
if (limitSize > 0) {
|
||||
ArrayList<TopVoterPlayer> listKeys = new ArrayList<TopVoterPlayer>(map.keySet());
|
||||
if (listKeys.size() > limitSize) {
|
||||
for (int i = listKeys.size() - 1; i >= 0 && i >= limitSize; i--) {
|
||||
map.remove(listKeys.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
map = sortByValues(map, false);
|
||||
int limitSize = plugin.getConfigFile().getMaxiumNumberOfTopVotersToLoad();
|
||||
if (limitSize > 0) {
|
||||
ArrayList<VotingPluginUser> listKeys = new ArrayList<VotingPluginUser>(map.keySet());
|
||||
if (listKeys.size() > limitSize) {
|
||||
for (int i = listKeys.size() - 1; i >= 0 && i >= limitSize; i--) {
|
||||
map.remove(listKeys.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
plugin.getTopVoter(top).clear();
|
||||
plugin.getTopVoter().put(top, map);
|
||||
plugin.debug(top.toString() + " TopVoter loaded");
|
||||
}
|
||||
tempTopVoter.put(entry.getKey(), map);
|
||||
plugin.setTopVoter(tempTopVoter);
|
||||
plugin.debug(entry.getKey().getName() + " TopVoter loaded, number of players " + map.size());
|
||||
|
||||
}
|
||||
|
||||
plugin.debug("Updated TopVoter");
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.bencodez.votingplugin.topvoter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class TopVoterPlayer {
|
||||
@Getter
|
||||
@Setter
|
||||
private UUID uuid;
|
||||
@Getter
|
||||
@Setter
|
||||
private String playerName;
|
||||
|
||||
public TopVoterPlayer(UUID uuid, String playerName) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
public ItemStack getPlayerHead() {
|
||||
return PlayerUtils.getInstance().getPlayerSkull(getPlayerName(), false);
|
||||
}
|
||||
|
||||
public VotingPluginUser getUser() {
|
||||
return UserManager.getInstance().getVotingPluginUser(getUuid(), getPlayerName());
|
||||
}
|
||||
}
|
||||
@@ -39,10 +39,8 @@ public class CheckUpdate {
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.getUpdater().getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
plugin.getLogger().info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.getUpdater().getVersion());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -59,10 +57,8 @@ public class CheckUpdate {
|
||||
final Updater.UpdateResult result = plugin.getUpdater().getResult();
|
||||
switch (result) {
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.getUpdater().getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
plugin.getLogger().info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.getUpdater().getVersion());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
package com.bencodez.votingplugin.user;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.advancedcore.api.user.usercache.UserDataManager;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class UserManager {
|
||||
@@ -24,24 +27,62 @@ public class UserManager {
|
||||
}
|
||||
|
||||
public UserManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
public void addCachingKeys() {
|
||||
UserDataManager manager = plugin.getUserManager().getDataManager();
|
||||
manager.addKey(new UserDataKeyString("TopVoterIgnore").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyInt("VotePartyVotes"));
|
||||
manager.addKey(new UserDataKeyString("LastVotes"));
|
||||
manager.addKey(new UserDataKeyString("CoolDownCheck").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyInt("MilestoneCount"));
|
||||
manager.addKey(new UserDataKeyInt("MonthTotal"));
|
||||
manager.addKey(new UserDataKeyInt("AllTimeTotal"));
|
||||
manager.addKey(new UserDataKeyInt("DailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("WeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("Points"));
|
||||
manager.addKey(new UserDataKeyInt("DayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("BestDayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyString("DayVoteStreakLastUpdate").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyString("Reminded").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyString("DisableBroadcast").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyInt("WeekVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("BestWeekVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("MonthVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("HighestDailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("HighestMonthlyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("HighestWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastMonthTotal"));
|
||||
manager.addKey(new UserDataKeyInt("BestMonthVoteStreak"));
|
||||
if (plugin.getOptions().isPerServerRewards()) {
|
||||
manager.addKey(new UserDataKeyString("OfflineRewards" + plugin.getOptions().getServer())
|
||||
.setColumnType("MEDIUMTEXT"));
|
||||
}
|
||||
if (plugin.getConfigFile().isExtraAllSitesCheck()) {
|
||||
manager.addKey(new UserDataKeyInt(getGottenAllSitesDayPath()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getGottenAllSitesDayPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "AllSitesLast_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
}
|
||||
return "AllSitesLast";
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllUUIDs() {
|
||||
return com.bencodez.advancedcore.api.user.UserManager.getInstance().getAllUUIDs();
|
||||
return plugin.getUserManager().getAllUUIDs();
|
||||
}
|
||||
|
||||
public VotingPluginUser getVotingPluginUser(com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
|
||||
return getVotingPluginUser(java.util.UUID.fromString(user.getUUID()));
|
||||
}
|
||||
|
||||
public VotingPluginUser getVotingPluginUser(java.util.UUID uuid) {
|
||||
return getVotingPluginUser(new UUID(uuid.toString()));
|
||||
return new VotingPluginUser(plugin, user);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(java.util.UUID uuid, String playerName) {
|
||||
return new VotingPluginUser(plugin, new UUID(uuid.toString()), playerName);
|
||||
public VotingPluginUser getVotingPluginUser(UUID uuid, String playerName) {
|
||||
return new VotingPluginUser(plugin, uuid, playerName);
|
||||
}
|
||||
|
||||
public VotingPluginUser getVotingPluginUser(OfflinePlayer player) {
|
||||
@@ -54,12 +95,16 @@ public class UserManager {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(String playerName) {
|
||||
return new VotingPluginUser(plugin,
|
||||
com.bencodez.advancedcore.api.user.UserManager.getInstance().getProperName(playerName));
|
||||
return new VotingPluginUser(plugin, plugin.getUserManager().getProperName(playerName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(UUID uuid) {
|
||||
return new VotingPluginUser(plugin, uuid);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(UUID uuid, boolean loadName) {
|
||||
return new VotingPluginUser(plugin, uuid, loadName);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -23,15 +24,15 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerReceivePointsEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -72,6 +73,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public VotingPluginUser(VotingPluginMain plugin, AdvancedCoreUser user) {
|
||||
super(plugin, user);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addAllTimeTotal() {
|
||||
setAllTimeTotal(getAllTimeTotal() + 1);
|
||||
}
|
||||
@@ -153,9 +159,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public void bungeeVote(String service, BungeeMessageData text, boolean setTotals) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
VotingPluginMain.plugin.debug("Bungee vote for " + getPlayerName() + " on " + service);
|
||||
plugin.debug("Bungee vote for " + getPlayerName() + " on " + service);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service), getPlayerName(), service,
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service,
|
||||
true);
|
||||
voteEvent.setBungee(true);
|
||||
voteEvent.setForceBungee(true);
|
||||
@@ -174,9 +180,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public void bungeeVoteOnline(String service, BungeeMessageData text, boolean setTotals) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
VotingPluginMain.plugin.debug("Bungee online vote for " + getPlayerName() + " on " + service);
|
||||
plugin.debug("Bungee online vote for " + getPlayerName() + " on " + service);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service), getPlayerName(), service,
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service,
|
||||
true);
|
||||
voteEvent.setBungee(true);
|
||||
voteEvent.setForceBungee(true);
|
||||
@@ -194,11 +200,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public void bungeeVotePluginMessaging(String service, long time, BungeeMessageData text, boolean setTotals,
|
||||
boolean wasOnline) {
|
||||
boolean wasOnline, boolean broadcast) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
VotingPluginMain.plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
|
||||
plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service), getPlayerName(), service,
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service,
|
||||
true);
|
||||
voteEvent.setBungee(true);
|
||||
voteEvent.setVotingPluginUser(this);
|
||||
@@ -207,6 +213,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setAddTotals(setTotals);
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
voteEvent.setWasOnline(wasOnline);
|
||||
voteEvent.setBroadcast(broadcast);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -224,9 +231,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
*/
|
||||
public boolean canVoteAll() {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (!canVote) {
|
||||
return false;
|
||||
if (!voteSite.isHidden()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (!canVote) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -234,7 +243,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public boolean canVoteAny() {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
if (!voteSite.isIgnoreCanVote()) {
|
||||
if (!voteSite.isIgnoreCanVote() && !voteSite.isHidden()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (canVote) {
|
||||
return true;
|
||||
@@ -259,7 +268,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
try {
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
|
||||
.plusHours(VotingPluginMain.plugin.getOptions().getTimeHourOffSet());
|
||||
.plusHours(plugin.getOptions().getTimeHourOffSet());
|
||||
|
||||
if (!voteSite.isVoteDelayDaily()) {
|
||||
double votedelay = voteSite.getVoteDelay();
|
||||
@@ -297,12 +306,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
ArrayList<Integer> days = new ArrayList<Integer>();
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time != 0) {
|
||||
months.add(MiscUtils.getInstance().getMonthFromMili(time));
|
||||
days.add(MiscUtils.getInstance().getDayFromMili(time));
|
||||
} else {
|
||||
return false;
|
||||
if (voteSite.isEnabled() && !voteSite.isHidden()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time != 0) {
|
||||
months.add(MiscUtils.getInstance().getMonthFromMili(time));
|
||||
days.add(MiscUtils.getInstance().getDayFromMili(time));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,17 +334,6 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return true;
|
||||
}
|
||||
|
||||
public void checkCoolDownEvents() {
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (canVoteSite(site) != getLastCoolDownCheck(site)) {
|
||||
plugin.debug(getPlayerName() + " vote cooldown ended: " + site.getKey());
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(this, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
setLastVoteCoolDownCheck(true, site);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDayVoteStreak(boolean forceBungee) {
|
||||
if (!voteStreakUpdatedToday(LocalDateTime.now())) {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage() || hasPercentageTotal(
|
||||
@@ -345,10 +345,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
|
||||
public void clearOfflineRewards() {
|
||||
public void clearOfflineVotes() {
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
setOfflineRewards(new ArrayList<String>());
|
||||
setOfflineOtherRewards(new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void clearTotals() {
|
||||
@@ -359,53 +358,49 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
@Deprecated
|
||||
public int getAllTimeTotal() {
|
||||
return getUserData().getInt("AllTimeTotal");
|
||||
return getUserData().getInt("AllTimeTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getBestDayVoteStreak() {
|
||||
return getData().getInt("BestDayVoteStreak", isWaitForCache());
|
||||
return getData().getInt("BestDayVoteStreak", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getBestMonthVoteStreak() {
|
||||
return getData().getInt("BestMonthVoteStreak", isWaitForCache());
|
||||
return getData().getInt("BestMonthVoteStreak", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getBestWeekVoteStreak() {
|
||||
return getData().getInt("BestWeekVoteStreak", isWaitForCache());
|
||||
return getData().getInt("BestWeekVoteStreak", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getDailyTotal() {
|
||||
return getUserData().getInt("DailyTotal", isWaitForCache());
|
||||
return getUserData().getInt("DailyTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getDayVoteStreak() {
|
||||
return getData().getInt("DayVoteStreak", isWaitForCache());
|
||||
return getData().getInt("DayVoteStreak", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public long getDayVoteStreakLastUpdate() {
|
||||
String str = getData().getString("DayVoteStreakLastUpdate", isWaitForCache());
|
||||
if (str.isEmpty()) {
|
||||
String str = getData().getString("DayVoteStreakLastUpdate", isCacheData(), isWaitForCache());
|
||||
if (str == null || str.isEmpty() || str.equals("null")) {
|
||||
return 0;
|
||||
}
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
public boolean getDisableBroadcast() {
|
||||
return getUserData().getBoolean("DisableBroadcast");
|
||||
return getUserData().getBoolean("DisableBroadcast", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getGottenAllSitesDay() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return getData().getInt("AllSitesLast_" + plugin.getBungeeSettings().getServerNameStorage(), 0, true);
|
||||
} else {
|
||||
return getData().getInt("AllSitesLast", 0, true);
|
||||
}
|
||||
return getData().getInt(plugin.getVotingPluginUserManager().getGottenAllSitesDayPath(), 0, isWaitForCache());
|
||||
}
|
||||
|
||||
public HashMap<String, Boolean> getHasGottenMilestone() {
|
||||
HashMap<String, Boolean> hasGottenMilestone = new HashMap<String, Boolean>();
|
||||
ArrayList<String> milestoneList = getUserData().getStringList("GottenMileStones");
|
||||
ArrayList<String> milestoneList = getUserData().getStringList(getGottenMilestonesPath());
|
||||
for (String str : milestoneList) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1) {
|
||||
@@ -417,48 +412,19 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public int getHighestDailyTotal() {
|
||||
return getData().getInt("HighestDailyTotal", isWaitForCache());
|
||||
return getData().getInt("HighestDailyTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getHighestMonthlyTotal() {
|
||||
return getData().getInt("HighestMonthlyTotal", isWaitForCache());
|
||||
return getData().getInt("HighestMonthlyTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getHighestWeeklyTotal() {
|
||||
return getData().getInt("HighestWeeklyTotal", isWaitForCache());
|
||||
}
|
||||
|
||||
public boolean getLastCoolDownCheck(VoteSite site) {
|
||||
HashMap<VoteSite, Boolean> array = getLastCoolDownCheckArray();
|
||||
if (array.containsKey(site)) {
|
||||
return array.get(site).booleanValue();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Boolean> getLastCoolDownCheckArray() {
|
||||
HashMap<VoteSite, Boolean> lastVotesCheck = new HashMap<VoteSite, Boolean>();
|
||||
ArrayList<String> LastVotesCheckList = getUserData().getStringList("LastVoteCoolDownCheck");
|
||||
for (String str : LastVotesCheckList) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1 && plugin.hasVoteSite(data[0])) {
|
||||
VoteSite site = plugin.getVoteSite(data[0]);
|
||||
if (site != null) {
|
||||
Boolean value = Boolean.FALSE;
|
||||
try {
|
||||
value = Boolean.valueOf(data[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
plugin.debug("Not value: " + data[1]);
|
||||
}
|
||||
lastVotesCheck.put(site, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return lastVotesCheck;
|
||||
return getData().getInt("HighestWeeklyTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getLastMonthTotal() {
|
||||
return getData().getInt("LastMonthTotal", isWaitForCache());
|
||||
return getData().getInt("LastMonthTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Long> getLastVotes() {
|
||||
@@ -467,7 +433,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
for (String str : LastVotesList) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1 && plugin.hasVoteSite(data[0])) {
|
||||
VoteSite site = plugin.getVoteSite(data[0]);
|
||||
VoteSite site = plugin.getVoteSite(data[0], true);
|
||||
if (site != null) {
|
||||
long time = 0;
|
||||
try {
|
||||
@@ -501,20 +467,20 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public int getMilestoneCount() {
|
||||
return getData().getInt("MilestoneCount", getAllTimeTotal(), isWaitForCache());
|
||||
return getData().getInt("MilestoneCount", getAllTimeTotal(), isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMonthTotal() {
|
||||
return getData().getInt("MonthTotal");
|
||||
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getMonthVoteStreak() {
|
||||
return getData().getInt("MonthVoteStreak", isWaitForCache());
|
||||
return getData().getInt("MonthVoteStreak", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public ArrayList<String> getOfflineVotes() {
|
||||
return getUserData().getStringList("OfflineVotes");
|
||||
return getUserData().getStringList("OfflineVotes", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -523,7 +489,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* @return the points
|
||||
*/
|
||||
public int getPoints() {
|
||||
return getUserData().getInt(getPointsPath(), isWaitForCache());
|
||||
return getUserData().getInt(getPointsPath(), isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public String getPointsPath() {
|
||||
@@ -535,7 +501,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public java.util.UUID getPrimaryAccount() {
|
||||
String s = getData().getString("PrimaryAccount", true);
|
||||
String s = getData().getString("PrimaryAccount", isCacheData(), isWaitForCache());
|
||||
if (s != null && !s.isEmpty()) {
|
||||
return java.util.UUID.fromString(s);
|
||||
}
|
||||
@@ -569,13 +535,13 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
public int getTotal(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getUserData().getInt("AllTimeTotal", isWaitForCache());
|
||||
return getUserData().getInt("AllTimeTotal", isCacheData(), isWaitForCache());
|
||||
case Daily:
|
||||
return getUserData().getInt("DailyTotal", isWaitForCache());
|
||||
return getUserData().getInt("DailyTotal", isCacheData(), isWaitForCache());
|
||||
case Monthly:
|
||||
return getData().getInt("MonthTotal", isWaitForCache());
|
||||
return getData().getInt("MonthTotal", isCacheData(), isWaitForCache());
|
||||
case Weekly:
|
||||
return getUserData().getInt("WeeklyTotal", isWaitForCache());
|
||||
return getUserData().getInt("WeeklyTotal", isCacheData(), isWaitForCache());
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -583,20 +549,20 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public int getVotePartyVotes() {
|
||||
return getUserData().getInt("VotePartyVotes", isWaitForCache());
|
||||
return getUserData().getInt("VotePartyVotes", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getVoteShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("VoteShopLimit" + identifier, isWaitForCache());
|
||||
return getData().getInt("VoteShopLimit" + identifier, isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getWeeklyTotal() {
|
||||
return getUserData().getInt("WeeklyTotal");
|
||||
return getUserData().getInt("WeeklyTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public int getWeekVoteStreak() {
|
||||
return getData().getInt("WeekVoteStreak", isWaitForCache());
|
||||
return getData().getInt("WeekVoteStreak", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public void giveDailyTopVoterAward(int place, String path) {
|
||||
@@ -606,27 +572,6 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* public Integer hasLastCumulative(int votesRequired) { HashMap<Integer,
|
||||
* Integer> lastCumative = getLastCumulatives(); if
|
||||
* (lastCumative.containsKey(votesRequired)) { return
|
||||
* lastCumative.get(votesRequired); } return 0; } public HashMap<Integer,
|
||||
* Integer> getLastCumulatives() { HashMap<Integer, Integer> lastCumulative =
|
||||
* new HashMap<Integer, Integer>(); ArrayList<String> milestoneList =
|
||||
* getUserData().getStringList("LastCumulative"); for (String str :
|
||||
* milestoneList) { String[] data = str.split("//"); if (data.length > 1) { try
|
||||
* { lastCumulative.put(Integer.parseInt(data[0]), Integer.parseInt(data[1])); }
|
||||
* catch (Exception e) { e.printStackTrace(); } } } return lastCumulative; }
|
||||
* public void setLastCumulatives(HashMap<Integer, Integer> lastCumulative) {
|
||||
* ArrayList<String> data = new ArrayList<String>(); for (Entry<Integer,
|
||||
* Integer> entry : lastCumulative.entrySet()) { String str = entry.getKey() +
|
||||
* "//" + entry.getValue(); data.add(str); }
|
||||
* getUserData().setStringList("LastCumulative", data); } public void
|
||||
* setLastCumulative(int votesRequired, int value) { HashMap<Integer, Integer>
|
||||
* lastCumulative = getLastCumulatives(); lastCumulative.put(votesRequired,
|
||||
* value); setLastCumulatives(lastCumulative); }
|
||||
*/
|
||||
|
||||
public void giveMonthlyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMonthlyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
@@ -723,14 +668,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* Off vote.
|
||||
*/
|
||||
public void offVote() {
|
||||
if (!VotingPluginMain.plugin.getOptions().isProcessRewards()) {
|
||||
VotingPluginMain.plugin.debug("Processing rewards is disabled");
|
||||
if (!plugin.getOptions().isProcessRewards()) {
|
||||
plugin.debug("Processing rewards is disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginMain.plugin.extraDebug("Checking offline vote site votes for " + player.getName());
|
||||
plugin.extraDebug("Checking offline vote site votes for " + player.getName());
|
||||
|
||||
boolean topVoterIngorePerm = player.hasPermission("VotingPlugin.TopVoter.Ignore");
|
||||
if (isTopVoterIgnore() != topVoterIngorePerm) {
|
||||
@@ -746,7 +691,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
for (int i = 0; i < offlineVotes.size(); i++) {
|
||||
if (plugin.hasVoteSite(offlineVotes.get(i))) {
|
||||
plugin.debug("Giving offline site reward: " + offlineVotes.get(i));
|
||||
playerVote(plugin.getVoteSite(offlineVotes.get(i)), false, true, false);
|
||||
playerVote(plugin.getVoteSite(offlineVotes.get(i), true), false, true, false);
|
||||
} else {
|
||||
plugin.debug("Site doesn't exist: " + offlineVotes.get(i));
|
||||
}
|
||||
@@ -756,7 +701,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast, boolean bungee) {
|
||||
if (plugin.getConfigFile().getFormatBroadcastWhenOnline() && plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& broadcast) {
|
||||
&& broadcast && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
voteSite.broadcastVote(this);
|
||||
}
|
||||
voteSite.giveRewards(this, online, bungee);
|
||||
@@ -828,11 +773,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public void setGottenAllSitesDay(int day) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
getData().setInt("AllSitesLast_" + plugin.getBungeeSettings().getServerNameStorage(), day);
|
||||
} else {
|
||||
getData().setInt("AllSitesLast", day);
|
||||
}
|
||||
getData().setInt(plugin.getVotingPluginUserManager().getGottenAllSitesDayPath(), day);
|
||||
}
|
||||
|
||||
public void setHasGotteMilestone(int votesRequired, boolean b) {
|
||||
@@ -847,7 +788,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
String str = entry.getKey() + "//" + entry.getValue().booleanValue();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList("GottenMileStones", data);
|
||||
getUserData().setStringList(getGottenMilestonesPath(), data);
|
||||
}
|
||||
|
||||
public String getGottenMilestonesPath() {
|
||||
if (plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
return plugin.getOptions().getServer() + "_" + "GottenMilestones";
|
||||
}
|
||||
return "GottenMileStones";
|
||||
}
|
||||
|
||||
public void setHighestDailyTotal(int total) {
|
||||
@@ -862,25 +810,10 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
getData().setInt("HighestWeeklyTotal", total);
|
||||
}
|
||||
|
||||
public void setLastCoolDownCheckArray(HashMap<VoteSite, Boolean> lastVotesCheck) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<VoteSite, Boolean> entry : lastVotesCheck.entrySet()) {
|
||||
String str = entry.getKey().getKey() + "//" + entry.getValue().booleanValue();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList("LastVoteCoolDownCheck", data);
|
||||
}
|
||||
|
||||
public void setLastMonthTotal(int total) {
|
||||
getData().setInt("LastMonthTotal", total);
|
||||
}
|
||||
|
||||
public void setLastVoteCoolDownCheck(boolean lastDelay, VoteSite voteSite) {
|
||||
HashMap<VoteSite, Boolean> array = getLastCoolDownCheckArray();
|
||||
array.put(voteSite, Boolean.valueOf(lastDelay));
|
||||
setLastCoolDownCheckArray(array);
|
||||
}
|
||||
|
||||
public void setLastVotes(HashMap<VoteSite, Long> lastVotes) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<VoteSite, Long> entry : lastVotes.entrySet()) {
|
||||
@@ -894,6 +827,22 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
getData().setInt("MilestoneCount", value);
|
||||
}
|
||||
|
||||
public String getCoolDownCheckPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServer();
|
||||
} else {
|
||||
return "CoolDownCheck";
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoolDownCheck(boolean coolDownCheck) {
|
||||
getData().setBoolean(getCoolDownCheckPath(), coolDownCheck);
|
||||
}
|
||||
|
||||
public boolean getCoolDownCheck() {
|
||||
return getData().getBoolean(getCoolDownCheckPath(), isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMonthTotal(int total) {
|
||||
setTotal(TopVoter.Monthly, total);
|
||||
@@ -906,10 +855,6 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
|
||||
public void setOfflineOtherRewards(ArrayList<String> offlineOtherRewards) {
|
||||
getUserData().setStringList("OfflineOtherRewards", offlineOtherRewards);
|
||||
}
|
||||
|
||||
public void setOfflineVotes(ArrayList<String> offlineVotes) {
|
||||
getUserData().setStringList("OfflineVotes", offlineVotes);
|
||||
}
|
||||
@@ -1125,7 +1070,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
|
||||
.plusHours(VotingPluginMain.plugin.getOptions().getTimeHourOffSet());
|
||||
.plusHours(plugin.getOptions().getTimeHourOffSet());
|
||||
|
||||
if (!voteSite.isVoteDelayDaily()) {
|
||||
double votedelay = voteSite.getVoteDelay();
|
||||
@@ -1220,9 +1165,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
public long voteNextDurationTime(VoteSite voteSite) {
|
||||
long time = getTime(voteSite);
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
;
|
||||
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
|
||||
.plusHours(VotingPluginMain.plugin.getOptions().getTimeHourOffSet());
|
||||
.plusHours(plugin.getOptions().getTimeHourOffSet());
|
||||
|
||||
if (!voteSite.isVoteDelayDaily()) {
|
||||
double votedelay = voteSite.getVoteDelay();
|
||||
@@ -1269,4 +1214,32 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return MiscUtils.getInstance().getTime(getDayVoteStreakLastUpdate()).getDayOfYear() == time.getDayOfYear();
|
||||
}
|
||||
|
||||
public int getSitesNotVotedOn() {
|
||||
int amount = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
if (canVoteSite(site)) {
|
||||
amount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
public TopVoterPlayer getTopVoterPlayer() {
|
||||
return new TopVoterPlayer(UUID.fromString(getUUID()), getPlayerName());
|
||||
}
|
||||
|
||||
public long getNextTimeAllSitesAvailable() {
|
||||
long longest = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
long seconds = voteNextDurationTime(site);
|
||||
if (seconds > longest) {
|
||||
longest = seconds;
|
||||
}
|
||||
}
|
||||
|
||||
return longest;
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user