Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
ba2312ed46 | ||
|
|
2d8f9e1ca1 | ||
|
|
7556a203c2 | ||
|
|
67b8fbcc88 | ||
|
|
4c9f7f76b9 | ||
|
|
df388ca0e3 | ||
|
|
1d8fc309ff | ||
|
|
42a159ea82 | ||
|
|
a62187e0cb | ||
|
|
7896b2f08a | ||
|
|
034d031d79 | ||
|
|
e228fd6fed | ||
|
|
baa85d7222 | ||
|
|
5fd2d976a2 | ||
|
|
03ac8627df | ||
|
|
63d6f2829c | ||
|
|
9824a891b6 | ||
|
|
a648074757 | ||
|
|
5e3a3621bc | ||
|
|
01a645083f | ||
|
|
8b9aced63c | ||
|
|
6eba6aee3b | ||
|
|
0fbbaaee5d | ||
|
|
57e973b371 | ||
|
|
c93f8f06f2 | ||
|
|
6a742dbecc | ||
|
|
c3edbf946c | ||
|
|
24fcd076b8 | ||
|
|
a6ac022cb3 | ||
|
|
363c57158f | ||
|
|
d22e22480e | ||
|
|
daf1d95c82 | ||
|
|
35d588477d | ||
|
|
2ba3ee0323 | ||
|
|
ed1ccc0623 | ||
|
|
2332079002 | ||
|
|
3b7f8afe76 | ||
|
|
4c33f3d03c | ||
|
|
cfd317f5a8 | ||
|
|
063b44aa67 | ||
|
|
a42c00ecf5 | ||
|
|
9e36f0a500 | ||
|
|
f13386ad29 | ||
|
|
1c3dbcc8d6 | ||
|
|
1d4f34ec84 | ||
|
|
2ef4194a51 | ||
|
|
98f60f1350 | ||
|
|
02f98c739f | ||
|
|
766fa58157 | ||
|
|
ebf0c2fb4f | ||
|
|
bc3cfc7986 | ||
|
|
e516f5ee87 | ||
|
|
7abe7c6224 | ||
|
|
e46a9c7476 | ||
|
|
891f4a9d24 | ||
|
|
df6d771e4d | ||
|
|
0f861c4ab7 | ||
|
|
510d4d1895 | ||
|
|
cd4af0ff5d | ||
|
|
77f508682e | ||
|
|
3a41a94f47 | ||
|
|
cba19065a4 | ||
|
|
19a652a1fa | ||
|
|
c8f8077159 | ||
|
|
60db0e87f4 | ||
|
|
f581ce26fb | ||
|
|
0cc06a0b1f | ||
|
|
27dfa7e481 | ||
|
|
0659fd8b84 | ||
|
|
8512eef6c0 | ||
|
|
e860195847 | ||
|
|
3c34798d1a | ||
|
|
1275a10de5 | ||
|
|
99c2e9aa1f | ||
|
|
d3b0787f90 | ||
|
|
faad7d3b85 | ||
|
|
099596fdde | ||
|
|
ab202ffe1c | ||
|
|
b935d7f578 | ||
|
|
d505d197ba | ||
|
|
12c9aab745 | ||
|
|
3c10cb2340 | ||
|
|
f57cc3bc06 | ||
|
|
eb4afec6db | ||
|
|
35b4df196d | ||
|
|
038e8fb98a | ||
|
|
b84a14f849 | ||
|
|
eeda3875e4 | ||
|
|
a584a78734 | ||
|
|
e408c07f85 | ||
|
|
4700684f03 | ||
|
|
8ef7631eed |
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.
@@ -9,7 +9,7 @@ UseBungeecord: false
|
||||
|
||||
# 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
|
||||
@@ -35,6 +35,14 @@ BungeeBroadcastAlways: false
|
||||
# Requires server name below to be correct
|
||||
PerServerRewards: false
|
||||
|
||||
# If true, points will be given on a per server level
|
||||
# Points will be added when server gets vote from bungee
|
||||
PerServerPoints: false
|
||||
|
||||
# If true, plugin will trigger VotifierEvent
|
||||
# Should allow some compability with other plugins
|
||||
TriggerVotifierEvent: false
|
||||
|
||||
# What server this is in bungee (must match)
|
||||
# Also can be applied to rewards
|
||||
Server: PleaseSet
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# VotingPlugin by Ben12345rocks
|
||||
# VotingPlugin by BenCodez
|
||||
# Main Config
|
||||
# See wiki for help:
|
||||
# https://github.com/Ben12345rocks/VotingPlugin/wiki
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki
|
||||
# Config is sorted in sections
|
||||
# Use Control + F to search with Notepad++
|
||||
#
|
||||
@@ -27,33 +27,12 @@ MySQL:
|
||||
# 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
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# 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
|
||||
#Additional info on connection string
|
||||
#Line: ''
|
||||
|
||||
# --------------------
|
||||
# AllowUnJoined options
|
||||
@@ -74,35 +53,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
|
||||
# By default, the reward file will be created for you
|
||||
# Run rewards
|
||||
# and have the default message
|
||||
# Edit the message at AdvancedCore/Rewards/Remind.yml (or any other reward listed)
|
||||
# Can add titles and more in the reward file
|
||||
# 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% to vote on still!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
@@ -137,6 +115,13 @@ Format:
|
||||
# Broadcast only when player is online
|
||||
BroadcastWhenOnline: false
|
||||
|
||||
# Broadcast every x number of minutes with number of players that voted
|
||||
AlternateBroadcast:
|
||||
Enabled: false
|
||||
Broadcast: '&6[&4Broadcast&6] &2%numberofplayers% voted in the last half hour! /vote'
|
||||
# Delay in minutes
|
||||
Delay: 30
|
||||
|
||||
Commands:
|
||||
# Format for /vote
|
||||
# %num% = the number of the site, for a numbered list
|
||||
@@ -224,6 +209,9 @@ Format:
|
||||
Title: '&6&lVoting Player Help'
|
||||
# Format for help message in /v help
|
||||
Line: '&6%Command% - &6%HelpMessage%'
|
||||
# Hover color for help message
|
||||
# Hex format: #HEXCOLOR
|
||||
HoverColor: AQUA
|
||||
# Require permission to see command in /v help or /av help
|
||||
RequirePermission: true
|
||||
|
||||
@@ -247,7 +235,7 @@ Format:
|
||||
|
||||
Today:
|
||||
Title:
|
||||
- '&cToday's Votes %page%/%maxpage%'
|
||||
- "&cToday's Votes %page%/%maxpage%"
|
||||
- '&cPlayerName : VoteSite : Time'
|
||||
Line: '&6%player% : %VoteSite% : %Time%'
|
||||
|
||||
@@ -364,7 +352,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.
|
||||
@@ -384,6 +372,9 @@ TreatVanishAsOffline: false
|
||||
# If true, cooldown check is disabled
|
||||
DisableCoolDownCheck: false
|
||||
|
||||
# If true, disable PlayerInteractEvent (for clicking signs and skulls)
|
||||
DisableInteractEvent: false
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In ticks
|
||||
DelayLoginEvent: 0
|
||||
@@ -442,6 +433,11 @@ PreventRepeatMilestones: false
|
||||
# Mainly to be used for alts and such
|
||||
UsePrimaryAccountForPlaceholders: false
|
||||
|
||||
# Always force placeholders to return value if the value isn't cached
|
||||
# This should prevent server from crashing when pulling placeholders on main thread
|
||||
# Only affects placeholderapi placeholders
|
||||
AlwaysWaitForCachePlaceholders: false
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
@@ -558,12 +554,14 @@ 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
|
||||
|
||||
# Use vault for permission checks
|
||||
@@ -576,12 +574,17 @@ UseVaultPermissions: false
|
||||
# - PERMISSION
|
||||
DisabledCommands: []
|
||||
|
||||
# Enable Geyser prefix support
|
||||
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
|
||||
# Number is time in between clicking in milliseconds
|
||||
SpamClickTime: 350
|
||||
SpamClickTime: 150
|
||||
# Message to send when inventory forced closed when spam clicking
|
||||
# Uncomment to use
|
||||
#SpamClickMessage: '&cDetected spam clicking GUI, closing 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?)
|
||||
@@ -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:
|
||||
@@ -132,6 +134,10 @@ CHEST:
|
||||
VoteLast:
|
||||
Name: 'VoteLast: %player%'
|
||||
BackButton: true
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
# %timesince% = time since vote
|
||||
Line: '&6%timeSince%'
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
@@ -147,7 +153,7 @@ CHEST:
|
||||
Amount: 1
|
||||
VoteTop:
|
||||
Name: 'VoteTop %topvoter%'
|
||||
BackButton: false
|
||||
BackButton: true
|
||||
# Item of top voter (change material below)
|
||||
Item:
|
||||
Name: '&3&l%position%: &3%player%'
|
||||
@@ -268,6 +274,8 @@ CHEST:
|
||||
Name: '&8Back to VoteGUI'
|
||||
# If true, clicking back button will open VoteURL
|
||||
OpenVoteURL: false
|
||||
# If true, backbutton will be the last slot of the GUI
|
||||
EndOfGUI: false
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
# To disable reward set value to []
|
||||
# To disable reward set value to {}
|
||||
# or remove entirely
|
||||
# Eg:
|
||||
# FirstVote: [] (All in one line)
|
||||
# Rewards will be given if there is a reward to give
|
||||
# FirstVote: {} (All in one line)
|
||||
# Rewards will be given if there is a reward to give, otherwise they will be ignored
|
||||
|
||||
# First vote rewards
|
||||
FirstVote:
|
||||
Messages:
|
||||
Player: '&aYou voted for your first time!'
|
||||
|
||||
# First vote of the day reward
|
||||
FirstVoteToday: {}
|
||||
|
||||
# All vote rewards
|
||||
# Reward for voting on all sites in one day
|
||||
@@ -28,9 +31,12 @@ Cumulative:
|
||||
# Wether or not votes must be made in same day/week
|
||||
# Useful if you want to require a certain number of voting sites to be voted on
|
||||
# for a daily/weekly reward instead of all of them
|
||||
VotesInSameDay: false
|
||||
VotesInSameWeek: false
|
||||
VotesInSameMonth: false
|
||||
# Valid options
|
||||
# AllTime
|
||||
# Monthly
|
||||
# Weekly
|
||||
# Daily
|
||||
TotalToUse: AllTime
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %cumulative% cumulative votes!'
|
||||
@@ -47,6 +53,9 @@ VoteParty:
|
||||
# recieve the reward
|
||||
# If false, only players who voted get rewards
|
||||
GiveAllPlayers: false
|
||||
# If true, give online players the vote party reward
|
||||
# Can also use RewardType: ONLINE if you wanted
|
||||
GiveOnlinePlayersOnly: true
|
||||
# If true, the vote count will reset each day
|
||||
ResetEachDay: false
|
||||
# If true, the vote count will reset each week
|
||||
@@ -136,8 +145,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
|
||||
|
||||
@@ -25,7 +25,7 @@ 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
|
||||
|
||||
@@ -43,6 +43,9 @@ 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
|
||||
# If false, spigot servers will EACH set their own totals
|
||||
# If false, AllowUnJoined should false on bungee, spigot servers will handle that
|
||||
@@ -53,7 +56,7 @@ BungeeManageTotals: true
|
||||
# PLUGINMESSAGING Settings
|
||||
# ----------------------------
|
||||
|
||||
# Applies to PLUGINMESSAGING & when SendVotesToAllServers is true
|
||||
# Applies to PLUGINMESSAGING only
|
||||
# Votes will be forwarded when specific player is online
|
||||
WaitForUserOnline: false
|
||||
|
||||
|
||||
@@ -5,7 +5,10 @@ description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: BenCodez
|
||||
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe]
|
||||
loadbefore: [MCPerks]
|
||||
api-version: 1.13
|
||||
libraries:
|
||||
- org.openjdk.nashorn:nashorn-core:15.2
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
@@ -218,7 +221,15 @@ commands:
|
||||
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
|
||||
@@ -244,7 +255,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}'
|
||||
+167
-98
@@ -3,8 +3,8 @@
|
||||
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.2</version>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.6.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
@@ -12,14 +12,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>
|
||||
@@ -79,7 +73,7 @@
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.12.0</version>
|
||||
<version>1.18.20.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>delombok</id>
|
||||
@@ -102,15 +96,19 @@
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>mysql-connector-java</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</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>
|
||||
@@ -128,8 +126,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>xyz.upperlevel.spigot</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
@@ -148,50 +150,16 @@
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</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>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -228,14 +196,7 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>maven-central</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public</url>
|
||||
@@ -249,20 +210,15 @@
|
||||
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bintray-repo</id>
|
||||
<url>https://dl.bintray.com/ichbinjoe/public/</url>
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!--<dependency> <groupId>com.github.Ben12345rocks</groupId> <artifactId>AdvancedCore</artifactId>
|
||||
<version>3.0-SNAPSHOT</version> </dependency> -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -274,48 +230,55 @@
|
||||
<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.6.0</version>
|
||||
<version>2.7.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tchristofferson</groupId>
|
||||
<artifactId>ConfigUpdater</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.6</version>
|
||||
<scope>test</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>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-velocity</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<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>
|
||||
</profile>
|
||||
@@ -324,10 +287,17 @@
|
||||
<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>
|
||||
@@ -341,11 +311,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>
|
||||
@@ -8,23 +8,24 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@Deprecated
|
||||
public class User {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public User(Player p) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return user.getPoints();
|
||||
}
|
||||
|
||||
public void setPoints(int points) {
|
||||
user.setPoints(points);
|
||||
}
|
||||
|
||||
|
||||
public void addPoints(int points) {
|
||||
user.addPoints(points);
|
||||
}
|
||||
|
||||
|
||||
public int getPoints() {
|
||||
return user.getPoints();
|
||||
}
|
||||
|
||||
public boolean removePoints(int points) {
|
||||
return user.removePoints(points);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPoints(int points) {
|
||||
user.setPoints(points);
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,8 @@ public class BungeeHandler {
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
|
||||
plugin.getPluginMessaging().setDebug(true);
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
@@ -80,10 +82,13 @@ public class BungeeHandler {
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
@@ -122,6 +127,10 @@ public class BungeeHandler {
|
||||
player);
|
||||
user.clearCache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
@@ -130,7 +139,7 @@ public class BungeeHandler {
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
if (Boolean.valueOf(args.get(4)) || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
@@ -168,7 +177,7 @@ public class BungeeHandler {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(1);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
@@ -213,6 +222,10 @@ public class BungeeHandler {
|
||||
|
||||
user.clearCache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
user.bungeeVote(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
|
||||
}
|
||||
}
|
||||
@@ -234,6 +247,10 @@ public class BungeeHandler {
|
||||
|
||||
user.clearCache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
user.bungeeVoteOnline(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
|
||||
}
|
||||
}
|
||||
@@ -244,7 +261,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) {
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
|
||||
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VotingPluginHooks {
|
||||
private static VotingPluginHooks instance = new VotingPluginHooks();
|
||||
@@ -20,6 +23,12 @@ public class VotingPluginHooks {
|
||||
RewardHandler.getInstance().addInjectedReward(inject);
|
||||
}
|
||||
|
||||
public void backgroundUpdate(Player player) {
|
||||
VotingPluginUser user = getUserManager().getVotingPluginUser(player);
|
||||
user.offVote();
|
||||
user.checkOfflineRewards();
|
||||
}
|
||||
|
||||
public VotingPluginMain getMainClass() {
|
||||
return VotingPluginMain.plugin;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,7 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
@@ -7,12 +9,12 @@ import com.bencodez.votingplugin.user.UserManager;
|
||||
public class VotingPluginMetrics {
|
||||
|
||||
public void load(VotingPluginMain plugin) {
|
||||
BStatsMetrics metrics = new BStatsMetrics(plugin);
|
||||
BStatsMetrics metrics = new BStatsMetrics(plugin, 38);
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_firstvote") {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_firstvote", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
return "True";
|
||||
@@ -20,11 +22,11 @@ public class VotingPluginMetrics {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
@@ -32,11 +34,11 @@ public class VotingPluginMetrics {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
|
||||
return "True";
|
||||
@@ -44,11 +46,11 @@ public class VotingPluginMetrics {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
@@ -60,22 +62,22 @@ public class VotingPluginMetrics {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (!plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
|
||||
return "False";
|
||||
} else {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_milestone") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_milestone", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
@@ -87,11 +89,11 @@ public class VotingPluginMetrics {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
@@ -99,11 +101,11 @@ public class VotingPluginMetrics {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Day")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Day", s)
|
||||
@@ -115,12 +117,12 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakweek") {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakweek", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Week")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Week", s)
|
||||
@@ -132,12 +134,12 @@ public class VotingPluginMetrics {
|
||||
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakmonth") {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakmonth", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Month")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Month", s)
|
||||
@@ -149,33 +151,33 @@ public class VotingPluginMetrics {
|
||||
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofsites") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofsites", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getVoteSites().size();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + RewardHandler.getInstance().getRewards().size();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isAutoCreateVoteSites();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofusers") {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofusers", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size();
|
||||
if (total < 1000) {
|
||||
return "<1000";
|
||||
@@ -185,59 +187,148 @@ public class VotingPluginMetrics {
|
||||
return "1000-10000";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
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
|
||||
public String call() throws Exception {
|
||||
return plugin.getOptions().getStorageType().toString();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getOptions().isDisableCheckOnWorldChange();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votereminding_enabled") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votereminding_enabled", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getVoteRemindingEnabled();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterMonthly();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterWeekly();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterDaily();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeemethod") {
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeemethod", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "" + plugin.getBungeeHandler().getMethod().toString();
|
||||
} else {
|
||||
return "Disabled";
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeebroadcast", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isBungeeBroadcast();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeebroadcastalways", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isBungeeBroadcastAlways();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("perserverrewards", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isPerServerRewards();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("perserverpoints", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isPerServerPoints();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("triggervotifierevent", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isTriggerVotifierEvent();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("geyserprefixsupport", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getOptions().isGeyserPrefixSupport();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("using_dev_build", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
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();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
public class BroadcastHandler {
|
||||
private VotingPluginMain plugin;
|
||||
private Timer timer;
|
||||
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
public BroadcastHandler(VotingPluginMain plugin, int delay) {
|
||||
this.plugin = plugin;
|
||||
schelude(delay);
|
||||
}
|
||||
|
||||
public void check() {
|
||||
int size = votedPlayers.size();
|
||||
if (size > 0) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
votedPlayers.poll();
|
||||
}
|
||||
String bc = StringParser.getInstance()
|
||||
.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("numberofplayers", "" + size);
|
||||
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
MiscUtils.getInstance().broadcast(bc, players);
|
||||
}
|
||||
}
|
||||
|
||||
public void onVote(String player) {
|
||||
votedPlayers.add(player);
|
||||
}
|
||||
|
||||
public void schelude(int delay) {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = new Timer();
|
||||
} else {
|
||||
timer = new Timer();
|
||||
}
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
check();
|
||||
}
|
||||
}, 1000 * 60, 1000 * 60 * delay);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -12,15 +12,25 @@ public class BungeeMessageData {
|
||||
@Getter
|
||||
private int allTimeTotal = 0;
|
||||
@Getter
|
||||
private int monthTotal = 0;
|
||||
@Getter
|
||||
private int weeklyTotal = 0;
|
||||
@Getter
|
||||
private int dailyTotal = 0;
|
||||
@Getter
|
||||
private int milestoneCount = 0;
|
||||
@Getter
|
||||
private int monthTotal = 0;
|
||||
@Getter
|
||||
private int points = 0;
|
||||
@Getter
|
||||
private int milestoneCount = 0;
|
||||
private int weeklyTotal = 0;
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
int milestoneCount) {
|
||||
this.allTimeTotal = allTimeTotal;
|
||||
this.monthTotal = monthTotal;
|
||||
this.weeklyTotal = weeklyTotal;
|
||||
this.dailyTotal = dailyTotal;
|
||||
this.points = points;
|
||||
this.milestoneCount = milestoneCount;
|
||||
}
|
||||
|
||||
public BungeeMessageData(String str) {
|
||||
String[] data = str.split(Pattern.quote("//"));
|
||||
@@ -40,14 +50,4 @@ public class BungeeMessageData {
|
||||
+ milestoneCount;
|
||||
}
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
int milestoneCount) {
|
||||
this.allTimeTotal = allTimeTotal;
|
||||
this.monthTotal = monthTotal;
|
||||
this.weeklyTotal = weeklyTotal;
|
||||
this.dailyTotal = dailyTotal;
|
||||
this.points = points;
|
||||
this.milestoneCount = milestoneCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,472 +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(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);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,10 @@ public class Config {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getData().getBoolean("AllowUnJoined", false);
|
||||
}
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getData().getStringList("BlockedServers");
|
||||
}
|
||||
@@ -29,22 +33,14 @@ public class Config {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
public String getBungeeHost() {
|
||||
return getData().getString("BungeeServer.Host", "");
|
||||
}
|
||||
|
||||
public boolean getBungeeManageTotals() {
|
||||
return getData().getBoolean("BungeeManageTotals", true);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getData().getBoolean("AllowUnJoined", false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getData().getString("BungeeServer.Host", "");
|
||||
}
|
||||
|
||||
public String getBungeeMethod() {
|
||||
return getData().getString("BungeeMethod", "SOCKETS");
|
||||
}
|
||||
@@ -61,6 +57,10 @@ public class Config {
|
||||
return getData().getString("FallBackServer", "");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getData().getBoolean("SendVotesToAllServers");
|
||||
}
|
||||
@@ -73,6 +73,10 @@ public class Config {
|
||||
return getData().getSection("SpigotServers").getKeys();
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
|
||||
@@ -29,18 +29,6 @@ public class NonVotedPlayersCache {
|
||||
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public String playerExists(String playerName) {
|
||||
if (getData().getSection("NonVotedPlayers").getKeys().contains(playerName)) {
|
||||
return getData().getString("NonVotedPlayers." + playerName + ".UUID", "");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void remove(String player) {
|
||||
bungee.debug("Removing nonvotedplayer: " + player);
|
||||
getData().set("NonVotedPlayers." + player, null);
|
||||
}
|
||||
|
||||
public void check() {
|
||||
for (String player : getData().getSection("NonVotedPlayers").getKeys()) {
|
||||
long time = getData().getLong("NonVotedPlayers." + player + ".LastTime", 0);
|
||||
@@ -82,6 +70,18 @@ public class NonVotedPlayersCache {
|
||||
}
|
||||
}
|
||||
|
||||
public String playerExists(String playerName) {
|
||||
if (getData().getSection("NonVotedPlayers").getKeys().contains(playerName)) {
|
||||
return getData().getString("NonVotedPlayers." + playerName + ".UUID", "");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void remove(String player) {
|
||||
bungee.debug("Removing nonvotedplayer: " + player);
|
||||
getData().set("NonVotedPlayers." + player, null);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
|
||||
@@ -26,7 +26,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 +36,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,11 +21,16 @@ import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
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.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;
|
||||
@@ -38,11 +46,13 @@ 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>>();
|
||||
|
||||
@@ -61,11 +71,13 @@ public class VotingPluginBungee extends Plugin {
|
||||
@Getter
|
||||
private BungeeMySQL mysql;
|
||||
|
||||
private NonVotedPlayersCache nonVotedPlayersCache;
|
||||
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private VoteCache voteCacheFile;
|
||||
|
||||
private NonVotedPlayersCache nonVotedPlayersCache;
|
||||
private boolean votifierEnabled = true;
|
||||
|
||||
public void checkCachedVotes(String server) {
|
||||
if (getProxy().getServerInfo(server) != null) {
|
||||
@@ -180,39 +192,108 @@ 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;
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
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;
|
||||
private void loadMysql() {
|
||||
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)");
|
||||
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");
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -229,12 +310,15 @@ public class VotingPluginBungee extends Plugin {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
voteCacheFile.save();
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
if (mysql != null) {
|
||||
mysql.shutdown();
|
||||
}
|
||||
getLogger().info("VotingPlugin disabled");
|
||||
}
|
||||
|
||||
private boolean votifierEnabled = true;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
@@ -246,45 +330,28 @@ 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 {
|
||||
mysql = new BungeeMySQL("VotingPlugin_Users", config.getData());
|
||||
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
|
||||
|
||||
// column types
|
||||
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");
|
||||
boolean mysqlLoaded = true;
|
||||
try {
|
||||
if (!config.getData().getString("Host", "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
mysqlLoaded = false;
|
||||
getLogger().severe("MySQL settings not set in bungeeconfig.yml");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mysqlLoaded = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
|
||||
|
||||
method = BungeeMethod.getByName(config.getBungeeMethod());
|
||||
if (method == null) {
|
||||
method = BungeeMethod.PLUGINMESSAGING;
|
||||
@@ -292,114 +359,116 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
if (mysqlLoaded) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
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();
|
||||
|
||||
try {
|
||||
for (String server : voteCacheFile.getServers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getServerVotes(server)) {
|
||||
Configuration data = voteCacheFile.getServerVotes(server, num);
|
||||
vote.add(new OfflineBungeeVote(data.getString("Name"), data.getString("UUID"),
|
||||
data.getString("Service"), data.getLong("Time"), data.getBoolean("Real"),
|
||||
data.getString("Text")));
|
||||
try {
|
||||
for (String server : voteCacheFile.getServers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getServerVotes(server)) {
|
||||
Configuration data = voteCacheFile.getServerVotes(server, num);
|
||||
vote.add(new OfflineBungeeVote(data.getString("Name"), data.getString("UUID"),
|
||||
data.getString("Service"), data.getLong("Time"), data.getBoolean("Real"),
|
||||
data.getString("Text")));
|
||||
}
|
||||
cachedVotes.put(server, vote);
|
||||
}
|
||||
cachedVotes.put(server, vote);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
for (String player : voteCacheFile.getPlayers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getServerVotes(player)) {
|
||||
Configuration data = voteCacheFile.getOnlineVotes(player, num);
|
||||
vote.add(new OfflineBungeeVote(data.getString("Name"), data.getString("UUID"),
|
||||
data.getString("Service"), data.getLong("Time"), data.getBoolean("Real"),
|
||||
data.getString("Text")));
|
||||
try {
|
||||
for (String player : voteCacheFile.getPlayers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getOnlineVotes(player)) {
|
||||
Configuration data = voteCacheFile.getOnlineVotes(player, num);
|
||||
vote.add(new OfflineBungeeVote(data.getString("Name"), data.getString("UUID"),
|
||||
data.getString("Service"), data.getLong("Time"), data.getBoolean("Real"),
|
||||
data.getString("Text")));
|
||||
}
|
||||
cachedOnlineVotes.put(player, vote);
|
||||
}
|
||||
cachedOnlineVotes.put(player, vote);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
voteCacheFile.clearData();
|
||||
voteCacheFile.clearData();
|
||||
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String server : cachedVotes.keySet()) {
|
||||
checkCachedVotes(server);
|
||||
@Override
|
||||
public void run() {
|
||||
for (String server : cachedVotes.keySet()) {
|
||||
checkCachedVotes(server);
|
||||
}
|
||||
|
||||
for (String player : cachedOnlineVotes.keySet()) {
|
||||
checkOnlineVotes(getProxy().getPlayer(UUID.fromString(player)), player, null);
|
||||
}
|
||||
}
|
||||
}, 15l, 30l, TimeUnit.SECONDS);
|
||||
|
||||
for (String player : cachedOnlineVotes.keySet()) {
|
||||
checkOnlineVotes(getProxy().getPlayer(UUID.fromString(player)), player, null);
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
debug("Checking nonvotedplayers.yml...");
|
||||
nonVotedPlayersCache.check();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 15l, 30l, TimeUnit.SECONDS);
|
||||
}, 1l, 60l, TimeUnit.MINUTES);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
socketHandler = new SocketHandler(getDescription().getVersion(), config.getBungeeHost(),
|
||||
config.getBungeePort(), encryptionHandler, config.getDebug());
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
debug("Checking nonvotedplayers.yml...");
|
||||
nonVotedPlayersCache.check();
|
||||
}
|
||||
}
|
||||
}, 1l, 60l, TimeUnit.MINUTES);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
socketHandler = new SocketHandler(getDescription().getVersion(), config.getBungeeHost(),
|
||||
config.getBungeePort(), encryptionHandler, config.getDebug());
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data.length > 2) {
|
||||
if (data[0].equalsIgnoreCase("Broadcast")) {
|
||||
sendServerMessage(data);
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data.length > 2) {
|
||||
if (data[0].equalsIgnoreCase("Broadcast")) {
|
||||
sendServerMessage(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data[0].equalsIgnoreCase("StatusOkay")) {
|
||||
String server = data[1];
|
||||
getLogger().info("Voting communicaton okay with " + server);
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data[0].equalsIgnoreCase("StatusOkay")) {
|
||||
String server = data[1];
|
||||
getLogger().info("Voting communicaton okay with " + server);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clientHandles = new HashMap<String, ClientHandler>();
|
||||
List<String> l = config.getBlockedServers();
|
||||
for (String s : config.getSpigotServers()) {
|
||||
if (!l.contains(s)) {
|
||||
Configuration d = config.getSpigotServerConfiguration(s);
|
||||
clientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1298),
|
||||
encryptionHandler, config.getDebug()));
|
||||
clientHandles = new HashMap<String, ClientHandler>();
|
||||
List<String> l = config.getBlockedServers();
|
||||
for (String s : config.getSpigotServers()) {
|
||||
if (!l.contains(s)) {
|
||||
Configuration d = config.getSpigotServerConfiguration(s);
|
||||
clientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1298),
|
||||
encryptionHandler, config.getDebug()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,7 +481,36 @@ public class VotingPluginBungee extends Plugin {
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("sendtoallservers",
|
||||
() -> "" + getConfig().getSendVotesToAllServers()));
|
||||
|
||||
getLogger().info("VotingPlugin loaded, using method: " + method.toString());
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("allowunjoined", () -> "" + getConfig().getAllowUnJoined()));
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("pointsonvote", () -> "" + getConfig().getPointsOnVote()));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("bungeemanagetotals",
|
||||
() -> "" + getConfig().getBungeeManageTotals()));
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -423,8 +521,10 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
ev.setCancelled(true);
|
||||
|
||||
if (!(ev.getSender() instanceof Server))
|
||||
if (!(ev.getSender() instanceof Server)) {
|
||||
debug("Ignore plugin message");
|
||||
return;
|
||||
}
|
||||
|
||||
ByteArrayInputStream instream = new ByteArrayInputStream(ev.getData());
|
||||
DataInputStream in = new DataInputStream(instream);
|
||||
@@ -434,12 +534,25 @@ 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();
|
||||
getLogger().info("Status okay for " + server);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
String player = in.readUTF();
|
||||
debug("Login: " + player);
|
||||
ProxiedPlayer p = getProxy().getPlayer(player);
|
||||
if (p != null && p.isConnected()) {
|
||||
String server = p.getServer().getInfo().getName();
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(p, p.getUniqueId().toString(), server);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
@@ -457,13 +570,6 @@ public class VotingPluginBungee extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PostLoginEvent event) {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
final String server = event.getServer().getInfo().getName();
|
||||
@@ -476,7 +582,7 @@ public class VotingPluginBungee extends Plugin {
|
||||
checkOnlineVotes(event.getPlayer(), uuid, server);
|
||||
}
|
||||
|
||||
}, 2, TimeUnit.SECONDS);
|
||||
}, 3, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private UUID parseUUIDFromString(String uuidAsString) {
|
||||
@@ -497,8 +603,19 @@ public class VotingPluginBungee extends Plugin {
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
public void reload(boolean loadMysql) {
|
||||
config.load();
|
||||
if (loadMysql) {
|
||||
try {
|
||||
if (!config.getData().getString("Host", "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
getLogger().severe("MySQL settings not set in bungeeconfig.yml");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPluginMessageServer(String server, String channel, String... messageData) {
|
||||
@@ -588,7 +705,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);
|
||||
@@ -612,7 +729,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;
|
||||
}
|
||||
}
|
||||
@@ -623,16 +740,33 @@ public class VotingPluginBungee extends Plugin {
|
||||
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", player, DataType.STRING);
|
||||
if (mysql == null) {
|
||||
getLogger().severe("Mysql is not loaded correctly, stopping vote processing");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", uuid, DataType.STRING));
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", new DataValueString(player));
|
||||
}
|
||||
|
||||
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", 1),
|
||||
mysqlUpdate(data, uuid, "MilestoneCount", 1));
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", new DataValueString(uuid)));
|
||||
|
||||
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
|
||||
int monthTotal = getValue(data, "MonthTotal", 1);
|
||||
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
|
||||
int dailyTotal = getValue(data, "DailyTotal", 1);
|
||||
int points = getValue(data, "Points", getConfig().getPointsOnVote());
|
||||
int milestoneCount = getValue(data, "MilestoneCount", 1);
|
||||
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points, milestoneCount);
|
||||
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);
|
||||
}
|
||||
@@ -698,6 +832,9 @@ 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);
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
|
||||
@@ -17,8 +17,12 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
if (sender.hasPermission("votingplugin.admin")) {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
bungee.reload();
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
|
||||
bungee.reload(false);
|
||||
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
bungee.reload(true);
|
||||
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee with MySQL"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
@@ -31,26 +35,28 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"Checking status, waiting for response, check console, method: sockets"));
|
||||
"&aChecking status, waiting for response, check console, method: sockets"));
|
||||
bungee.status(sender);
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)){
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"Checking status, waiting for response, check console, method: plugin messaging"));
|
||||
"&aChecking status, waiting for response, check console, method: plugin messaging"));
|
||||
bungee.status(sender);
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("Not using socket/pluginmessage method, command unavailable"));
|
||||
sender.sendMessage(
|
||||
new TextComponent("&aNot using socket/pluginmessage method, command unavailable"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
TextComponent[] msg = new TextComponent[3];
|
||||
TextComponent[] msg = new TextComponent[4];
|
||||
msg[0] = new TextComponent("&avotingpluginbungee reload - Reload plugin");
|
||||
msg[1] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
|
||||
msg[2] = new TextComponent("&avotingplugin status - Check socket connection status");
|
||||
msg[1] = new TextComponent("&avotingpluginbungee reloadmysql - Reload plugin including mysql");
|
||||
msg[2] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
|
||||
msg[3] = new TextComponent("&avotingpluginbungee status - Check socket connection status");
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("You do not have permission to do this!"));
|
||||
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class Config extends VelocityYMLFile {
|
||||
|
||||
public Config(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getBoolean(getNode("AllowUnJoined"), false);
|
||||
}
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getStringList(getNode("BlockedServers"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getBroadcast() {
|
||||
return getBoolean(getNode("Broadcast"), false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
public boolean getBungeeManageTotals() {
|
||||
return getBoolean(getNode("BungeeManageTotals"), true);
|
||||
}
|
||||
|
||||
public String getBungeeMethod() {
|
||||
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
|
||||
}
|
||||
|
||||
public int getBungeePort() {
|
||||
return getInt(getNode("BungeeServer", "Port"), 1297);
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return getBoolean(getNode("Debug"), false);
|
||||
}
|
||||
|
||||
public String getFallBack() {
|
||||
return getString(getNode("FallBackServer"), "");
|
||||
}
|
||||
|
||||
public ConfigurationNode getMysqlNode() {
|
||||
return getNode("MySQL");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getInt(getNode("PointsOnVote"), 1);
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getBoolean(getNode("SendVotesToAllServers"), true);
|
||||
}
|
||||
|
||||
public ConfigurationNode getSpigotServerConfiguration(String s) {
|
||||
return getNode("SpigotServers", s);
|
||||
}
|
||||
|
||||
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 getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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 {
|
||||
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
public NonVotedPlayersCache(File file, VotingPluginVelocity plugin) {
|
||||
super(file);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
if (!plugin.getMysql().containsKeyQuery(player.getUniqueId().toString())) {
|
||||
addPlayer(player.getUniqueId().toString(), player.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayer(String uuid, String playerName) {
|
||||
getNode("NonVotedPlayers", playerName, "UUID").setValue(uuid);
|
||||
getNode("NonVotedPlayers", playerName, "LastTime").setValue(System.currentTimeMillis());
|
||||
save();
|
||||
}
|
||||
|
||||
public void check() {
|
||||
for (String player : getKeys(getNode("NonVotedPlayers"))) {
|
||||
long time = getNode("NonVotedPlayers", player, "LastTime").getLong(0);
|
||||
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
|
||||
remove(player);
|
||||
} else {
|
||||
String uuid = getNode("NonVotedPlayers", player, "UUID").getString("");
|
||||
if (!uuid.isEmpty()) {
|
||||
if (plugin.getMysql().containsKeyQuery(uuid)) {
|
||||
remove(player);
|
||||
}
|
||||
} else {
|
||||
remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
public String playerExists(String playerName) {
|
||||
if (!getNode("NonVotedPlayers", playerName).isEmpty()) {
|
||||
return getNode("NonVotedPlayers", playerName, "UUID").getString("");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void remove(String player) {
|
||||
plugin.debug("Removing nonvotedplayer: " + player);
|
||||
|
||||
getNode("NonVotedPlayers", player).setValue(null);
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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;
|
||||
|
||||
public class VoteCache extends VelocityYMLFile {
|
||||
|
||||
public VoteCache(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
String[] path = new String[] { "VoteCache", server, "" + num };
|
||||
|
||||
getNode(path, "Name").setValue(voteData.getPlayerName());
|
||||
getNode(path, "Service").setValue(voteData.getService());
|
||||
getNode(path, "UUID").setValue(voteData.getUuid());
|
||||
getNode(path, "Time").setValue(voteData.getTime());
|
||||
getNode(path, "Real").setValue(voteData.isRealVote());
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
String[] path = new String[] { "OnlineCache", player, "" + num };
|
||||
|
||||
getNode(path, "Name").setValue(voteData.getPlayerName());
|
||||
getNode(path, "Service").setValue(voteData.getService());
|
||||
getNode(path, "UUID").setValue(voteData.getUuid());
|
||||
getNode(path, "Time").setValue(voteData.getTime());
|
||||
getNode(path, "Real").setValue(voteData.isRealVote());
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
getNode("VoteCache").setValue(null);
|
||||
getNode("OnlineCache").setValue(null);
|
||||
save();
|
||||
}
|
||||
|
||||
public Collection<String> getOnlineVotes(String name) {
|
||||
return getKeys(getNode("OnlineCache", name));
|
||||
}
|
||||
|
||||
public ConfigurationNode getOnlineVotes(String name, String num) {
|
||||
return getNode("OnlineCache", name, num);
|
||||
}
|
||||
|
||||
public Collection<String> getPlayers() {
|
||||
return getKeys(getNode("OnlineCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getServers() {
|
||||
return getKeys(getNode("VoteCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getKeys(getNode("OnlineCache", server));
|
||||
}
|
||||
|
||||
public ConfigurationNode getServerVotes(String server, String num) {
|
||||
return getNode("VoteCache", server, num);
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
|
||||
public class VotingPluginChannelIdentifier implements ChannelIdentifier {
|
||||
public VotingPluginChannelIdentifier() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return "vp:vp";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,897 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.security.CodeSource;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
import org.bstats.charts.SimplePie;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
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.VelocityMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.PluginMessageEvent;
|
||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyShutdownEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
import com.velocitypowered.api.proxy.messages.ChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.messages.MinecraftChannelIdentifier;
|
||||
import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import com.vexsoftware.votifier.velocity.event.VotifierEvent;
|
||||
|
||||
import lombok.Getter;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.yaml.YAMLConfigurationLoader;
|
||||
|
||||
@Plugin(id = "votingplugin", name = "VotingPlugin", version = "1.0", url = "https://www.spigotmc.org/resources/votingplugin.15358/", description = "VotingPlugin Velocity Version", authors = {
|
||||
"BenCodez" }, dependencies = { @Dependency(id = "nuvotifier", optional = true) })
|
||||
public class VotingPluginVelocity {
|
||||
|
||||
private static final ChannelIdentifier CHANNEL = MinecraftChannelIdentifier.create("vp", "vp");
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
private HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>> cachedVotes = new HashMap<RegisteredServer, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<String, ClientHandler> clientHandles;
|
||||
|
||||
@Getter
|
||||
private Config config;
|
||||
private final Path dataDirectory;
|
||||
private EncryptionHandler encryptionHandler;
|
||||
@Getter
|
||||
private final Logger logger;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
private final Metrics.Factory metricsFactory;
|
||||
|
||||
@Getter
|
||||
private VelocityMySQL mysql;
|
||||
|
||||
private NonVotedPlayersCache nonVotedPlayersCache;
|
||||
|
||||
private final ProxyServer server;
|
||||
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private VoteCache voteCacheFile;
|
||||
|
||||
private Timer timer;
|
||||
|
||||
@Inject
|
||||
public VotingPluginVelocity(ProxyServer server, Logger logger, Metrics.Factory metricsFactory,
|
||||
@DataDirectory Path dataDirectory) {
|
||||
this.server = server;
|
||||
this.logger = logger;
|
||||
this.dataDirectory = dataDirectory;
|
||||
this.metricsFactory = metricsFactory;
|
||||
timer = new Timer();
|
||||
}
|
||||
|
||||
public void checkCachedVotes(RegisteredServer serverToCheck) {
|
||||
if (!serverToCheck.getPlayersConnected().isEmpty()) {
|
||||
if (cachedVotes.containsKey(serverToCheck)
|
||||
&& !config.getBlockedServers().contains(serverToCheck.getServerInfo().getName())) {
|
||||
ArrayList<OfflineBungeeVote> c = cachedVotes.get(serverToCheck);
|
||||
ArrayList<OfflineBungeeVote> newSet = new ArrayList<OfflineBungeeVote>();
|
||||
if (!c.isEmpty()) {
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
boolean toSend = true;
|
||||
if (getConfig().getWaitForUserOnline()) {
|
||||
Player p = null;
|
||||
if (server.getPlayer(UUID.fromString(cache.getUuid())).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(cache.getUuid())).get();
|
||||
}
|
||||
if (p == null || !p.isActive()) {
|
||||
toSend = false;
|
||||
} else if (p != null && p.isActive() && !p.getCurrentServer().get().getServerInfo()
|
||||
.getName().equals(serverToCheck.getServerInfo().getName())) {
|
||||
toSend = false;
|
||||
}
|
||||
|
||||
}
|
||||
if (toSend) {
|
||||
sendPluginMessageServer(serverToCheck, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
} else {
|
||||
debug("Not sending vote because user isn't on server " + serverToCheck + ": "
|
||||
+ cache.toString());
|
||||
newSet.add(cache);
|
||||
}
|
||||
}
|
||||
cachedVotes.put(serverToCheck, newSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void checkOnlineVotes(Player player, String uuid, RegisteredServer serverToCheck) {
|
||||
if (player != null && player.isActive() && cachedOnlineVotes.containsKey(uuid)) {
|
||||
ArrayList<OfflineBungeeVote> c = cachedOnlineVotes.get(uuid);
|
||||
if (!c.isEmpty()) {
|
||||
if (serverToCheck == null) {
|
||||
serverToCheck = player.getCurrentServer().get().getServer();
|
||||
}
|
||||
if (!config.getBlockedServers().contains(serverToCheck.getServerInfo().getName())) {
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendPluginMessageServer(serverToCheck, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText(), "" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void debug(String msg) {
|
||||
if (config.getDebug()) {
|
||||
logger.info("Debug: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID fetchUUID(String playerName) throws Exception {
|
||||
// Get response from Mojang API
|
||||
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.connect();
|
||||
|
||||
if (connection.getResponseCode() == 400) {
|
||||
logger.info("There is no player with the name \"" + playerName + "\"!");
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
// Parse JSON response and get UUID
|
||||
JsonElement element = new JsonParser().parse(bufferedReader);
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
String uuidAsString = object.get("id").getAsString();
|
||||
|
||||
// Return UUID
|
||||
return parseUUIDFromString(uuidAsString);
|
||||
}
|
||||
|
||||
public String getProperName(String uuid, String currentName) {
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
Player p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUsername();
|
||||
}
|
||||
}
|
||||
return currentName;
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
if (server.getPlayer(playerName).isPresent()) {
|
||||
Player p = server.getPlayer(playerName).get();
|
||||
if (p != null && p.isActive()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
}
|
||||
if (mysql != null) {
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private int getValue(ArrayList<Column> cols, String column, int toAdd) {
|
||||
for (Column d : cols) {
|
||||
if (d.getName().equalsIgnoreCase(column)) {
|
||||
|
||||
DataValue value = d.getValue();
|
||||
int num = 0;
|
||||
if (value.isInt()) {
|
||||
num = value.getInt();
|
||||
} else if (value.isString()) {
|
||||
try {
|
||||
num = Integer.parseInt(value.getString());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return num + toAdd;
|
||||
}
|
||||
}
|
||||
return toAdd;
|
||||
}
|
||||
|
||||
private void loadMysql() {
|
||||
mysql = new VelocityMySQL("VotingPlugin_Users", config) {
|
||||
|
||||
@Override
|
||||
public void severe(String str) {
|
||||
getLogger().error(str);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(SQLException e) {
|
||||
if (config.getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
// column types
|
||||
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");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onPluginMessagingReceived(PluginMessageEvent event) {
|
||||
if (event.getIdentifier().getId().equals(CHANNEL.getId())) {
|
||||
ByteArrayInputStream instream = new ByteArrayInputStream(event.getData());
|
||||
DataInputStream in = new DataInputStream(instream);
|
||||
try {
|
||||
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(outstream);
|
||||
String subchannel = in.readUTF();
|
||||
int size = in.readInt();
|
||||
|
||||
// check for status message returns
|
||||
if (subchannel.equalsIgnoreCase("statusokay")) {
|
||||
String server = in.readUTF();
|
||||
logger.info("Status okay for " + server);
|
||||
return;
|
||||
} else if (subchannel.equalsIgnoreCase("login")) {
|
||||
String player = in.readUTF();
|
||||
debug("Login: " + player);
|
||||
Player p = server.getPlayer(player).get();
|
||||
checkCachedVotes(p.getCurrentServer().get().getServer());
|
||||
checkOnlineVotes(p, p.getUniqueId().toString(), p.getCurrentServer().get().getServer());
|
||||
return;
|
||||
} else {
|
||||
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
out.writeUTF(in.readUTF());
|
||||
}
|
||||
for (RegisteredServer send : server.getAllServers()) {
|
||||
|
||||
if (send.getPlayersConnected().size() > 0) {
|
||||
send.sendPluginMessage(CHANNEL, outstream.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyDisable(ProxyShutdownEvent event) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
logger.info("VotingPlugin saving vote cache: " + cachedVotes.size() + "/" + cachedOnlineVotes.size());
|
||||
for (Entry<RegisteredServer, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
|
||||
RegisteredServer server = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVote(server.getServerInfo().getName(), 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++;
|
||||
}
|
||||
}
|
||||
|
||||
voteCacheFile.save();
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
if (mysql != null) {
|
||||
mysql.shutDown();
|
||||
}
|
||||
logger.info("VotingPlugin disabled");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
File configFile = new File(dataDirectory.toFile(), "bungeeconfig.yml");
|
||||
configFile.getParentFile().mkdirs();
|
||||
if (!configFile.exists()) {
|
||||
try {
|
||||
configFile.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
InputStream toCopyStream = VotingPluginVelocity.class.getClassLoader()
|
||||
.getResourceAsStream("bungeeconfig.yml");
|
||||
|
||||
try (FileOutputStream fos = new FileOutputStream(configFile)) {
|
||||
byte[] buf = new byte[2048];
|
||||
int r;
|
||||
while (-1 != (r = toCopyStream.read(buf))) {
|
||||
fos.write(buf, 0, r);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
config = new Config(configFile);
|
||||
server.getChannelRegistrar().register(CHANNEL);
|
||||
method = BungeeMethod.getByName(config.getBungeeMethod());
|
||||
boolean mysqlLoaded = true;
|
||||
try {
|
||||
if (!config.getString(config.getNode("Host"), "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
mysqlLoaded = false;
|
||||
logger.error("MySQL settings not set in bungeeconfig.yml");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
mysqlLoaded = false;
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
CommandMeta meta = server.getCommandManager().metaBuilder("votingpluginbungee")
|
||||
// Specify other aliases (optional)
|
||||
.aliases("vpb").build();
|
||||
|
||||
server.getCommandManager().register(meta, new VotingPluginVelocityCommand(this));
|
||||
|
||||
if (mysqlLoaded) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
voteCacheFile = new VoteCache(new File(dataDirectory.toFile(), "votecache.yml"));
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(
|
||||
new File(dataDirectory.toFile(), "nonvotedplayerscache.yml"), this);
|
||||
|
||||
try {
|
||||
for (String serverToCheck : voteCacheFile.getServers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getServerVotes(serverToCheck)) {
|
||||
ConfigurationNode data = voteCacheFile.getServerVotes(serverToCheck, num);
|
||||
|
||||
vote.add(new OfflineBungeeVote(data.getNode("Name").getString(),
|
||||
data.getNode("UUID").getString(), data.getNode("Service").getString(),
|
||||
data.getNode("Time").getLong(), data.getNode("Real").getBoolean(),
|
||||
data.getNode("TEXT").getString()));
|
||||
}
|
||||
cachedVotes.put(server.getServer(serverToCheck).get(), vote);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
for (String player : voteCacheFile.getPlayers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getOnlineVotes(player)) {
|
||||
ConfigurationNode data = voteCacheFile.getOnlineVotes(player, num);
|
||||
vote.add(new OfflineBungeeVote(data.getNode("Name").getString(),
|
||||
data.getNode("UUID").getString(), data.getNode("Service").getString(),
|
||||
data.getNode("Time").getLong(), data.getNode("Real").getBoolean(),
|
||||
data.getNode("TEXT").getString()));
|
||||
}
|
||||
cachedOnlineVotes.put(player, vote);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
voteCacheFile.clearData();
|
||||
|
||||
server.getScheduler().buildTask(this, () -> {
|
||||
for (RegisteredServer server : cachedVotes.keySet()) {
|
||||
checkCachedVotes(server);
|
||||
}
|
||||
|
||||
for (String player : cachedOnlineVotes.keySet()) {
|
||||
checkOnlineVotes(server.getPlayer(UUID.fromString(player)).get(), player, null);
|
||||
}
|
||||
}).delay(15L, TimeUnit.SECONDS).repeat(30l, TimeUnit.SECONDS).schedule();
|
||||
|
||||
server.getScheduler().buildTask(this, () -> {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
debug("Checking nonvotedplayerscache.yml...");
|
||||
nonVotedPlayersCache.check();
|
||||
}
|
||||
}).delay(1L, TimeUnit.MINUTES).repeat(60l, TimeUnit.MINUTES).schedule();
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(dataDirectory.toFile(), "secretkey.key"));
|
||||
|
||||
socketHandler = new SocketHandler(
|
||||
server.getPluginManager().getPlugin("votingplugin").get().getDescription().getVersion().get(),
|
||||
config.getBungeeHost(), config.getBungeePort(), encryptionHandler, config.getDebug());
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data.length > 2) {
|
||||
if (data[0].equalsIgnoreCase("Broadcast")) {
|
||||
sendServerMessage(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data[0].equalsIgnoreCase("StatusOkay")) {
|
||||
String server = data[1];
|
||||
logger.info("Voting communicaton okay with " + server);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clientHandles = new HashMap<String, ClientHandler>();
|
||||
List<String> l = config.getBlockedServers();
|
||||
for (String s : config.getSpigotServers()) {
|
||||
if (!l.contains(s)) {
|
||||
ConfigurationNode d = config.getSpigotServerConfiguration(s);
|
||||
clientHandles.put(s, new ClientHandler(d.getNode("Host").getString(""),
|
||||
d.getNode("Port").getInt(1298), encryptionHandler, config.getDebug()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
getVersionFile();
|
||||
if (versionFile != null) {
|
||||
versionFile.delete();
|
||||
versionFile.getParentFile().delete();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Metrics metrics = metricsFactory.make(this, 11547);
|
||||
|
||||
metrics.addCustomChart(new SimplePie("bungee_method", () -> getConfig().getBungeeMethod().toString()));
|
||||
|
||||
metrics.addCustomChart(new SimplePie("sendtoallservers", () -> "" + getConfig().getSendVotesToAllServers()));
|
||||
|
||||
metrics.addCustomChart(new SimplePie("allowunjoined", () -> "" + getConfig().getAllowUnJoined()));
|
||||
|
||||
metrics.addCustomChart(new SimplePie("pointsonvote", () -> "" + getConfig().getPointsOnVote()));
|
||||
|
||||
metrics.addCustomChart(new SimplePie("bungeemanagetotals", () -> "" + getConfig().getBungeeManageTotals()));
|
||||
|
||||
metrics.addCustomChart(new SimplePie("waitforuseronline", () -> "" + getConfig().getWaitForUserOnline()));
|
||||
|
||||
metrics.addCustomChart(new SimplePie("plugin_version", () -> "" + version));
|
||||
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
metrics.addCustomChart(new SimplePie("dev_build_number", () -> "" + buildNumber));
|
||||
}
|
||||
|
||||
logger.info("VotingPlugin velocity loaded, method: " + method.toString() + ", PluginMessagingVersion: "
|
||||
+ BungeeVersion.getPluginMessageVersion() + ", Internal Jar Version: " + version);
|
||||
if (!buildNumber.equals("NOTSET")) {
|
||||
logger.info("Detected using dev build number: " + buildNumber);
|
||||
}
|
||||
}
|
||||
|
||||
private String version = "";
|
||||
private File versionFile;
|
||||
private String buildNumber = "NOTSET";
|
||||
|
||||
private void 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) {
|
||||
versionFile = new File(dataDirectory.toFile(),
|
||||
"tmp" + File.separator + "votingpluginversion.yml");
|
||||
if (!versionFile.exists()) {
|
||||
versionFile.getParentFile().mkdirs();
|
||||
versionFile.createNewFile();
|
||||
}
|
||||
FileWriter fileWriter = new FileWriter(versionFile);
|
||||
|
||||
int charVal;
|
||||
while ((charVal = defConfigStream.read()) != -1) {
|
||||
fileWriter.append((char) charVal);
|
||||
}
|
||||
|
||||
fileWriter.close();
|
||||
YAMLConfigurationLoader loader = YAMLConfigurationLoader.builder().setFile(versionFile)
|
||||
.build();
|
||||
defConfigStream.close();
|
||||
ConfigurationNode node = loader.load();
|
||||
if (node != null) {
|
||||
version = node.getNode("version").getString("");
|
||||
buildNumber = node.getNode("buildnumber").getString("NOTSET");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onVotifierEvent(VotifierEvent event) {
|
||||
final String serviceSiteVote = event.getVote().getServiceName();
|
||||
final String name = event.getVote().getUsername();
|
||||
timer.schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String serviceSite = serviceSiteVote;
|
||||
logger.info("Vote received " + name + " from service site " + serviceSite);
|
||||
if (serviceSite.isEmpty()) {
|
||||
serviceSite = "Empty";
|
||||
}
|
||||
vote(name, serviceSite, true);
|
||||
}
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
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),
|
||||
"0x" + uuidAsString.substring(20, 32) };
|
||||
|
||||
long mostSigBits = Long.decode(parts[0]).longValue();
|
||||
mostSigBits <<= 16;
|
||||
mostSigBits |= Long.decode(parts[1]).longValue();
|
||||
mostSigBits <<= 16;
|
||||
mostSigBits |= Long.decode(parts[2]).longValue();
|
||||
|
||||
long leastSigBits = Long.decode(parts[3]).longValue();
|
||||
leastSigBits <<= 48;
|
||||
leastSigBits |= Long.decode(parts[4]).longValue();
|
||||
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void playerServerConnected(ServerConnectedEvent event) {
|
||||
checkCachedVotes(event.getServer());
|
||||
checkOnlineVotes(event.getPlayer(), event.getPlayer().getUniqueId().toString(), event.getServer());
|
||||
}
|
||||
|
||||
public void reload(boolean loadMySQL) {
|
||||
config.reload();
|
||||
if (loadMySQL) {
|
||||
if (!config.getString(config.getNode("Host"), "").isEmpty()) {
|
||||
loadMysql();
|
||||
} else {
|
||||
logger.error("MySQL settings not set in bungeeconfig.yml");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPluginMessageServer(RegisteredServer s, String channel, String... messageData) {
|
||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||
try {
|
||||
out.writeUTF(channel);
|
||||
out.writeInt(messageData.length);
|
||||
for (String message : messageData) {
|
||||
out.writeUTF(message);
|
||||
}
|
||||
if (s.getPlayersConnected().size() > 0) {
|
||||
s.sendPluginMessage(CHANNEL, byteOutStream.toByteArray());
|
||||
}
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
debug("Sending plugin message " + s.getServerInfo().getName() + " " + channel + " "
|
||||
+ ArrayUtils.getInstance().makeStringList(ArrayUtils.getInstance().convert(messageData)));
|
||||
|
||||
}
|
||||
|
||||
public void sendServerMessage(String... messageData) {
|
||||
for (ClientHandler h : clientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendServerMessageServer(String server, String... messageData) {
|
||||
if (clientHandles.containsKey(server)) {
|
||||
clientHandles.get(server).sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSocketVote(String name, String service, BungeeMessageData text) {
|
||||
String uuid = getUUID(name);
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
sendServerMessage("bungeevote", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
} else {
|
||||
// online server only
|
||||
Player p = server.getPlayer(name).get();
|
||||
|
||||
String server = "";
|
||||
if (p != null && p.isActive()) {
|
||||
server = p.getCurrentServer().get().getServerInfo().getName();
|
||||
} else {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
if (config.getBlockedServers().contains(server)) {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
|
||||
sendServerMessageServer(server, "bungeevoteonline", uuid, name, service, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
sendServerMessage("BungeeUpdate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void status() {
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
if (s.getPlayersConnected().size() == 0) {
|
||||
getLogger().info("No players on server " + s + " to send test status message");
|
||||
} else {
|
||||
// send
|
||||
getLogger().info("Sending request for status message on " + s);
|
||||
sendPluginMessageServer(s, "Status", s.getServerInfo().getName());
|
||||
}
|
||||
} else {
|
||||
getLogger().info("Ignoring blocked server " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void vote(String player, String service, boolean realVote) {
|
||||
try {
|
||||
if (player == null || player.isEmpty()) {
|
||||
logger.info("No name from vote on " + service);
|
||||
return;
|
||||
}
|
||||
|
||||
String uuid = getUUID(player);
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getAllowUnJoined()) {
|
||||
UUID u = null;
|
||||
try {
|
||||
u = fetchUUID(player);
|
||||
} catch (Exception e) {
|
||||
if (getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (u == null) {
|
||||
debug("Failed to get uuid for " + player);
|
||||
return;
|
||||
}
|
||||
uuid = u.toString();
|
||||
} else {
|
||||
logger.info("Ignoring vote from " + player + " since player hasn't joined before");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player = getProperName(uuid, player);
|
||||
|
||||
BungeeMessageData text = null;
|
||||
|
||||
if (getConfig().getBungeeManageTotals()) {
|
||||
|
||||
if (mysql == null) {
|
||||
logger.error("Mysql is not loaded correctly, stopping vote processing");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", new DataValueString(player));
|
||||
}
|
||||
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", new DataValueString(uuid)));
|
||||
|
||||
int allTimeTotal = getValue(data, "AllTimeTotal", 1);
|
||||
int monthTotal = getValue(data, "MonthTotal", 1);
|
||||
int weeklyTotal = getValue(data, "WeeklyTotal", 1);
|
||||
int dailyTotal = getValue(data, "DailyTotal", 1);
|
||||
int points = getValue(data, "Points", getConfig().getPointsOnVote());
|
||||
int milestoneCount = getValue(data, "MilestoneCount", 1);
|
||||
text = new BungeeMessageData(allTimeTotal, monthTotal, weeklyTotal, dailyTotal, points, milestoneCount);
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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)) {
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
if (!config.getBlockedServers().contains(s.getServerInfo().getName())) {
|
||||
boolean forceCache = false;
|
||||
Player p = null;
|
||||
if (server.getPlayer(UUID.fromString(uuid)).isPresent()) {
|
||||
p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
}
|
||||
if ((p == null || !p.isActive()) && getConfig().getWaitForUserOnline()) {
|
||||
forceCache = true;
|
||||
debug("Forcing vote to cache");
|
||||
}
|
||||
if (s.getPlayersConnected().isEmpty() || forceCache) {
|
||||
// cache
|
||||
if (!cachedVotes.containsKey(s)) {
|
||||
cachedVotes.put(s, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedVotes.get(s);
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedVotes.put(s, list);
|
||||
|
||||
debug("Caching vote for " + player + " on " + service + " for " + s);
|
||||
|
||||
} else {
|
||||
// send
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(),
|
||||
"" + BungeeVersion.getPluginMessageVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Player p = server.getPlayer(UUID.fromString(uuid)).get();
|
||||
if (p != null && p.isActive() && !config.getBlockedServers()
|
||||
.contains(p.getCurrentServer().get().getServerInfo().getName())) {
|
||||
sendPluginMessageServer(p.getCurrentServer().get().getServer(), "VoteOnline", player, uuid,
|
||||
service, "" + time, Boolean.TRUE.toString(), "" + realVote, text.toString(),
|
||||
"" + getConfig().getBungeeManageTotals(), "" + BungeeVersion.getPluginMessageVersion());
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedOnlineVotes.get(uuid);
|
||||
if (list == null) {
|
||||
list = new ArrayList<OfflineBungeeVote>();
|
||||
}
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
|
||||
for (RegisteredServer s : server.getAllServers()) {
|
||||
sendPluginMessageServer(s, "VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
public VotingPluginVelocityCommand(VotingPluginVelocity plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Invocation invocation) {
|
||||
CommandSource source = invocation.source();
|
||||
// Get the arguments after the command alias
|
||||
String[] args = invocation.arguments();
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
plugin.reload(false);
|
||||
source.sendMessage(Component.text("Reloading VotingPluginBungee").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
plugin.reload(true);
|
||||
source.sendMessage(Component.text("Reloading VotingPluginBungee MySQL").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
plugin.vote(user, site, false);
|
||||
source.sendMessage(Component.text("Sending vote").color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (plugin.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
source.sendMessage(
|
||||
Component.text("Checking status, waiting for response, check console, method: sockets")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
} else if (plugin.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
source.sendMessage(Component
|
||||
.text("Checking status, waiting for response, check console, method: pluginmessaging")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
} else {
|
||||
source.sendMessage(Component.text("Not using socket/pluginmessage method, command unavailable")
|
||||
.color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
String[] msg = new String[4];
|
||||
msg[0] = "votingpluginbungee reload - Reload plugin";
|
||||
msg[1] = "votingpluginbungee reloadmysql - Reload plugin including mysql";
|
||||
msg[2] = "votingpluginbungee vote (player) (servicesite) - Send bungee vote";
|
||||
msg[3] = "votingpluginbungee status - Check socket connection status";
|
||||
for (String m : msg) {
|
||||
source.sendMessage(Component.text(m).color(NamedTextColor.AQUA));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Invocation invocation) {
|
||||
return invocation.source().hasPermission("votingpluginbungee.admin");
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.bencodez.votingplugin.commands;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
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;
|
||||
@@ -32,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;
|
||||
@@ -41,11 +39,13 @@ import com.bencodez.advancedcore.command.gui.UserGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.executers.CommandAliases;
|
||||
import com.bencodez.votingplugin.commands.gui.AdminGUI;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteBungeeSettings;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteHelp;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVotePerms;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholders;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVotePlaceholdersPlayer;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVotePlayer;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteMilestones;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.voteshop.AdminVoteVoteShop;
|
||||
@@ -69,7 +69,6 @@ import com.bencodez.votingplugin.test.VoteTester;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.tchristofferson.configupdater.ConfigUpdater;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -125,8 +124,14 @@ public class CommandLoader {
|
||||
new VoteURL(plugin, event.getWhoClicked(), user, true).open();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// set item to end of the GUI
|
||||
if (sec != null && sec.getBoolean("EndOfGUI")) {
|
||||
b.setSlot(-2);
|
||||
}
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
b.dontClose();
|
||||
}
|
||||
@@ -258,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");
|
||||
|
||||
}
|
||||
});
|
||||
@@ -274,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");
|
||||
|
||||
}
|
||||
@@ -301,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) {
|
||||
@@ -329,10 +334,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");
|
||||
|
||||
}
|
||||
@@ -403,7 +406,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,6 +431,15 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "BungeeSettings" },
|
||||
"VotingPlugin.Commands.AdminVote.Edit.BungeeSettings", "Edit BungeeSettings.yml", false) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
new AdminVoteBungeeSettings(plugin, sender).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "VoteShop" },
|
||||
"VotingPlugin.Commands.AdminVote.Edit.VoteShop", "Edit VoteShop", false) {
|
||||
|
||||
@@ -444,7 +456,7 @@ public class CommandLoader {
|
||||
new AdminVoteMilestones(plugin, sender).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "Cumulative" },
|
||||
"VotingPlugin.Commands.AdminVote.Edit.Cumulative", "Edit cumulative rewards", false) {
|
||||
|
||||
@@ -453,7 +465,7 @@ public class CommandLoader {
|
||||
new AdminVoteCumulative(plugin, sender).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Edit", "VoteParty" },
|
||||
"VotingPlugin.Commands.AdminVote.Edit.VoteParty", "Edit voteparty", false) {
|
||||
|
||||
@@ -610,6 +622,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());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -638,7 +656,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");
|
||||
}
|
||||
@@ -664,7 +682,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");
|
||||
}
|
||||
@@ -683,16 +701,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) {
|
||||
@@ -701,34 +719,52 @@ 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") {
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "DAY", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVoteStreak.Day|" + adminPerm, "Set votestreak for player") {
|
||||
|
||||
@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();
|
||||
}
|
||||
UserManager.getInstance().getVotingPluginUser(args[1])
|
||||
.setDayVoteStreak(Integer.parseInt(args[4]));
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
.colorize("&cSet votestreak day for '" + args[1] + "' to " + args[4]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "WEEK", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVoteStreak.Week|" + adminPerm,
|
||||
"Set votestreak for player") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
UserManager.getInstance().getVotingPluginUser(args[1])
|
||||
.setWeekVoteStreak(Integer.parseInt(args[4]));
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
.colorize("&cSet votestreak week for '" + args[1] + "' to " + args[4]));
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(player)", "SetVoteStreak", "MONTH", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.SetVoteStreak.Month|" + adminPerm,
|
||||
"Set votestreak for player") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
UserManager.getInstance().getVotingPluginUser(args[1])
|
||||
.setMonthVoteStreak(Integer.parseInt(args[4]));
|
||||
sender.sendMessage(StringParser.getInstance()
|
||||
.colorize("&cSet votestreak month for '" + args[1] + "' to " + args[4]));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -781,6 +817,7 @@ public class CommandLoader {
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
user.setMilestoneCount(user.getMilestoneCount() + Integer.parseInt(args[3]));
|
||||
plugin.getSpecialRewards().checkMilestone(user, null, false);
|
||||
sender.sendMessage(
|
||||
StringParser.getInstance().colorize("&cAdded milestonecount for " + args[1]));
|
||||
}
|
||||
@@ -799,12 +836,52 @@ 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") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cTriggering vote for all voting sites...");
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(), false);
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
sendMessage(sender,
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
}
|
||||
}
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
|
||||
if (plugin.isYmlError()) {
|
||||
sendMessage(sender, "&3Detected yml error, please check server log for details");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", "(Sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {
|
||||
|
||||
@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()) {
|
||||
@@ -821,14 +898,57 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote", "(player)", },
|
||||
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote via GUI", false) {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
new AdminVoteVotePlayer(plugin, sender, args[1]).open();
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Vote" },
|
||||
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Manual vote syntax") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&aUse /av vote (player) (site)");
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(Player)", "ForceVote", "All" },
|
||||
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sendMessage(sender, "&cTriggering vote for all voting sites...");
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, args[1], site.getServiceSite(), false);
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
sendMessage(sender,
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
}
|
||||
}
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
|
||||
if (plugin.isYmlError()) {
|
||||
sendMessage(sender, "&3Detected yml error, please check server log for details");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "User", "(Player)", "ForceVote", "(Sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.Vote|" + adminPerm, "Trigger manual vote") {
|
||||
|
||||
@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()) {
|
||||
@@ -866,26 +986,6 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "Config", "Update" },
|
||||
"VotingPlugin.Commands.AdminVote.Config.Edit|" + adminPerm, "Updates config with missing values") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
ArrayList<String> ignoreSections = new ArrayList<String>();
|
||||
ignoreSections.add("VoteReminding");
|
||||
|
||||
File file = new File(plugin.getDataFolder(), "Config.yml");
|
||||
try {
|
||||
ConfigUpdater.update(plugin, "Config.yml", file, ignoreSections);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
plugin.getConfigFile().reloadData();
|
||||
plugin.getConfigFile().loadValues();
|
||||
sendMessage(sender, "&cUpdated config with new values");
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "Config", "TempExtraDebug" },
|
||||
"VotingPlugin.Commands.AdminVote.Config.Edit|" + adminPerm,
|
||||
@@ -903,7 +1003,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()
|
||||
@@ -917,7 +1017,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()
|
||||
@@ -931,7 +1031,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()
|
||||
@@ -946,7 +1046,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()
|
||||
@@ -1002,7 +1102,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);
|
||||
@@ -1066,11 +1166,9 @@ public class CommandLoader {
|
||||
|
||||
@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"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1125,7 +1223,7 @@ public class CommandLoader {
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "VotePartyExtraRequired", "(Number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteParty.SetExtraRequired|" + adminPerm,
|
||||
"Force a voteparty reward, resets vote count") {
|
||||
"Set VotePartyExtraRequired value") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
@@ -1259,6 +1357,18 @@ public class CommandLoader {
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand().add(new CommandHandler(new String[] { "User", "(player)", "ForceFirstVoteToday" },
|
||||
"VotingPlugin.Commands.AdminVote.ForceFirstVoteToday|" + adminPerm, "Force a firstvotetoday reward") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(args[1]);
|
||||
plugin.getSpecialRewards().giveFirstVoteTodayRewards(user, user.isOnline(),
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
sendMessage(sender, "&cFirstVoteToday forced");
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getAdminVoteCommand()
|
||||
.add(new CommandHandler(new String[] { "Placeholders", "(player)" },
|
||||
"VotingPlugin.Commands.AdminVote.Placeholders.Players|" + adminPerm,
|
||||
@@ -1425,7 +1535,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);
|
||||
@@ -1682,8 +1792,7 @@ public class CommandLoader {
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user,
|
||||
plugin.getConfigFile().getData(),
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
@@ -1737,7 +1846,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()
|
||||
@@ -1779,7 +1888,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()
|
||||
@@ -1793,7 +1902,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());
|
||||
@@ -1836,7 +1945,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()
|
||||
@@ -1962,7 +2071,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);
|
||||
@@ -1988,7 +2098,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()
|
||||
@@ -2021,7 +2131,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()
|
||||
@@ -2044,7 +2154,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()
|
||||
@@ -2061,21 +2171,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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteBungeeSettings;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteMilestones;
|
||||
@@ -112,6 +113,14 @@ public class AdminGUI {
|
||||
RewardHandler.getInstance().getDirectlyDefined("FirstVote"));
|
||||
}
|
||||
});
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit FirstVoteToday reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("FirstVoteToday"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AllSites reward")) {
|
||||
|
||||
@@ -121,7 +130,7 @@ public class AdminGUI {
|
||||
RewardHandler.getInstance().getDirectlyDefined("AllSites"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AnySiteRewards")) {
|
||||
|
||||
@Override
|
||||
@@ -130,7 +139,7 @@ public class AdminGUI {
|
||||
RewardHandler.getInstance().getDirectlyDefined("AnySiteRewards"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit EverySiteReward")) {
|
||||
|
||||
@Override
|
||||
@@ -140,6 +149,14 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteBungeeSettings(plugin, clickEvent.getPlayer()).open();
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", new String[] {}, new ItemStack(Material.BUCKET, 1)) {
|
||||
|
||||
@Override
|
||||
@@ -276,7 +293,7 @@ public class AdminGUI {
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelayMin", voteSite.getVoteDelay()) {
|
||||
|
||||
@Override
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class AdminVoteBungeeSettings extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteBungeeSettings(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Edit BungeeSettings");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.BungeeSettings");
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("UseBungeecord", plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueString("BungeeMethod", plugin.getBungeeSettings().getBungeeMethod()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}).addOptions("PLUGINMESSAGING", "SOCKETS", "MYSQL"));
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueBoolean("BungeeDebug", plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("BungeeBroadcast", plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}.addLore("Triggers a broadcast for the entire network, most cases it is best for this to be false")));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("BungeeBroadcastAlways", plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}.addLore("Whether or not to broadcast on cached votes").addLore("PLUGINMESSAGING ONLY")));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerRewards", plugin.getBungeeSettings().isPerServerRewards()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerPoints", plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("TriggerVotifierEvent", plugin.getBungeeSettings().isTriggerVotifierEvent()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("Server", plugin.getBungeeSettings().getServer()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}.addLore("Server name as stated in proxy")));
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getBungeeSettings().getData().set(path, value);
|
||||
plugin.getBungeeSettings().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
}
|
||||
+5
-5
@@ -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;
|
||||
}
|
||||
@@ -40,10 +40,6 @@ public abstract class AdminVoteConfirmation extends GUIHandler {
|
||||
|
||||
}
|
||||
|
||||
public abstract void onConfirm(Player p);
|
||||
|
||||
public abstract void onDeny(Player p);
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(title);
|
||||
@@ -64,6 +60,10 @@ public abstract class AdminVoteConfirmation extends GUIHandler {
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public abstract void onConfirm(Player p);
|
||||
|
||||
public abstract void onDeny(Player p);
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -67,9 +67,7 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
|
||||
if (requirePerms && sender.hasPermission(cmdHandle.getPerm())) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
} else {
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-2
@@ -19,11 +19,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;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -20,12 +20,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;
|
||||
}
|
||||
|
||||
+16
-7
@@ -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;
|
||||
}
|
||||
|
||||
@@ -46,12 +46,6 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getSpecialRewardsConfig().getData().set("VoteParty." + path, value);
|
||||
plugin.getSpecialRewardsConfig().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Edit VoteParty");
|
||||
@@ -121,6 +115,15 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean(
|
||||
"GiveOnlinePlayersOnly", plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
setPathData(getKey(), name);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("ResetEachDay", plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
|
||||
|
||||
@@ -223,4 +226,10 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getSpecialRewardsConfig().getData().set("VoteParty." + path, value);
|
||||
plugin.getSpecialRewardsConfig().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
}
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
|
||||
public class AdminVoteVotePlayer extends GUIHandler {
|
||||
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVotePlayer(VotingPluginMain plugin, CommandSender player, String playerName) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Trigger vote for " + playerName);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Vote|VotingPlugin.Admin");
|
||||
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VoteSite site = (VoteSite) getData("site");
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, playerName, site.getServiceSite(), false);
|
||||
sendMessage(clickEvent.getPlayer(), "&cTriggering vote...");
|
||||
if (voteEvent.getVoteSite() != null) {
|
||||
if (!voteEvent.getVoteSite().isVaidServiceSite()) {
|
||||
sendMessage(clickEvent.getPlayer(),
|
||||
"&cPossible issue with service site, has the server gotten the vote from "
|
||||
+ voteEvent.getServiceSite() + "?");
|
||||
}
|
||||
}
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (plugin.isYmlError()) {
|
||||
sendMessage(clickEvent.getPlayer(),
|
||||
"&3Detected yml error, please check server log for details");
|
||||
}
|
||||
}
|
||||
}.addData("site", site));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
+26
-22
@@ -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;
|
||||
}
|
||||
|
||||
@@ -48,30 +48,34 @@ public class AdminVoteCumulative extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit Cumulative");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.Cumulative");
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cEdit existing cumulative rewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (StringParser.getInstance().isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
}
|
||||
}
|
||||
Number[] options = new Number[nums.size()];
|
||||
for (int i = 0; i < nums.size(); i++) {
|
||||
options[i] = nums.get(i);
|
||||
}
|
||||
new ValueRequestBuilder(new NumberListener() {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cEdit existing cumulative rewards")) {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance().getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (StringParser.getInstance().isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
}
|
||||
}
|
||||
Number[] options = new Number[nums.size()];
|
||||
for (int i = 0; i < nums.size(); i++) {
|
||||
options[i] = nums.get(i);
|
||||
}
|
||||
new ValueRequestBuilder(new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
RewardHandler.getInstance()
|
||||
.getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
|
||||
.request(clickEvent.getPlayer());
|
||||
;
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY).request(clickEvent.getPlayer());;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd cumulative reward")) {
|
||||
|
||||
|
||||
+8
-7
@@ -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;
|
||||
}
|
||||
|
||||
@@ -50,18 +50,19 @@ public class AdminVoteCumulativeRemove extends GUIHandler {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteConfirmation(plugin, clickEvent.getPlayer(), "Remove cumulative " + votes + "?") {
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteCumulative(plugin, p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getSpecialRewardsConfig().removeCumulative(votes);
|
||||
p.sendMessage("Removed cumulative " + votes);
|
||||
plugin.reload();
|
||||
}
|
||||
}.open();;
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteCumulative(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+8
-7
@@ -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;
|
||||
}
|
||||
|
||||
@@ -50,18 +50,19 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteConfirmation(plugin, clickEvent.getPlayer(), "Remove milestone " + votes + "?") {
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteMilestones(plugin, p);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getSpecialRewardsConfig().removeMilestone(votes);
|
||||
p.sendMessage("Removed milestone " + votes);
|
||||
plugin.reload();
|
||||
}
|
||||
}.open();;
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteMilestones(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
+4
-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;
|
||||
}
|
||||
|
||||
@@ -71,7 +71,9 @@ public class AdminVoteMilestones extends GUIHandler {
|
||||
RewardHandler.getInstance()
|
||||
.getDirectlyDefined("MileStones." + value.intValue() + ".Rewards"));
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY).request(clickEvent.getPlayer());;
|
||||
}, 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;
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -9,8 +9,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList;
|
||||
@@ -23,11 +23,11 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private String identifier;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteVoteShopItem(VotingPluginMain plugin, CommandSender player, String identifier) {
|
||||
super(player);
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
@@ -46,12 +46,6 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getGui().getData().set("CHEST.Shop." + identifier + "." + path, value);
|
||||
plugin.getGui().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Edit VoteShop Item: " + identifier);
|
||||
@@ -135,4 +129,10 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getGui().getData().set("CHEST.Shop." + identifier + "." + path, value);
|
||||
plugin.getGui().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
}
|
||||
+9
-8
@@ -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;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit VoteShop Remove Item");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier))
|
||||
@@ -52,18 +52,19 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
new AdminVoteConfirmation(plugin, clickEvent.getPlayer(),
|
||||
"Remove shop item " + identifier + "?") {
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteVoteShop(plugin, p).open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getGui().removeShop(identifier);
|
||||
p.sendMessage("Removed " + identifier);
|
||||
plugin.reload();
|
||||
}
|
||||
}.open();;
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class AdminVoteVoteShopItems extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit VoteShop Items");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
|
||||
|
||||
for (String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class VoteGUI extends GUIHandler {
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (this.user == null) {
|
||||
user = UserManager.getInstance().getVotingPluginUser((Player) player);
|
||||
user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class VoteHelp extends GUIHandler {
|
||||
@@ -21,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;
|
||||
}
|
||||
@@ -37,12 +38,19 @@ public class VoteHelp extends GUIHandler {
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
String colorStr = plugin.getConfigFile().getFormatCommandsVoteHelpHoverColor();
|
||||
ChatColor hoverColor = null;
|
||||
try {
|
||||
hoverColor = ChatColor.of(colorStr);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Failed to get color for hover help message");
|
||||
e.printStackTrace();
|
||||
hoverColor = ChatColor.AQUA;
|
||||
}
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (requirePerms && sender.hasPermission(cmdHandle.getPerm())) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"),
|
||||
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
|
||||
} else {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote"));
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote",
|
||||
plugin.getConfigFile().getFormatCommandsVoteHelpLine(), hoverColor));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class VoteLast extends GUIHandler {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastLine(site)).setAmountNone(1), 1000, 1000) {
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
@@ -74,7 +74,7 @@ public class VoteLast extends GUIHandler {
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player p) {
|
||||
return site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastLine(site)).setAmountNone(1);
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -85,10 +85,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,13 +111,16 @@ 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),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
|
||||
plugin.getGui().getCHESTVoteShopPurchase(identifier),
|
||||
placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -54,11 +55,11 @@ public class VoteToday extends GUIHandler {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("page", "" + page);
|
||||
placeholders.put("maxpage", "" + maxPage);
|
||||
|
||||
|
||||
for (String m : plugin.getConfigFile().getFormatCommandsVoteTodayTitle()) {
|
||||
msg.add(m);
|
||||
}
|
||||
|
||||
|
||||
page--;
|
||||
|
||||
for (int i = pagesize * page; (i < voteToday.length) && (i < ((page + 1) * pagesize)); i++) {
|
||||
@@ -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()) {
|
||||
|
||||
+4
-3
@@ -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()) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.MessageBuilder;
|
||||
@@ -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;
|
||||
@@ -115,17 +115,17 @@ public class VoteURL extends GUIHandler {
|
||||
|
||||
private ItemBuilder getItemVoteSite(VoteSite voteSite) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedItemSection());
|
||||
|
||||
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteItemSection());
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteNameCanVote().replace("%Name%", voteSite.getDisplayName()));
|
||||
builder.setName(
|
||||
plugin.getGui().getChestVoteURLGUISiteNameCanVote().replace("%Name%", voteSite.getDisplayName()));
|
||||
} else {
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteName().replace("%Name%", voteSite.getDisplayName()));
|
||||
builder.addLoreLine(
|
||||
plugin.getGui().getChestVoteURLNextVote().replace("%Info%", user.voteCommandNextInfo(voteSite)));
|
||||
}
|
||||
|
||||
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -25,10 +25,6 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private boolean bungeeDebug = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VotifierBypass")
|
||||
@Getter
|
||||
private boolean votifierBypass = false;
|
||||
|
||||
@ConfigDataString(path = "BungeeMethod")
|
||||
@Getter
|
||||
private String bungeeMethod = "PLUGINMESSAGING";
|
||||
@@ -41,14 +37,18 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private int bungeeServerPort = 1297;
|
||||
|
||||
@ConfigDataBoolean(path = "RemoveInvalidUsers")
|
||||
@ConfigDataBoolean(path = "PerServerPoints")
|
||||
@Getter
|
||||
private boolean removeInvalidUsers = false;
|
||||
private boolean perServerPoints = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PerServerRewards")
|
||||
@Getter
|
||||
private boolean perServerRewards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "RemoveInvalidUsers")
|
||||
@Getter
|
||||
private boolean removeInvalidUsers = false;
|
||||
|
||||
@ConfigDataString(path = "Server")
|
||||
@Getter
|
||||
private String server = "PleaseSet";
|
||||
@@ -61,14 +61,26 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private int spigotServerPort = 1298;
|
||||
|
||||
@ConfigDataBoolean(path = "TriggerVotifierEvent")
|
||||
@Getter
|
||||
private boolean triggerVotifierEvent = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseBungeecord", secondPath = "UseBungeecoord")
|
||||
@Getter
|
||||
private boolean useBungeecoord = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VotifierBypass")
|
||||
@Getter
|
||||
private boolean votifierBypass = 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,13 +37,9 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseVoteGUIMainCommand")
|
||||
@ConfigDataBoolean(path = "PreloadSkulls")
|
||||
@Getter
|
||||
private boolean useVoteGUIMainCommand = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraAllSitesCheck")
|
||||
@Getter
|
||||
private boolean extraAllSitesCheck = false;
|
||||
private boolean preloadSkulls = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
@@ -53,10 +49,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlterColumns")
|
||||
@Getter
|
||||
private boolean alterColumns = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AlternateUUIDLookup")
|
||||
@Getter
|
||||
private boolean alternateUUIDLookup = false;
|
||||
@@ -69,6 +61,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean alwaysUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysWaitForCachePlaceholders")
|
||||
@Getter
|
||||
private boolean alwaysWaitForCachePlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
@@ -77,26 +73,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 = 250;
|
||||
|
||||
@ConfigDataInt(path = "ConvertDelay", defaultValue = 30000)
|
||||
@Getter
|
||||
private int convertDelay;
|
||||
|
||||
@ConfigDataBoolean(path = "CountFakeVotes")
|
||||
@Getter
|
||||
private boolean countFakeVotes = true;
|
||||
@@ -105,10 +81,18 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private int delayBetweenUpdates = 3;
|
||||
|
||||
@ConfigDataInt(path = "DelayLoginEvent")
|
||||
@Getter
|
||||
private int delayLoginEvent = 0;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableAdvancedTab")
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableCoolDownCheck")
|
||||
@Getter
|
||||
private boolean disableCoolDownCheck = false;
|
||||
|
||||
@ConfigDataListString(path = "DisabledCommands")
|
||||
@Getter
|
||||
private ArrayList<String> disabledCommands = new ArrayList<String>();
|
||||
@@ -117,6 +101,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<String>();
|
||||
|
||||
@ConfigDataBoolean(path = "DisableInteractEvent")
|
||||
@Getter
|
||||
private boolean disableInteractEvent = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableNoServiceSiteMessage")
|
||||
@Getter
|
||||
private boolean disableNoServiceSiteMessage = false;
|
||||
@@ -125,10 +113,26 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean disableUpdateChecking = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraAllSitesCheck")
|
||||
@Getter
|
||||
private boolean extraAllSitesCheck = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraBackgroundUpdate")
|
||||
@Getter
|
||||
private boolean extraBackgroundUpdate = false;
|
||||
|
||||
@ConfigDataString(path = "Format.AlternateBroadcast.Broadcast")
|
||||
@Getter
|
||||
private String formatAlternateBroadcastBroadcast = "&6[&4Broadcast&6] &2%numberofplayers% voted in the last half hour! /vote";
|
||||
|
||||
@ConfigDataInt(path = "Format.AlternateBroadcast.Delay")
|
||||
@Getter
|
||||
private int formatAlternateBroadcastDelay = 30;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.AlternateBroadcast.Enabled")
|
||||
@Getter
|
||||
private boolean formatAlternateBroadcastEnabled = false;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteForceLinks = true;
|
||||
@@ -215,11 +219,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataInt(path = "MaxiumNumberOfTopVotersToLoad")
|
||||
@Getter
|
||||
private int MaxiumNumberOfTopVotersToLoad = -1;
|
||||
|
||||
@ConfigDataInt(path = "DelayLoginEvent")
|
||||
@Getter
|
||||
private int delayLoginEvent = 0;
|
||||
private int MaxiumNumberOfTopVotersToLoad = 1000;
|
||||
|
||||
@ConfigDataBoolean(path = "OverrideVersionDisable")
|
||||
@Getter
|
||||
@@ -233,6 +233,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean updateWithPlayersOnlineOnly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseHighestTotals")
|
||||
@Getter
|
||||
private boolean useHighestTotals = true;
|
||||
|
||||
@ConfigDataBoolean(path = "UseJavascriptPlaceholders")
|
||||
@Getter
|
||||
private boolean useJavascriptPlaceholders = false;
|
||||
@@ -241,9 +245,13 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean usePrimaryAccountForPlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableCoolDownCheck")
|
||||
@ConfigDataBoolean(path = "UseVoteGUIMainCommand")
|
||||
@Getter
|
||||
private boolean disableCoolDownCheck = false;
|
||||
private boolean useVoteGUIMainCommand = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseVoteStreaks")
|
||||
@Getter
|
||||
private boolean useVoteStreaks = true;
|
||||
|
||||
@ConfigDataListString(path = "VotingBroadcastBlacklist")
|
||||
@Getter
|
||||
@@ -313,6 +321,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.
|
||||
*
|
||||
@@ -661,14 +673,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("LoadTopVoter.AllTime", true);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "UseVoteStreaks")
|
||||
@Getter
|
||||
private boolean useVoteStreaks = true;
|
||||
|
||||
@ConfigDataBoolean(path = "UseHighestTotals")
|
||||
@Getter
|
||||
private boolean useHighestTotals = true;
|
||||
|
||||
public boolean getLoadTopVoterDaily() {
|
||||
return getData().getBoolean("LoadTopVoter.Daily", false);
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
@@ -69,6 +69,9 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData(String siteName) {
|
||||
if (!getData().isConfigurationSection("VoteSites." + siteName)) {
|
||||
plugin.getLogger().warning("VoteSites." + siteName + " is not a configuration section");
|
||||
}
|
||||
return getData().getConfigurationSection("VoteSites." + siteName);
|
||||
}
|
||||
|
||||
@@ -144,10 +147,6 @@ public class ConfigVoteSites extends YMLFile {
|
||||
public boolean getVoteSiteEnabled(String siteName) {
|
||||
return getData(siteName).getBoolean("Enabled");
|
||||
}
|
||||
|
||||
public boolean getVoteSiteHidden(String siteName) {
|
||||
return getData(siteName).getBoolean("Hidden");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site file.
|
||||
@@ -174,6 +173,14 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(site).getBoolean("ForceOffline", getData(site).getBoolean("GiveOffline"));
|
||||
}
|
||||
|
||||
public boolean getVoteSiteHidden(String siteName) {
|
||||
return getData(siteName).getBoolean("Hidden");
|
||||
}
|
||||
|
||||
public boolean getVoteSiteIgnoreCanVote(String siteName) {
|
||||
return getData(siteName).getBoolean("IgnoreCanVote");
|
||||
}
|
||||
|
||||
public boolean getVoteSiteResetVoteDelayDaily(String siteName) {
|
||||
return getData(siteName).getBoolean("VoteDelayDaily");
|
||||
}
|
||||
@@ -185,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")) {
|
||||
@@ -218,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));
|
||||
@@ -231,11 +233,14 @@ public class ConfigVoteSites extends YMLFile {
|
||||
|
||||
for (int i = siteNames.size() - 1; i >= 0; i--) {
|
||||
// plugin.getLogger().info(siteNames.get(i));
|
||||
if (!getVoteSiteEnabled(siteNames.get(i)) || siteNames.get(i).equalsIgnoreCase("null")
|
||||
|| !siteCheck(siteNames.get(i))) {
|
||||
if (!getData().isConfigurationSection("VoteSites." + siteNames.get(i))) {
|
||||
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)) && checkEnabled) || !siteCheck(siteNames.get(i))) {
|
||||
// plugin.getLogger().info("Removed: " + siteNames.get(i));
|
||||
siteNames.remove(i);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -144,16 +144,27 @@ public class GUI extends YMLFile {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public String getCHESTVoteShopPurchase(String identifier) {
|
||||
return getData().getString("CHEST.Shop." + identifier + ".PurchaseMessage",
|
||||
plugin.getConfigFile().getFormatShopPurchaseMsg());
|
||||
}
|
||||
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void createShop(String value) {
|
||||
ConfigurationSection shopData = getData().createSection("CHEST.Shop." + value);
|
||||
shopData.set("Identifier_Name", value);
|
||||
shopData.set("Material", "STONE");
|
||||
shopData.set("Amount", 1);
|
||||
shopData.set("Name", "&cPlaceholder item");
|
||||
shopData.set("Cost", 1);
|
||||
shopData.set("Permission", "");
|
||||
shopData.set("CloseGUI", true);
|
||||
shopData.set("RequireConfirmation", false);
|
||||
|
||||
shopData.set("Rewards.Items.Item1.Material", "STONE");
|
||||
shopData.set("Rewards.Items.Item1.Amount", 1);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public ConfigurationSection getCHESTBackButton() {
|
||||
return getData().getConfigurationSection("CHEST.BackButton");
|
||||
}
|
||||
@@ -218,10 +229,6 @@ public class GUI extends YMLFile {
|
||||
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot) {
|
||||
return "CHEST.VoteGUI." + slot + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot lore.
|
||||
*
|
||||
@@ -233,6 +240,10 @@ public class GUI extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot) {
|
||||
return "CHEST.VoteGUI." + slot + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slots.
|
||||
*
|
||||
@@ -264,6 +275,10 @@ public class GUI extends YMLFile {
|
||||
return getData().getBoolean("CHEST.VoteLast.BackButton");
|
||||
}
|
||||
|
||||
public String getChestVoteLastLine() {
|
||||
return getData().getString("CHEST.VoteLast.Line", "&6%timeSince%");
|
||||
}
|
||||
|
||||
public String getChestVoteLastName() {
|
||||
return getData().getString("CHEST.VoteLast.Name", "VoteLast: %player%");
|
||||
}
|
||||
@@ -304,6 +319,11 @@ public class GUI extends YMLFile {
|
||||
return getData().getString("CHEST.Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
public String getCHESTVoteShopPurchase(String identifier) {
|
||||
return getData().getString("CHEST.Shop." + identifier + ".PurchaseMessage",
|
||||
plugin.getConfigFile().getFormatShopPurchaseMsg());
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopResetDaily(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Daily", false);
|
||||
}
|
||||
@@ -357,7 +377,7 @@ public class GUI extends YMLFile {
|
||||
}
|
||||
|
||||
public boolean getChestVoteTopBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteToday.BackButton");
|
||||
return getData().getBoolean("CHEST.VoteTop.BackButton");
|
||||
}
|
||||
|
||||
public String getChestVoteTopItemLore() {
|
||||
@@ -368,14 +388,14 @@ public class GUI extends YMLFile {
|
||||
return getData().getString("CHEST.VoteTop.Item.Name", "&3&l%position%: &3%player%");
|
||||
}
|
||||
|
||||
public boolean getChestVoteTopOpenMainGUIOnClick() {
|
||||
return getData().getBoolean("CHEST.VoteTop.OpenMainGUIOnClick", true);
|
||||
}
|
||||
|
||||
public String getChestVoteTopName() {
|
||||
return getData().getString("CHEST.VoteTop.Name", "VoteTop %topvoter%");
|
||||
}
|
||||
|
||||
public boolean getChestVoteTopOpenMainGUIOnClick() {
|
||||
return getData().getBoolean("CHEST.VoteTop.OpenMainGUIOnClick", true);
|
||||
}
|
||||
|
||||
public int getChestVoteTopSize() {
|
||||
return getData().getInt("CHEST.VoteTop.Size", 27);
|
||||
}
|
||||
@@ -424,6 +444,14 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.WeekTotal.Item");
|
||||
}
|
||||
|
||||
public int getChestVoteURLAllUrlsButtonSlot() {
|
||||
return getData().getInt("CHEST.VoteURL.AllUrlsButton.Slot", -1);
|
||||
}
|
||||
|
||||
public int getChestVoteURLAllUrlsButtonStartSlot() {
|
||||
return getData().getInt("CHEST.VoteURL.StartSlot", -1);
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLAlreadyVotedAllUrlsButtonItemSection() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem");
|
||||
@@ -436,25 +464,6 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AlreadyVotedItem");
|
||||
}
|
||||
|
||||
public int getChestVoteURLAllUrlsButtonSlot() {
|
||||
return getData().getInt("CHEST.VoteURL.AllUrlsButton.Slot", -1);
|
||||
}
|
||||
|
||||
public int getChestVoteURLAllUrlsButtonStartSlot() {
|
||||
return getData().getInt("CHEST.VoteURL.StartSlot", -1);
|
||||
}
|
||||
|
||||
public Set<String> getChestVoteURLExtraItems() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
public boolean getChestVoteURLBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteURL.BackButton");
|
||||
}
|
||||
@@ -471,6 +480,17 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.CanVoteItem");
|
||||
}
|
||||
|
||||
public Set<String> getChestVoteURLExtraItems() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL site name.
|
||||
*
|
||||
@@ -524,6 +544,11 @@ public class GUI extends YMLFile {
|
||||
return getData().getBoolean("CHEST.VoteURL.ViewAllUrlsButtonEnabled");
|
||||
}
|
||||
|
||||
public boolean isChestVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
|
||||
isChestVoteShopRequireConfirmation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
@@ -534,27 +559,6 @@ public class GUI extends YMLFile {
|
||||
plugin.saveResource("GUI.yml", true);
|
||||
}
|
||||
|
||||
public boolean isChestVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
|
||||
isChestVoteShopRequireConfirmation());
|
||||
}
|
||||
|
||||
public void createShop(String value) {
|
||||
ConfigurationSection shopData = getData().createSection("CHEST.Shop." + value);
|
||||
shopData.set("Identifier_Name", value);
|
||||
shopData.set("Material", "STONE");
|
||||
shopData.set("Amount", 1);
|
||||
shopData.set("Name", "&cPlaceholder item");
|
||||
shopData.set("Cost", 1);
|
||||
shopData.set("Permission", "");
|
||||
shopData.set("CloseGUI", true);
|
||||
shopData.set("RequireConfirmation", false);
|
||||
|
||||
shopData.set("Rewards.Items.Item1.Material", "STONE");
|
||||
shopData.set("Rewards.Items.Item1.Amount", 1);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void removeShop(String value) {
|
||||
getData().set("CHEST.Shop." + value, null);
|
||||
saveData();
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataDouble;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@@ -36,17 +37,24 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private String firstVoteRewardsPath = "FirstVote";
|
||||
|
||||
@Getter
|
||||
private String firstVoteTodayRewardsPath = "FirstVoteToday";
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
|
||||
@ConfigDataBoolean(path = "VoteParty.GiveOnlinePlayersOnly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
private boolean votePartyGiveOnlinePlayersOnly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetCount")
|
||||
@Getter
|
||||
private boolean votePartyResetCount = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
|
||||
@@ -102,18 +110,35 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
* @param cumulative the cumulative
|
||||
* @return the cumulative votes in same day
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameDay(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameMonth(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameWeek(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
public String getCumulativeVotesTotal(int cumulative) {
|
||||
String str = getData().getString("Cumulative." + cumulative + ".TotalToUse", "");
|
||||
if (str.isEmpty()) {
|
||||
if (getCumulativeVotesInSameMonth(cumulative)) {
|
||||
return TopVoter.Monthly.toString();
|
||||
} else if (getCumulativeVotesInSameWeek(cumulative)) {
|
||||
return TopVoter.Weekly.toString();
|
||||
} else if (getCumulativeVotesInSameDay(cumulative)) {
|
||||
return TopVoter.Daily.toString();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
@@ -229,14 +254,14 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyOnlyOncePerDay() {
|
||||
return getData().getBoolean("VoteParty.OnlyOncePerDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetMontly() {
|
||||
return getData().getBoolean("VoteParty.ResetMonthly");
|
||||
}
|
||||
@@ -305,9 +330,8 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
plugin.saveResource("SpecialRewards.yml", true);
|
||||
}
|
||||
|
||||
public void setMilestone(int intValue) {
|
||||
getData().set("Milestones." + intValue + ".Enabled", true);
|
||||
getData().set("Milestones." + intValue + ".Rewards.Messages.Player", "&aYou got %milestone% milestone votes!");
|
||||
public void removeCumulative(String votes) {
|
||||
getData().set("Cumulative." + votes, null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
@@ -316,14 +340,17 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void removeCumulative(String votes) {
|
||||
getData().set("Cumulative." + votes, null);
|
||||
public void setCumulative(int intValue) {
|
||||
getData().set("Cumulative." + intValue + ".Enabled", true);
|
||||
getData().set("Cumulative." + intValue + ".TotalToUse", "AllTime");
|
||||
getData().set("Cumulative." + intValue + ".Rewards.Messages.Player",
|
||||
"&aYou got %cumulative% cumulative votes!");
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setCumulative(int intValue) {
|
||||
getData().set("Cumulative." + intValue + ".Enabled", true);
|
||||
getData().set("Cumulative." + intValue + ".Rewards.Messages.Player", "&aYou got %cumulative% cumulative votes!");
|
||||
public void setMilestone(int intValue) {
|
||||
getData().set("Milestones." + intValue + ".Enabled", true);
|
||||
getData().set("Milestones." + intValue + ".Rewards.Messages.Player", "&aYou got %milestone% milestone votes!");
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -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 load() {
|
||||
checkAll();
|
||||
}
|
||||
private Timer timer;
|
||||
|
||||
public void checkAll() {
|
||||
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() {
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,14 @@ public class ServerData {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
@@ -233,23 +241,15 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void updateLastVoteParty() {
|
||||
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateLastVoteParty() {
|
||||
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -71,7 +71,7 @@ public class PlayerVoteEvent extends Event {
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean wasOnline;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bencodez.votingplugin.events;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, MILESTONE, VOTESTREAK;
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
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;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
public class BungeeVotifierEvent {
|
||||
public void send(VotingPluginMain plugin, PlayerVoteEvent event) {
|
||||
plugin.debug("Triggering vote event");
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
@Deprecated
|
||||
public class PlayerCommandSendListener implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public PlayerCommandSendListener(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTab(PlayerCommandSendEvent event) {
|
||||
if (plugin.getConfigFile().isDisableAdvancedTab()) {
|
||||
return;
|
||||
}
|
||||
ArrayList<String> removeCmds = new ArrayList<String>();
|
||||
if (!VotingPluginMain.plugin.getAdvancedTab().containsKey(event.getPlayer().getUniqueId())) {
|
||||
ArrayList<String> whiteListed = new ArrayList<String>();
|
||||
for (String cmd : event.getCommands()) {
|
||||
if (plugin.getCommandLoader().isVotingPluginCommand(event.getPlayer(), cmd)) {
|
||||
if (!plugin.getCommandLoader().hasPermission(event.getPlayer(), cmd)
|
||||
&& !whiteListed.contains(cmd)) {
|
||||
removeCmds.add(cmd);
|
||||
// plugin.debug("removed " + cmd);
|
||||
} else {
|
||||
removeCmds.remove(cmd);
|
||||
whiteListed.add(cmd);
|
||||
// plugin.debug("has " + cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
VotingPluginMain.plugin.getAdvancedTab().put(event.getPlayer().getUniqueId(), removeCmds);
|
||||
} else {
|
||||
removeCmds = VotingPluginMain.plugin.getAdvancedTab().get(event.getPlayer().getUniqueId());
|
||||
}
|
||||
event.getCommands().removeAll(removeCmds);
|
||||
}
|
||||
}
|
||||
@@ -39,44 +39,51 @@ public class PlayerInteract implements Listener {
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
// plugin.debug("Checking for sign click");
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
// plugin.debug(player.getName() + " right clicked a sign");
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
UserManager.getInstance().getVotingPluginUser(player).sendMessage(sign.getRightClickMessage());
|
||||
if (plugin.getConfigFile().isDisableInteractEvent()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSigns().getSigns().size() > 0) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
// plugin.debug("Checking for sign click");
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
// plugin.debug(player.getName() + " right clicked a sign");
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
UserManager.getInstance().getVotingPluginUser(player)
|
||||
.sendMessage(sign.getRightClickMessage());
|
||||
|
||||
if (!sign.isSkullSet()) {
|
||||
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Sign.Create")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Admin")) {
|
||||
player.sendMessage("Skull not set, click to set skull");
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", sign.getSign());
|
||||
if (!sign.isSkullSet()) {
|
||||
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Sign.Create")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Admin")) {
|
||||
player.sendMessage("Skull not set, click to set skull");
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", sign.getSign());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getClickedBlock().getState() instanceof Skull) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "skullset");
|
||||
if (ob != null) {
|
||||
String sign1 = (String) ob;
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.getSign().equals(sign1)) {
|
||||
sign.setSkullLocation(event.getClickedBlock().getLocation());
|
||||
sign.storeSign();
|
||||
sign.checkSkulls();
|
||||
player.sendMessage("Skull set");
|
||||
} else if (event.getClickedBlock().getState() instanceof Skull) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "skullset");
|
||||
if (ob != null) {
|
||||
String sign1 = (String) ob;
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.getSign().equals(sign1)) {
|
||||
sign.setSkullLocation(event.getClickedBlock().getLocation());
|
||||
sign.storeSign();
|
||||
sign.checkSkulls();
|
||||
player.sendMessage("Skull set");
|
||||
}
|
||||
}
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", null);
|
||||
}
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -31,6 +32,29 @@ public class PlayerJoinEvent implements Listener {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
private void login(Player player) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (player.isOp() && plugin.isYmlError()) {
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
|
||||
}
|
||||
|
||||
boolean data = user.getData().hasData();
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
if (data) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
}
|
||||
|
||||
user.loginRewards();
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()
|
||||
&& plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("Login", user.getPlayerName(), user.getUUID());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On player login.
|
||||
*
|
||||
@@ -58,24 +82,6 @@ public class PlayerJoinEvent implements Listener {
|
||||
|
||||
}
|
||||
|
||||
private void login(Player player) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (player.isOp() && plugin.isYmlError()) {
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
|
||||
}
|
||||
|
||||
boolean data = user.getData().hasData();
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
if (data) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
}
|
||||
|
||||
user.loginRewards();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin.getConfigFile().isDisableAdvancedTab()) {
|
||||
@@ -89,6 +95,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -64,10 +64,18 @@ public class PlayerVoteListener implements Listener {
|
||||
if (event.isBungee()) {
|
||||
plugin.debug("BungeePlayerVote forcebungee: " + event.isForceBungee() + ", bungeetotals: "
|
||||
+ event.getBungeeTextTotals());
|
||||
|
||||
if (plugin.getBungeeSettings().isTriggerVotifierEvent()) {
|
||||
new BungeeVotifierEvent().send(plugin, event);
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
@@ -83,17 +91,22 @@ 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();
|
||||
}
|
||||
// reupdate cache
|
||||
user.clearCache();
|
||||
|
||||
user.updateName(true);
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
@@ -113,13 +126,17 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getBroadcastHandler() != null) {
|
||||
plugin.getBroadcastHandler().onVote(playerName);
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
if (event.getTime() != 0) {
|
||||
user.setTime(voteSite, event.getTime());
|
||||
} else {
|
||||
user.setTime(voteSite);
|
||||
}
|
||||
user.setLastVoteCoolDownCheck(false, voteSite);
|
||||
plugin.getCoolDownCheck().vote(user);
|
||||
|
||||
// try logging to file
|
||||
if (plugin.getConfigFile().isLogVotesToFile()) {
|
||||
@@ -134,8 +151,9 @@ public class PlayerVoteListener implements Listener {
|
||||
|
||||
// check first vote rewards
|
||||
plugin.getSpecialRewards().checkFirstVote(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkFirstVoteToday(user, event.isForceBungee());
|
||||
|
||||
if (user.isReminded()) {
|
||||
if (user.isReminded() && plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
@@ -181,13 +199,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,9 +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
|
||||
@@ -73,15 +81,15 @@ public class VotiferEvent implements Listener {
|
||||
&& (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");
|
||||
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 {
|
||||
@@ -89,15 +97,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.getLogger()
|
||||
.info("Current known service sites: " + ArrayUtils.getInstance().makeStringList(plugin.getServerData().getServiceSites()));
|
||||
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;
|
||||
@@ -36,13 +35,17 @@ public class VoteSite {
|
||||
@Setter
|
||||
private boolean enabled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean giveOffline;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean hidden;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean giveOffline;
|
||||
private boolean ignoreCanVote;
|
||||
|
||||
@Setter
|
||||
private ConfigurationSection item;
|
||||
@@ -101,6 +104,9 @@ public class VoteSite {
|
||||
* @param checkBungee check bungee broadcast
|
||||
*/
|
||||
public void broadcastVote(VotingPluginUser user, boolean checkBungee) {
|
||||
if (plugin.getConfigFile().isFormatAlternateBroadcastEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (!user.isVanished()) {
|
||||
if (checkBungee && plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
@@ -112,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,6 +233,7 @@ public class VoteSite {
|
||||
waitUntilVoteDelay = plugin.getConfigVoteSites().getWaitUntilVoteDelay(key);
|
||||
timeOffSet = plugin.getConfigVoteSites().getTimeOffSet(key);
|
||||
hidden = plugin.getConfigVoteSites().getVoteSiteHidden(key);
|
||||
ignoreCanVote = plugin.getConfigVoteSites().getVoteSiteIgnoreCanVote(key);
|
||||
}
|
||||
|
||||
public boolean isVaidServiceSite() {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.bencodez.votingplugin.placeholders;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
@@ -15,6 +17,7 @@ import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
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;
|
||||
|
||||
@@ -39,7 +42,11 @@ public class PlaceHolders {
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -50,14 +57,15 @@ public class PlaceHolders {
|
||||
}
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
|
||||
user.setWaitForCache(false);
|
||||
if (!user.isCached()) {
|
||||
user.loadCache();
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
user.setWaitForCache(false);
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
@@ -78,7 +86,7 @@ public class PlaceHolders {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders()) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier, false);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
@@ -247,6 +255,14 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Return true/false if player can vote on all sites"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("CanVoteSites") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
return "" + user.getSitesNotVotedOn();
|
||||
}
|
||||
}.withDescription("Return number of votesites available"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_AnySite") {
|
||||
|
||||
@Override
|
||||
@@ -305,8 +321,8 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, 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())) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -321,9 +337,9 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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++;
|
||||
}
|
||||
@@ -337,7 +353,7 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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();
|
||||
}
|
||||
@@ -352,8 +368,8 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, 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())) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -368,7 +384,7 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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();
|
||||
}
|
||||
@@ -384,9 +400,9 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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++;
|
||||
}
|
||||
@@ -399,8 +415,8 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, 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())) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -415,7 +431,7 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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();
|
||||
}
|
||||
@@ -431,9 +447,9 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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++;
|
||||
}
|
||||
@@ -446,8 +462,8 @@ public class PlaceHolders {
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, 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())) {
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (entry.getKey().getUuid().equals(p.getUniqueId())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
@@ -462,7 +478,7 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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();
|
||||
}
|
||||
@@ -486,9 +502,9 @@ public class PlaceHolders {
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, 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++;
|
||||
}
|
||||
@@ -569,5 +585,43 @@ public class PlaceHolders {
|
||||
return Integer.toString(total);
|
||||
}
|
||||
}.withDescription("Global daily total"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder<VotingPluginUser>("TimeUntilDayReset") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, VotingPluginUser user, String identifier) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0);
|
||||
LocalDateTime offsetoclocktomorrow = plugin.getTimeChecker().getTime().plusDays(1).withHour(0)
|
||||
.withMinute(0);
|
||||
|
||||
String timeMsg = "%hours% Hours %minutes% Minutes";
|
||||
Duration dur = null;
|
||||
if (!now.isBefore(offsetoclocktoday)) {
|
||||
dur = Duration.between(now, offsetoclocktomorrow);
|
||||
|
||||
} else {
|
||||
dur = Duration.between(now, offsetoclocktoday);
|
||||
}
|
||||
int diffHours = (int) (dur.getSeconds() / (60 * 60));
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
|
||||
|
||||
if (diffHours < 0) {
|
||||
diffHours = diffHours * -1;
|
||||
}
|
||||
if (diffHours >= 24) {
|
||||
diffHours = diffHours - 24;
|
||||
}
|
||||
if (diffMinutes < 0) {
|
||||
diffMinutes = diffMinutes * -1;
|
||||
}
|
||||
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
|
||||
timeMsg = StringParser.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
return timeMsg;
|
||||
|
||||
}
|
||||
}.withDescription("Time until plugin time day changes"));
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -251,6 +257,7 @@ public class SignHandler {
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
plugin.debug("Failed to update sign at " + getLocation().toString());
|
||||
VotingPluginMain.plugin.debug(ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class Signs {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Signs updated");
|
||||
plugin.debug(getSigns().size() + " Signs updated");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -63,29 +63,27 @@ public class SpecialRewards {
|
||||
boolean gotCumulative = false;
|
||||
int total = 0;
|
||||
boolean useBungeeTotalNum = bungeeMessageData != null;
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameDay(votesRequired)) {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.Daily);
|
||||
} else {
|
||||
total = bungeeMessageData.getDailyTotal();
|
||||
}
|
||||
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameWeek(votesRequired)) {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.Weekly);
|
||||
} else {
|
||||
total = bungeeMessageData.getWeeklyTotal();
|
||||
}
|
||||
} else if (plugin.getSpecialRewardsConfig().getCumulativeVotesInSameMonth(votesRequired)) {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.Monthly);
|
||||
} else {
|
||||
total = bungeeMessageData.getMonthTotal();
|
||||
}
|
||||
String totalToUse = plugin.getSpecialRewardsConfig().getCumulativeVotesTotal(votesRequired);
|
||||
TopVoter top = TopVoter.getTopVoter(totalToUse);
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(top);
|
||||
} else {
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(TopVoter.AllTime);
|
||||
} else {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
total = bungeeMessageData.getAllTimeTotal();
|
||||
break;
|
||||
case Daily:
|
||||
total = bungeeMessageData.getDailyTotal();
|
||||
break;
|
||||
case Monthly:
|
||||
total = bungeeMessageData.getMonthTotal();
|
||||
break;
|
||||
case Weekly:
|
||||
total = bungeeMessageData.getWeeklyTotal();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +95,12 @@ public class SpecialRewards {
|
||||
|
||||
if (gotCumulative) {
|
||||
gotCumulativeAny = true;
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired + ", current total: " + total);
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired + ", total: "
|
||||
+ top.toString() + ", current total: " + total);
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired, forceBungee);
|
||||
} else {
|
||||
plugin.devDebug(user.getPlayerName() + " not able to get cumulative " + votesRequired);
|
||||
plugin.devDebug(user.getPlayerName() + " not able to get cumulative " + votesRequired
|
||||
+ ", total required: " + top.toString() + ", current player total: " + total);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,18 @@ public class SpecialRewards {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkFirstVoteToday(VotingPluginUser user, boolean forceBungee) {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVoteToday()) {
|
||||
giveFirstVoteTodayRewards(user, user.isOnline(), forceBungee);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkMilestone(VotingPluginUser user, BungeeMessageData bungeeMessageData, boolean forceBungee) {
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
if (bungeeMessageData != null) {
|
||||
@@ -274,6 +286,18 @@ public class SpecialRewards {
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveFirstVoteTodayRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.FIRSTVOTETODAY);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteTodayRewardsPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveMilestoneVoteReward(VotingPluginUser user, boolean online, int milestone, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.MILESTONE.setAmount(milestone));
|
||||
|
||||
@@ -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());
|
||||
@@ -28,6 +28,22 @@ public enum TopVoter {
|
||||
return new TopVoter[] { TopVoter.Daily, TopVoter.Weekly, TopVoter.Monthly };
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return "AllTimeTotal";
|
||||
case Daily:
|
||||
return "DailyTotal";
|
||||
case Monthly:
|
||||
return "MonthTotal";
|
||||
case Weekly:
|
||||
return "WeeklyTotal";
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return VotingPluginMain.plugin.getConfigFile().getFormatTopVoterMonthly();
|
||||
@@ -91,20 +107,4 @@ public enum TopVoter {
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
public String getColumnName() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return "AllTimeTotal";
|
||||
case Daily:
|
||||
return "DailyTotal";
|
||||
case Monthly:
|
||||
return "MonthTotal";
|
||||
case Weekly:
|
||||
return "WeeklyTotal";
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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: {
|
||||
|
||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user