Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
132d871039 | ||
|
|
aea6954dbb | ||
|
|
1ee8819e4c | ||
|
|
41e3b7fbf6 | ||
|
|
4218d240bc | ||
|
|
683d6fcc42 | ||
|
|
c9f6ab2fa6 | ||
|
|
c99d3baa3c | ||
|
|
d0ade2feff | ||
|
|
dcebe5a701 | ||
|
|
d33791fb28 | ||
|
|
8512b3ab4f | ||
|
|
4395d8cc89 | ||
|
|
55f4e6872c | ||
|
|
6699a9204c | ||
|
|
14e1a975c9 | ||
|
|
7ab3c4bcf9 | ||
|
|
1866196571 | ||
|
|
301c21ed20 | ||
|
|
2d5208a568 | ||
|
|
44a543e64c | ||
|
|
458c66819a | ||
|
|
dcf4f3f15d | ||
|
|
e33ef5420a | ||
|
|
8d1c3a05ce | ||
|
|
9a167a46d8 | ||
|
|
ffe60808b6 | ||
|
|
1affd6c2fa | ||
|
|
17225dca5b | ||
|
|
fc9f55ead8 | ||
|
|
eec877623e | ||
|
|
a06b0573c5 | ||
|
|
dfcfee302f | ||
|
|
cb1cc27c60 | ||
|
|
aed30a94c0 | ||
|
|
8e172e2647 | ||
|
|
ca355e1a01 | ||
|
|
b0e18d5224 | ||
|
|
f5fc80ef14 | ||
|
|
21f846f0bc | ||
|
|
a6a742b91e | ||
|
|
4ca6510910 | ||
|
|
e06ea06884 | ||
|
|
2c79dff678 | ||
|
|
56c4a094cf | ||
|
|
1898af9fea | ||
|
|
885d2bc019 | ||
|
|
12c604d09c | ||
|
|
7b48699b39 | ||
|
|
3b5593882f | ||
|
|
8c72154eed | ||
|
|
0dc942ecfd | ||
|
|
bc4d051590 | ||
|
|
011a0322ea | ||
|
|
ed90db12a4 | ||
|
|
3afea03485 | ||
|
|
6da17ee181 | ||
|
|
e5d1c255c0 | ||
|
|
b43754661c | ||
|
|
89c419c8df | ||
|
|
bd6b2b1edb | ||
|
|
b7c73902f2 | ||
|
|
c0995447de | ||
|
|
d970506c76 | ||
|
|
74fb06302a | ||
|
|
1cfed8aa98 | ||
|
|
9f563c37e5 | ||
|
|
d311588984 | ||
|
|
8c5324f602 | ||
|
|
17832a0bf7 | ||
|
|
3c415c63c9 | ||
|
|
6ab27775d2 | ||
|
|
e04bf8210f | ||
|
|
7b4879ddf1 | ||
|
|
081ac7bb3c | ||
|
|
d9894c6b74 | ||
|
|
f13f56c830 | ||
|
|
b6a67f2aeb | ||
|
|
a5b416b210 | ||
|
|
caa4a7a714 | ||
|
|
72aa819361 | ||
|
|
cf52db0c7d | ||
|
|
5021c4bf67 | ||
|
|
9dd8e757d4 | ||
|
|
da7cdb74d4 | ||
|
|
18c6ee6614 | ||
|
|
cafe2b1de7 | ||
|
|
74c94746c1 | ||
|
|
61130a1b2b | ||
|
|
7dafa5c8eb | ||
|
|
c89edc47c3 | ||
|
|
0b89df6262 | ||
|
|
c2218b2c67 | ||
|
|
1950cfdd2d | ||
|
|
71af70a026 | ||
|
|
b269c29f7c | ||
|
|
c9e8ade60f | ||
|
|
2364fd7ac6 | ||
|
|
7135ed0f95 | ||
|
|
b5fbaaaf92 | ||
|
|
94c025886a | ||
|
|
0956466edb | ||
|
|
b2b23ab622 | ||
|
|
0e6529efbe | ||
|
|
f7ce51f63a | ||
|
|
68334ef1a2 | ||
|
|
404c1eeb4d | ||
|
|
347c1d975d | ||
|
|
3b022fc841 | ||
|
|
88afb70fad | ||
|
|
62e21d9f93 | ||
|
|
20289a5d7b | ||
|
|
02b0103fbd | ||
|
|
a514ad6cac | ||
|
|
894f1147fd | ||
|
|
6a881b7c5f | ||
|
|
b3eaac0fbb | ||
|
|
4444b53106 | ||
|
|
ec4a28a63e | ||
|
|
f3722a32f5 | ||
|
|
b3cf416fc4 | ||
|
|
66c2f3a5a6 | ||
|
|
50609d6729 | ||
|
|
0635e7370e | ||
|
|
f94951cffa | ||
|
|
5ebdcca3e6 | ||
|
|
f00b7df49b | ||
|
|
e0a6c14825 | ||
|
|
a3bcc4a391 | ||
|
|
7af7034149 | ||
|
|
3cb18946ed | ||
|
|
ac604ee538 | ||
|
|
aac3c129cc | ||
|
|
28695094ca | ||
|
|
ac583d58bc | ||
|
|
52de25fad3 | ||
|
|
72bf623007 | ||
|
|
c6e61ea5a5 | ||
|
|
b400476758 | ||
|
|
9ff0fc8356 | ||
|
|
f7b142e8c6 | ||
|
|
4d80915811 | ||
|
|
f1edc73eca | ||
|
|
197beb1792 | ||
|
|
3aed208345 | ||
|
|
27e500fbf0 | ||
|
|
a0f6016dcd | ||
|
|
f37abe15c7 | ||
|
|
8f66733fe7 | ||
|
|
1bafb69f84 | ||
|
|
ed5ced8b31 | ||
|
|
468747847c | ||
|
|
d28ccc85ac | ||
|
|
9b5d6333d1 | ||
|
|
99307f15c7 | ||
|
|
8e9db014d1 | ||
|
|
5e88782475 | ||
|
|
ba50789744 | ||
|
|
f06e2d8045 | ||
|
|
58e7143a0a | ||
|
|
0ee3706190 | ||
|
|
9f7fc3dafd | ||
|
|
d8ce4a9578 | ||
|
|
574e8d4a54 | ||
|
|
19a7a6a733 | ||
|
|
1e131e57c3 |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=Cp1252
|
||||
encoding/Resources=Cp1252
|
||||
encoding/src=Cp1252
|
||||
@@ -1,13 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
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
|
||||
@@ -17,40 +8,14 @@ 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.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
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.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
@@ -59,65 +24,4 @@ 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.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=info
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,7 @@
|
||||
DataStorage: SQLITE
|
||||
|
||||
# Information for mysql
|
||||
# See the end of the config for cache options
|
||||
MySQL:
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
@@ -28,21 +29,9 @@ MySQL:
|
||||
#UseSSL: true
|
||||
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data files)
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# If true, plugin will send scoreboards on some commands
|
||||
SendScoreboards: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note that updates take 30-40 minutes to load before they can be downloaded
|
||||
AutoDownload: false
|
||||
|
||||
# ------------------------------------------------
|
||||
# VoteReminding
|
||||
# ------------------------------------------------
|
||||
@@ -85,6 +74,9 @@ VoteReminding:
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
ActionBar:
|
||||
Message: '&cRemember to vote'
|
||||
Delay: 30
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
@@ -112,6 +104,9 @@ Commands:
|
||||
# If true, you can right click a votesite from /vote (gui version) and open the vote reward gui for that site
|
||||
# Can be used to display rewards for that site
|
||||
VoteRewardFromVoteURL: false
|
||||
# disable /vote reward commands
|
||||
# Effective after restart
|
||||
DisableVoteRewardGUIs: false
|
||||
|
||||
Format:
|
||||
# CommandHandler help message
|
||||
@@ -169,7 +164,12 @@ Format:
|
||||
Title: '&3&l%player% Last Vote Times:'
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
Line: '&3%SiteName%: &6%time%'
|
||||
# %timesince% = time since vote
|
||||
Line: '&3%SiteName%: &6%timeSince%'
|
||||
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
LastVoted: '%times% ago'
|
||||
NeverVoted: 'Never voted'
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
@@ -246,6 +246,16 @@ Format:
|
||||
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
TimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
TimeFormats:
|
||||
Day: 'Day'
|
||||
Days: 'Days'
|
||||
Hour: 'Hour'
|
||||
Hours: 'Hours'
|
||||
Minute: 'Minute'
|
||||
Minutes: 'Minutes'
|
||||
Second: 'Second'
|
||||
Seconds: 'Seconds'
|
||||
|
||||
# Format for signs
|
||||
# SiteName may be all, depending on sign
|
||||
# %position% = position of player, set by sign
|
||||
@@ -307,42 +317,36 @@ GUI:
|
||||
# You can set skulls of the player using the following
|
||||
# Remove the # to enable
|
||||
#Skull: '%Player%'
|
||||
Slot: 0
|
||||
Next:
|
||||
Item:
|
||||
Material: 'COMPASS'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Next'
|
||||
Slot: 1
|
||||
Last:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
Slot: 2
|
||||
Total:
|
||||
Item:
|
||||
Material: 'CHEST'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Total'
|
||||
Slot: 3
|
||||
Top:
|
||||
Item:
|
||||
Material: 'SIGN'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Top'
|
||||
Slot: 4
|
||||
Today:
|
||||
Item:
|
||||
Material: 'BOOK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Today'
|
||||
Slot: 5
|
||||
Shop:
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
@@ -351,7 +355,6 @@ GUI:
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
Slot: 6
|
||||
|
||||
# GUI for /vote url
|
||||
# And /vote if enabled in Config.yml
|
||||
@@ -387,6 +390,8 @@ GUI:
|
||||
Data: 0
|
||||
Amount: 1
|
||||
URLText: '%VoteUrl%'
|
||||
|
||||
VoteRewardBackButton: false
|
||||
# Customize /vote reward
|
||||
# Show players what you get when you vote on each site
|
||||
VoteReward:
|
||||
@@ -412,7 +417,6 @@ GUI:
|
||||
# Remove this line for no lore
|
||||
Lore:
|
||||
- '&4Line 1'
|
||||
Slot: 0
|
||||
VoteLast:
|
||||
Name: 'VoteLast: %player%'
|
||||
BackButton: true
|
||||
@@ -438,6 +442,11 @@ GUI:
|
||||
# Number of topvoters to display on page +9
|
||||
# 9 Slots on the botton are used for page buttons
|
||||
Size: 27
|
||||
# If true, /vote top will show player heads
|
||||
UseSkull: true
|
||||
# Item for player in GUI if use skull is false
|
||||
PlayerItem:
|
||||
Material: 'PAPER'
|
||||
VoteTotal:
|
||||
Name: 'VoteTotal: %player%'
|
||||
BackButton: true
|
||||
@@ -556,14 +565,14 @@ Shop:
|
||||
Cost: 3
|
||||
# Permission required, leave blank for no permission
|
||||
Permission: ''
|
||||
# Rewards to run if player buys succesfully
|
||||
# Limit how many times you can buy this
|
||||
#Limit: 3
|
||||
# Rewards to run if player buys successfully
|
||||
Rewards:
|
||||
Items:
|
||||
Diamond:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
# Slot
|
||||
Slot: 0
|
||||
Amount: 1
|
||||
|
||||
# ------------------------------------------------
|
||||
# Extra Rewards
|
||||
@@ -623,11 +632,18 @@ VoteParty:
|
||||
# Broadcast when vote party reached
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# List of commands to execute, these only execute once.
|
||||
# %player% does not work here
|
||||
Commands: []
|
||||
# Reward files to give
|
||||
Rewards: []
|
||||
# Rewards to give
|
||||
Rewards:
|
||||
Commands:
|
||||
- say %player%
|
||||
Items:
|
||||
DIAMOND:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Reset milestons at end of the month
|
||||
# Reset milestones at end of the month
|
||||
ResetMilestonesMonthly: false
|
||||
|
||||
MileStones:
|
||||
@@ -640,13 +656,13 @@ MileStones:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %milestone% milestone votes!'
|
||||
|
||||
|
||||
VoteStreak:
|
||||
# Valid options: Day, Week, Month
|
||||
Day:
|
||||
# Number of days in a row
|
||||
# Each day requires one vote
|
||||
# Add a - to give a reward for every multiple (e.g. 2-)
|
||||
# Add a - to give a reward for every multiple (e.g. 2- = 2,4,6,8, and so on)
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
@@ -674,13 +690,22 @@ VoteStreak:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: "&aYou voted for %Streak% %Type%'s in a row!"
|
||||
Requirement:
|
||||
# Require certain percentage of votes
|
||||
UsePercentage: false
|
||||
# Percentage requirements of votes
|
||||
# 50 = %50
|
||||
Day: 50
|
||||
Week: 50
|
||||
Month: 50
|
||||
|
||||
|
||||
# ONLY USE THIS FOR TITLES/SOUNDS AND OTHER EFFECTS
|
||||
# IT WILL ONLY RUN ONE TIME FOR ANY NUMBER OF OFFLINE VOTES
|
||||
# IT WILL ONLY RUN ONE TIME FOR ANY NUMBER OF OFFLINE VOTES (3 offline votes = 1 AnySiteReward)
|
||||
# Any reward files listed here are ran on vote of any site
|
||||
# It is recommended to add rewards to each site instead of here
|
||||
# Using forceoffline won't work here
|
||||
# Use EverySiteReward in VoteSites.yml for a global reward for each site
|
||||
AnySiteRewards: []
|
||||
|
||||
|
||||
@@ -689,12 +714,13 @@ AnySiteRewards: []
|
||||
# ------------------------------------------------
|
||||
|
||||
# Top voter blacklist
|
||||
# Hide these names from top voter lists
|
||||
BlackList:
|
||||
- 'Notch'
|
||||
|
||||
# If true players with the permission 'VotingPlugin.TopVoter.Ignore' will act
|
||||
# as if there name was added on the the blacklist above
|
||||
# This also applies for ops
|
||||
# This also applies for players with op
|
||||
TopVoterIgnorePermission: false
|
||||
|
||||
# /vote top default data displayed
|
||||
@@ -761,7 +787,7 @@ DailyAwards:
|
||||
|
||||
# ------------------------------------------------
|
||||
# Advanced
|
||||
# Most of these values can be left untouched
|
||||
# Most of these values can be left untouched for most setups
|
||||
# ------------------------------------------------
|
||||
|
||||
# Number of points to give on vote
|
||||
@@ -772,9 +798,12 @@ PointsOnVote: 1
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
DisableCheckOnWorldChange: false
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# Debug
|
||||
Debug: false
|
||||
@@ -807,31 +836,22 @@ RequestAPI:
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
# Only update in the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Clear cache on update, setting to true reduces performance
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clears cache for the player who voted only
|
||||
# Only effects if using mysql
|
||||
# Would recommend for some bungee setups
|
||||
ClearCacheOnVote: false
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
# Will also disable a few other warnings about vote sites
|
||||
DisableNoServiceSiteMessage: false
|
||||
|
||||
# Used in special cases
|
||||
# Much slower, but may work better
|
||||
AlternateUUIDLookup: false
|
||||
|
||||
# Shouldn't need to change this
|
||||
AutoKillInvs: true
|
||||
|
||||
# Count fake votes
|
||||
# If true fake votes will give points and totals
|
||||
CountFakeVotes: true
|
||||
@@ -847,9 +867,75 @@ PurgeOldData: false
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
|
||||
# If true, plugin will send scoreboards on some commands
|
||||
SendScoreboards: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note: It takes 30-40 minutes before being able to download the latest build
|
||||
# You can also use /av download
|
||||
AutoDownload: false
|
||||
|
||||
# Whether or not to disable update checks
|
||||
DisableUpdateChecking: false
|
||||
|
||||
# Allow transfer of vote points
|
||||
AllowVotePointTransfers: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
|
||||
# Disable checking permissions on tab complete
|
||||
DisableAdvancedTab: false
|
||||
|
||||
# Load command aliases, such as /avgui
|
||||
# Requires restart to take effect
|
||||
LoadCommandAliases: true
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe
|
||||
WaitUntilLoggedIn: true
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Mysql cache options
|
||||
# Clearing cache forces the plugin to pull from database
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# Clear cache on update, setting to true reduces update speed
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clear mysql 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
|
||||
|
||||
# ###############################################################
|
||||
# Deprecated options, don't recommend using any of these
|
||||
|
||||
# Whether or not to disable checking names on mojang, disable if you hit the rate limit
|
||||
# Shouldn't make a noticeable impact if set to false
|
||||
CheckNameMojang: false
|
||||
#CheckNameMojang: false
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get saved)
|
||||
CreateBackups: true
|
||||
# Shouldn't need to change this
|
||||
#AutoKillInvs: true
|
||||
|
||||
# Used in special cases
|
||||
# Much slower, but may work better
|
||||
# Not recommended in newer versions
|
||||
#AlternateUUIDLookup: false
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
#DisableCheckOnWorldChange: false
|
||||
@@ -28,11 +28,14 @@ VoteSites:
|
||||
# Most sites are 24 hours
|
||||
VoteDelay: 24
|
||||
|
||||
# Require waiting until votedelay time has pasted in order to accept vote
|
||||
WaitUntilVoteDelay: false
|
||||
|
||||
# Reset vote delay each day (for certain sites that do this)
|
||||
VoteDelayDaily: false
|
||||
|
||||
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
|
||||
# Setting this to true will execute the reward offline, NOT WHEN THE PLAYER IS OFFLINE
|
||||
# Setting this to true will execute the reward offline while the player is offline
|
||||
# This basiclly disables offline voting if set to true, don't misinterpret this option
|
||||
ForceOffline: false
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ main: com.Ben12345rocks.VotingPlugin.Main
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: Ben12345rocks
|
||||
softdepend: [AdvancedCore]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
vote:
|
||||
@@ -28,9 +27,6 @@ commands:
|
||||
votetop:
|
||||
description: See top voters
|
||||
aliases: vtop
|
||||
voteinfo:
|
||||
description: See player info
|
||||
aliases: vinfo
|
||||
votetoday:
|
||||
description: See who voted today
|
||||
aliases: vtoday
|
||||
@@ -58,21 +54,21 @@ commands:
|
||||
votestreak:
|
||||
description: A command
|
||||
aliases: vstreak
|
||||
votetogglebroadcast:
|
||||
description: A command
|
||||
aliases: vtogglebroadcast
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votegivereward:
|
||||
description: A command
|
||||
voteselectChoiceReward:
|
||||
votechoices:
|
||||
description: A command
|
||||
alaises: vchoices
|
||||
adminvotehelp:
|
||||
description: Open adminvote help
|
||||
aliases: avhelp
|
||||
adminvote?:
|
||||
description: Open adminvote help
|
||||
aliases: av?
|
||||
adminvoteconvert:
|
||||
description: A command
|
||||
adminvotereport:
|
||||
description: Command Alias
|
||||
aliases: avreport
|
||||
@@ -94,24 +90,15 @@ commands:
|
||||
adminvoterewards:
|
||||
description: Command Alias
|
||||
aliases: avrewards
|
||||
adminvotereward:
|
||||
description: Command Alias
|
||||
aliases: avreward
|
||||
adminvoteuuid:
|
||||
description: Command Alias
|
||||
aliases: avuuid
|
||||
adminvotereset:
|
||||
description: Command Alias
|
||||
aliases: avreset
|
||||
adminvotevotesite:
|
||||
description: Command Alias
|
||||
aliases: avvotesite
|
||||
adminvoteconfig:
|
||||
description: Command Alias
|
||||
aliases: avconfig
|
||||
adminvoteserverdata:
|
||||
description: Command Alias
|
||||
aliases: avserverdata
|
||||
adminvotesettotal:
|
||||
description: Command Alias
|
||||
aliases: avsettotal
|
||||
@@ -121,36 +108,20 @@ commands:
|
||||
adminvotevote:
|
||||
description: Command Alias
|
||||
aliases: [avvote, fakevote]
|
||||
adminvoteTriggerPlayerVoteEvent:
|
||||
description: Command Alias
|
||||
aliases: avTriggerPlayerVoteEvent
|
||||
adminvotesetpoints:
|
||||
description: Command Alias
|
||||
aliases: avsetpoints
|
||||
adminvoteaddpoints:
|
||||
description: Command Alias
|
||||
aliases: avaddpoints
|
||||
adminvotegui:
|
||||
description: Command Alias
|
||||
aliases: avgui
|
||||
votesetrequestmethod:
|
||||
description: Command Alias
|
||||
aliases: [vsetrequestmethod, setrequesetmethod]
|
||||
adminvotegivereward:
|
||||
description: Command Alias
|
||||
aliases: avgivereward
|
||||
adminvoteusers:
|
||||
description: Command Alias
|
||||
aliases: avusers
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
aliases: avClearTotal
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
aliases: avClearTotal
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
@@ -160,9 +131,6 @@ commands:
|
||||
adminvoteConvertFrom:
|
||||
description: Command Alias
|
||||
aliases: avConvertFrom
|
||||
adminvoteRemovePoints:
|
||||
description: Command Alias
|
||||
aliases: avRemovePoints
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
@@ -199,6 +167,30 @@ commands:
|
||||
adminvoteJavascript:
|
||||
description: Command Alias
|
||||
aliases: avJavascript
|
||||
adminvoteStatus:
|
||||
description: Command Alias
|
||||
aliases: avStatus
|
||||
adminvoteTest:
|
||||
description: Command Alias
|
||||
aliases: avTest
|
||||
adminvotePlaceholders:
|
||||
description: Command Alias
|
||||
aliases: avPlaceholders
|
||||
adminvoteDownloadJenkins:
|
||||
description: Command Alias
|
||||
aliases: avDownloadJenkins
|
||||
adminvoteForceVoteParty:
|
||||
description: Command Alias
|
||||
aliases: avForceVoteParty
|
||||
adminvoteUserEditValue:
|
||||
description: Command Alias
|
||||
aliases: avUserEditValue
|
||||
adminvoteSetRequestMethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
adminvoteUser:
|
||||
description: Command Alias
|
||||
aliases: avUser
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
@@ -218,4 +210,6 @@ permissions:
|
||||
VotingPlugin.NoRemind:
|
||||
description: Ignore vote reminding
|
||||
default: false
|
||||
VotingPlugin.Sign.Create:
|
||||
description: Permission to create sign
|
||||
|
||||
+100
-4
@@ -1,15 +1,17 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.14</version>
|
||||
<version>5.18</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
@@ -33,6 +35,34 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<versionRange>[1,)</versionRange>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -44,6 +74,25 @@
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>delombok</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@@ -92,7 +141,6 @@
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -108,6 +156,9 @@
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@@ -138,6 +189,31 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${user.home}/Documents/Test Server/plugins</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/target</directory>
|
||||
<includes>
|
||||
<include>${project.artifactId}.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@@ -165,7 +241,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -189,5 +265,25 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/VoteRoulette.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.mimimum.minecraft</groupId>
|
||||
<artifactId>SuperbVote</artifactId>
|
||||
<version>0.5.3</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/SuperbVote-0.5.3.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>MVdWPlaceholderAPI</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/MVdWPlaceholderAPI.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -18,8 +18,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
@@ -29,6 +29,7 @@ import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -119,7 +120,7 @@ public class Commands {
|
||||
|
||||
boolean requirePerms = Config.getInstance().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.adminVoteCommand) {
|
||||
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
|
||||
if (sender.hasPermission(cmdHandle.getPerm()) && requirePerms) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
} else {
|
||||
@@ -191,7 +192,7 @@ public class Commands {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&c&lCommand : Permissions (seperated by |)");
|
||||
|
||||
for (CommandHandler handle : plugin.voteCommand) {
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
|
||||
@@ -204,7 +205,7 @@ public class Commands {
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.adminVoteCommand) {
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
|
||||
@@ -240,7 +241,7 @@ public class Commands {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
|
||||
for (CommandHandler handle : plugin.voteCommand) {
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
@@ -249,7 +250,7 @@ public class Commands {
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.adminVoteCommand) {
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
@@ -321,9 +322,9 @@ public class Commands {
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterAllTimeScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
if (AdvancedCoreHook.getInstance().getOptions().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterAllTime.keySet());
|
||||
ArrayList<User> users = plugin.convertSet(plugin.getTopVoter(TopVoter.AllTime).keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
@@ -337,7 +338,7 @@ public class Commands {
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterAllTime.get(users.get(i)));
|
||||
plugin.getTopVoter(TopVoter.AllTime).get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
@@ -361,9 +362,9 @@ public class Commands {
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterDailyScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
if (AdvancedCoreHook.getInstance().getOptions().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterDaily.keySet());
|
||||
ArrayList<User> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Daily).keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
@@ -377,7 +378,7 @@ public class Commands {
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterDaily.get(users.get(i)));
|
||||
plugin.getTopVoter(TopVoter.Daily).get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
@@ -401,9 +402,9 @@ public class Commands {
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterMonthlyScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
if (AdvancedCoreHook.getInstance().getOptions().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterMonthly.keySet());
|
||||
ArrayList<User> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Monthly).keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
@@ -417,7 +418,7 @@ public class Commands {
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterMonthly.get(users.get(i)));
|
||||
plugin.getTopVoter(TopVoter.Monthly).get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
@@ -441,9 +442,9 @@ public class Commands {
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterWeeklyScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
if (AdvancedCoreHook.getInstance().getOptions().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
ArrayList<User> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
@@ -457,7 +458,7 @@ public class Commands {
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterWeekly.get(users.get(i)));
|
||||
plugin.getTopVoter(TopVoter.Weekly).get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
@@ -482,7 +483,7 @@ public class Commands {
|
||||
* the page
|
||||
*/
|
||||
public void sendVoteTodayScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
if (AdvancedCoreHook.getInstance().getOptions().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
|
||||
String[] voteToday = voteToday();
|
||||
@@ -535,7 +536,7 @@ public class Commands {
|
||||
}
|
||||
|
||||
public void updateVoteToday(ArrayList<User> users) {
|
||||
plugin.voteToday.clear();
|
||||
plugin.getVoteToday().clear();
|
||||
|
||||
for (User user : users) {
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
@@ -550,7 +551,7 @@ public class Commands {
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
plugin.voteToday.put(user, times);
|
||||
plugin.getVoteToday().put(user, times);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -590,6 +591,7 @@ public class Commands {
|
||||
* the vote site
|
||||
* @return the string
|
||||
*/
|
||||
@Deprecated
|
||||
public String voteCommandLastDate(User user, VoteSite voteSite) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time > 0) {
|
||||
@@ -600,11 +602,92 @@ public class Commands {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String voteCommandLastDuration(User user, VoteSite voteSite) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time > 0) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
|
||||
|
||||
Duration dur = Duration.between(lastVote, now);
|
||||
|
||||
long diffSecond = dur.getSeconds();
|
||||
int diffDays = (int) (diffSecond / 60 / 60 / 24);
|
||||
int diffHours = (int) (diffSecond / 60 / 60 - diffDays * 24);
|
||||
int diffMinutes = (int) (diffSecond / 60 - diffHours * 60 - diffDays * 24 * 60);
|
||||
int diffSeconds = (int) (diffSecond - diffMinutes * 60 - diffHours * 60 * 60 - diffDays * 24 * 60 * 60);
|
||||
|
||||
String info = "";
|
||||
if (diffDays == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsDay()), "amount", "" + diffDays);
|
||||
info += " ";
|
||||
} else if (diffDays > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsDays()), "amount", "" + diffDays);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffHours == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsHour()), "amount", "" + diffHours);
|
||||
info += " ";
|
||||
} else if (diffHours > 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsHours()), "amount", "" + diffHours);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffMinutes == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsMinute()), "amount", "" + diffMinutes);
|
||||
info += " ";
|
||||
} else if (diffMinutes > 1) {
|
||||
info += StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsMinutes()), "amount", "" + diffMinutes);
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffSeconds == 1) {
|
||||
info += StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsSecond()), "amount", "" + diffSeconds);
|
||||
} else {
|
||||
info += StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
Config.getInstance().getFormatTimeFormatsSeconds()), "amount", "" + diffSeconds);
|
||||
}
|
||||
|
||||
info = StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getFormatCommandsVoteLastLastVoted(), "times", info);
|
||||
|
||||
return info;
|
||||
}
|
||||
return Config.getInstance().getFormatCommandsVoteLastNeverVoted();
|
||||
}
|
||||
|
||||
public String voteCommandLastLine(User user, VoteSite voteSite) {
|
||||
String timeString = voteCommandLastDate(user, voteSite);
|
||||
String timeSince = voteCommandLastDuration(user, voteSite);
|
||||
|
||||
return config.getFormatCommandsVoteLastLine().replace("%Month% %Day%, %Year% %Hour%:%Minute% %ampm%", "%time%")
|
||||
.replace("%time%", timeString).replace("%SiteName%", voteSite.getDisplayName());
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("time", timeString);
|
||||
placeholders.put("SiteName", voteSite.getDisplayName());
|
||||
placeholders.put("timesince", timeSince);
|
||||
|
||||
return StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getFormatCommandsVoteLastLine(),
|
||||
placeholders);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -708,10 +791,10 @@ public class Commands {
|
||||
public String[] voteCommandTotal(User user) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
int daily = user.getDailyTotal();
|
||||
int weekly = user.getWeeklyTotal();
|
||||
int month = user.getMonthTotal();
|
||||
int all = user.getAllTimeTotal();
|
||||
int daily = user.getTotal(TopVoter.Daily);
|
||||
int weekly = user.getTotal(TopVoter.Weekly);
|
||||
int month = user.getTotal(TopVoter.Monthly);
|
||||
int all = user.getTotal(TopVoter.AllTime);
|
||||
|
||||
for (String s : config.getFormatCommandsVoteTotal()) {
|
||||
String str = StringUtils.getInstance().replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
|
||||
@@ -744,10 +827,10 @@ public class Commands {
|
||||
|
||||
for (String uuid : uuids) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
daily += user.getDailyTotal();
|
||||
weekly += user.getWeeklyTotal();
|
||||
month += user.getMonthTotal();
|
||||
all += user.getAllTimeTotal();
|
||||
daily += user.getTotal(TopVoter.Daily);
|
||||
weekly += user.getTotal(TopVoter.Weekly);
|
||||
month += user.getTotal(TopVoter.Monthly);
|
||||
all += user.getTotal(TopVoter.AllTime);
|
||||
}
|
||||
|
||||
for (String s : config.getFormatCommandsVoteTotalAll()) {
|
||||
@@ -776,7 +859,7 @@ public class Commands {
|
||||
|
||||
boolean requirePerms = config.getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.voteCommand) {
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote"));
|
||||
} else if (!requirePerms) {
|
||||
@@ -800,11 +883,11 @@ public class Commands {
|
||||
*/
|
||||
public String[] voteToday() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
for (User user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " + timeString);
|
||||
}
|
||||
}
|
||||
@@ -837,10 +920,10 @@ public class Commands {
|
||||
}
|
||||
if (user != null) {
|
||||
HashMap<String, String> phs = new HashMap<String, String>();
|
||||
phs.put("DailyTotal", "" + user.getDailyTotal());
|
||||
phs.put("WeekTotal", "" + user.getWeeklyTotal());
|
||||
phs.put("MonthTotal", "" + user.getMonthTotal());
|
||||
phs.put("Total", "" + user.getAllTimeTotal());
|
||||
phs.put("DailyTotal", "" + user.getTotal(TopVoter.Daily));
|
||||
phs.put("WeekTotal", "" + user.getTotal(TopVoter.Weekly));
|
||||
phs.put("MonthTotal", "" + user.getTotal(TopVoter.Monthly));
|
||||
phs.put("Total", "" + user.getTotal(TopVoter.AllTime));
|
||||
|
||||
sites = ArrayUtils.getInstance().replacePlaceHolder(sites, phs);
|
||||
}
|
||||
|
||||
+2
-3
@@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
@@ -55,14 +55,13 @@ public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (CommandHandler commandHandler : plugin.adminVoteCommand) {
|
||||
for (CommandHandler commandHandler : plugin.getAdminVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
+3
-4
@@ -7,7 +7,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
@@ -32,7 +32,6 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -50,9 +49,9 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.adminVoteCommand);
|
||||
handles.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
handles.addAll(plugin.voteCommand);
|
||||
handles.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : handles) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -47,7 +47,6 @@ public class CommandVote implements CommandExecutor {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -55,7 +54,7 @@ public class CommandVote implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
for (CommandHandler commandHandler : plugin.voteCommand) {
|
||||
for (CommandHandler commandHandler : plugin.getVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,11 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.EditGUI;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.EditGUIButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueBoolean;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueNumber;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueString;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
@@ -16,12 +21,10 @@ import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.InputMethod;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequestBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListener;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class AdminGUI {
|
||||
@@ -52,41 +55,34 @@ public class AdminGUI {
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("&cOnly enabled sites are listed in this section");
|
||||
lore.add("&cMiddle Click to create");
|
||||
buttons.add(new BInventoryButton("&cVoteSites", ArrayUtils.getInstance().convert(lore),
|
||||
buttons.add(new BInventoryButton("&cVoteSites",
|
||||
new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
ConfigVoteSites.getInstance().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openAdminGUIVoteSites(player);
|
||||
}
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
ConfigVoteSites.getInstance().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openAdminGUIVoteSites(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lore = new ArrayList<String>();
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE, 1, (short) 3)) {
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", new String[] {}, new ItemStack(Material.STONE, 1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().performCommand("av reload");
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -115,8 +111,6 @@ public class AdminGUI {
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
// lore.add("Rewards: " +
|
||||
// ArrayUtils.getInstance().makeStringList(voteSite.getRewards()));
|
||||
|
||||
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
@@ -143,7 +137,7 @@ public class AdminGUI {
|
||||
* the vote site
|
||||
*/
|
||||
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
|
||||
BInventory inv = new BInventory("VoteSite: " + voteSite.getDisplayName());
|
||||
EditGUI inv = new EditGUI("VoteSite: " + voteSite.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", voteSite);
|
||||
|
||||
inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {
|
||||
@@ -161,7 +155,8 @@ public class AdminGUI {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
VotiferEvent.playerVote(value, site.getServiceSite(), false);
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
@@ -169,137 +164,91 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetPriority", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("Priority", voteSite.getPriority()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestNumber(player, "" + voteSite.getPriority(), null, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
ConfigVoteSites.getInstance().setPriority(voteSite.getKey(), value.intValue());
|
||||
player.sendMessage("Set Priority");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().setPriority(voteSite.getKey(), num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
inv.addButton(new BInventoryButton("SetServiceSite", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("ServiceSite", voteSite.getServiceSite()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setServiceSite(siteName, value);
|
||||
player.sendMessage("Set ServiceSite");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setServiceSite(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
inv.addButton(new BInventoryButton("SetName", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("Name", voteSite.getDisplayName()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
ConfigVoteSites.getInstance().setDisplayName(voteSite.getKey(), value);
|
||||
player.sendMessage("Set name");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().setDisplayName(voteSite.getKey(), value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteURL", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("VoteURL", voteSite.getVoteURL()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getVoteURL(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteURL(siteName, value);
|
||||
player.sendMessage("Set VoteURL");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteURL(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteDelay", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelay", voteSite.getVoteDelay()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestNumber(player, "" + voteSite.getVoteDelay(), null, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelay(siteName, value.intValue());
|
||||
player.sendMessage("Set VoteDelay");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelay(siteName, num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("SetEnabled", new String[0], new ItemStack(Material.STONE)) {
|
||||
}));
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + ConfigVoteSites.getInstance().getVoteSiteEnabled(voteSite.getKey()),
|
||||
new BooleanListener() {
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setEnabled(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setEnabled(siteName, value);
|
||||
player.sendMessage("Set Enabled");
|
||||
plugin.reload();
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("ForceOffline", voteSite.isGiveOffline()) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setForceOffline(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("VoteDelayDaily", voteSite.isVoteDelayDaily()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelayDaily(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
@@ -12,6 +13,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardOptions;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
@@ -23,12 +26,11 @@ import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoterHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteShop.VoteShop;
|
||||
|
||||
public class PlayerGUIs {
|
||||
static PlayerGUIs instance = new PlayerGUIs();
|
||||
@@ -109,7 +111,8 @@ public class PlayerGUIs {
|
||||
&& !player.hasPermission("VotingPlugin.Mod"))
|
||||
|| (!player.hasPermission("VotingPlugin.Commands.Vote.GUI")
|
||||
&& !player.hasPermission("VotingPlugin.Player"))) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize(AdvancedCoreHook.getInstance().getFormatNoPerms()));
|
||||
player.sendMessage(
|
||||
StringUtils.getInstance().colorize(AdvancedCoreHook.getInstance().getOptions().getFormatNoPerms()));
|
||||
return;
|
||||
}
|
||||
setSelectedPlayer(player, user);
|
||||
@@ -156,34 +159,40 @@ public class PlayerGUIs {
|
||||
builder.setPlaceholders(placeholders);
|
||||
builder.setLore(ArrayUtils.getInstance().convert(lore));
|
||||
|
||||
inv.addButton(Config.getInstance().getVoteGUISlotSlot(slot), new BInventoryButton(builder) {
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
String cmd = Config.getInstance().getVoteGUISlotCommand(slot);
|
||||
User user = getSelectedPlayer(player);
|
||||
if (!cmd.equals("")) {
|
||||
player.performCommand(cmd);
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
openVoteURL(player);
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
openVoteNext(player, user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
openVoteLast(player, user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
openVoteTotal(player, user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
openVoteTop(player, null);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
openVoteToday(player);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
VoteShop.getInstance().voteShop(player);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Player player = event.getWhoClicked();
|
||||
String cmd = Config.getInstance().getVoteGUISlotCommand(slot);
|
||||
User user = getSelectedPlayer(player);
|
||||
if (!cmd.equals("")) {
|
||||
player.performCommand(cmd);
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
openVoteURL(player);
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
openVoteNext(player, user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
openVoteLast(player, user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
openVoteTotal(player, user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
openVoteTop(player, null);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
openVoteToday(player);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
openVoteShop(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
@@ -249,6 +258,103 @@ public class PlayerGUIs {
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (final String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
int limit = Config.getInstance().getIdentifierLimit(identifier);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPerm && limitPass) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (limitPass) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopPurchaseMsg(), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteStreak(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
@@ -326,12 +432,12 @@ public class PlayerGUIs {
|
||||
public void openVoteToday(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
for (User user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
|
||||
String msg = "&6" + user.getPlayerName() + " : " + voteSite.getDisplayName() + " : " + timeString;
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
String msg = "&6" + voteSite.getDisplayName() + " : " + timeString;
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(user.getPlayerName(), new String[] { msg },
|
||||
MiscUtils.getInstance().setSkullOwner(user.getOfflinePlayer())) {
|
||||
|
||||
@@ -363,47 +469,40 @@ public class PlayerGUIs {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
BInventory inv = null;
|
||||
Set<Entry<User, Integer>> users = null;
|
||||
String topVoter = "";
|
||||
if (top.equals(TopVoter.Monthly)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterMonthly();
|
||||
users = plugin.topVoterMonthly.entrySet();
|
||||
} else if (top.equals(TopVoter.Weekly)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterWeekly();
|
||||
users = plugin.topVoterWeekly.entrySet();
|
||||
} else if (top.equals(TopVoter.Daily)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterDaily();
|
||||
users = plugin.topVoterDaily.entrySet();
|
||||
} else {
|
||||
topVoter = Config.getInstance().getFormatTopVoterAllTime();
|
||||
users = plugin.topVoterAllTime.entrySet();
|
||||
}
|
||||
inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteTopName(),
|
||||
"topvoter", topVoter));
|
||||
|
||||
String topVoter = top.getName();
|
||||
users = plugin.getTopVoter(top).entrySet();
|
||||
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTopName(), "topvoter", topVoter));
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<User, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(MiscUtils.getInstance().setSkullOwner(entry.getKey().getOfflinePlayer()))
|
||||
.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore())
|
||||
.addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
if (Config.getInstance().isGuiVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(Config.getInstance().getGuiVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// ItemBuilder item = new ItemBuilder(clickEvent.getClickedItem());
|
||||
// String name = ChatColor.stripColor(item.getName()).split(":")[1].trim();
|
||||
String name = (String) clickEvent.getButton().getData("player");
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
User user = (User) getData("User");
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()));
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Config.getInstance().getGUIVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
@@ -427,6 +526,7 @@ public class PlayerGUIs {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
@@ -437,37 +537,17 @@ public class PlayerGUIs {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTotalName(), "player", user.getPlayerName()));
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalDayTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getDailyTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName())) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalWeekTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getWeeklyTotal())) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalMonthTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getMonthTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalAllTimeTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getAllTimeTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTotalBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
@@ -476,6 +556,7 @@ public class PlayerGUIs {
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
@@ -513,8 +594,6 @@ public class PlayerGUIs {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
|
||||
Player player = event.getWhoClicked();
|
||||
player.closeInventory();
|
||||
user.sendMessage(Commands.getInstance().voteURLs(user));
|
||||
|
||||
}
|
||||
@@ -538,11 +617,9 @@ public class PlayerGUIs {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
|
||||
if (Config.getInstance().commandsVoteRewardFromVoteURL
|
||||
if (Config.getInstance().isCommandsVoteRewardFromVoteURL()
|
||||
&& event.getClick().equals(ClickType.RIGHT)) {
|
||||
voteReward(player, voteSite.getKey());
|
||||
} else {
|
||||
@@ -637,31 +714,19 @@ public class PlayerGUIs {
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteRewardName());
|
||||
|
||||
if ((siteName == null) || (siteName == "")) {
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
try {
|
||||
ItemBuilder builder = voteSite.getItem();
|
||||
final VoteSite site = voteSite;
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builder) {
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand("vote reward " + site.getKey());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
voteReward(player, (String) getData("site"));
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}.addData("site", voteSite.getKey()));
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
@@ -675,10 +740,6 @@ public class PlayerGUIs {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -686,6 +747,16 @@ public class PlayerGUIs {
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().isVoteRewardBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
@@ -24,7 +24,6 @@ public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -36,7 +35,7 @@ public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.adminVoteCommand, sender, args,
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
|
||||
+4
-5
@@ -11,8 +11,8 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
@@ -32,7 +32,6 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -54,9 +53,9 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.adminVoteCommand);
|
||||
cmdHandlers.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
cmdHandlers.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance()
|
||||
.getTabCompleteOptions();
|
||||
|
||||
+2
-3
@@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
@@ -25,7 +25,6 @@ public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
@@ -37,7 +36,7 @@ public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.voteCommand, sender, args,
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
|
||||
@@ -9,9 +9,14 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.AnnotationHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.ConfigDataBoolean;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.ConfigDataDouble;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.ConfigDataInt;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Annotation.ConfigDataString;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFile;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -34,9 +39,233 @@ public class Config extends YMLFile {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
@ConfigDataString(
|
||||
path = "Format.Commands.Vote.ToggleBroadcasts.Enabled", defaultValue = "&cYou will now see vote broadcasts"
|
||||
)
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastEnabled;
|
||||
|
||||
@ConfigDataString(
|
||||
path = "Format.Commands.Vote.ToggleBroadcasts.Disabled",
|
||||
defaultValue = "&cYou will no longer see vote broadcasts"
|
||||
)
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastDisabled;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.VoteRewardFromVoteURL")
|
||||
@Getter
|
||||
private boolean commandsVoteRewardFromVoteURL = false;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastTimeFormat;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLine;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.NeverVoted", defaultValue = "Never voted")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastNeverVoted;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.LastVoted", defaultValue = "%times% ago")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLastVoted;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Days", defaultValue = "Days")
|
||||
@Getter
|
||||
private String formatTimeFormatsDays;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Day", defaultValue = "Day")
|
||||
@Getter
|
||||
private String formatTimeFormatsDay;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hours", defaultValue = "Hours")
|
||||
@Getter
|
||||
private String formatTimeFormatsHours;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hour", defaultValue = "Hour")
|
||||
@Getter
|
||||
private String formatTimeFormatsHour;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minutes", defaultValue = "Minutes")
|
||||
@Getter
|
||||
private String formatTimeFormatsMinutes;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minute", defaultValue = "Minute")
|
||||
@Getter
|
||||
private String formatTimeFormatsMinute;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Seconds", defaultValue = "Seconds")
|
||||
@Getter
|
||||
private String formatTimeFormatsSeconds;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Second", defaultValue = "Second")
|
||||
@Getter
|
||||
private String formatTimeFormatsSecond;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.DisableVoteRewardGUIs")
|
||||
@Getter
|
||||
private boolean commandsDisableVoteRewardGUIs;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysUpdate")
|
||||
@Getter
|
||||
private boolean alwaysUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UpdateWithPlayersOnlineOnly")
|
||||
@Getter
|
||||
private boolean updateWithPlayersOnlineOnly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AddTotals")
|
||||
@Getter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@Getter
|
||||
private String allSitesRewardPath = "AllSites";
|
||||
|
||||
@ConfigDataBoolean(path = "AlternateUUIDLookup")
|
||||
@Getter
|
||||
private boolean alternateUUIDLookup = false;
|
||||
|
||||
@Getter
|
||||
private String anySiteRewardsPath = "AnySiteRewards";
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.BroadcastVote")
|
||||
@Getter
|
||||
private boolean broadcastVotesEnabled = true;
|
||||
|
||||
@ConfigDataBoolean(path = "clearCacheOnUpdate")
|
||||
@Getter
|
||||
private boolean clearCacheOnUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ClearCacheOnVote")
|
||||
@Getter
|
||||
private boolean clearCacheOnVote = false;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Best")
|
||||
@Getter
|
||||
private boolean commandsUseGUIBest = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Last")
|
||||
@Getter
|
||||
private boolean commandsUseGUILast = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Next")
|
||||
@Getter
|
||||
private boolean commandsUseGUINext = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Streak")
|
||||
@Getter
|
||||
private boolean commandsUseGUIStreak = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Today")
|
||||
@Getter
|
||||
private boolean commandsUseGUIToday = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.TopVoter")
|
||||
@Getter
|
||||
private boolean commandsUseGUITopVoter = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Total")
|
||||
@Getter
|
||||
private boolean commandsUseGUITotal = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.UseGUI.Vote")
|
||||
@Getter
|
||||
private boolean commandsUseGUIVote = true;
|
||||
|
||||
@ConfigDataBoolean(path = "CountFakeVotes")
|
||||
@Getter
|
||||
private boolean countFakeVotes = true;
|
||||
|
||||
@ConfigDataBoolean(path = "GUI.VoteRewardBackButton")
|
||||
@Getter
|
||||
private boolean voteRewardBackButton = false;
|
||||
|
||||
@ConfigDataInt(path = "ConvertDelay", defaultValue = 30000)
|
||||
@Getter
|
||||
private int convertDelay;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableDailyRewards")
|
||||
@Getter
|
||||
private boolean enableDailyRewards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableUpdateChecking")
|
||||
@Getter
|
||||
private boolean disableUpdateChecking = false;
|
||||
|
||||
@ConfigDataInt(path = "DelayBetweenUpdates")
|
||||
@Getter
|
||||
private int delayBetweenUpdates = 3;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableNoServiceSiteMessage")
|
||||
@Getter
|
||||
private boolean disableNoServiceSiteMessage = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableAdvancedTab")
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
|
||||
@Getter
|
||||
private String firstVoteRewardsPath = "FirstVote";
|
||||
|
||||
@ConfigDataBoolean(path = "LogVotesToFile")
|
||||
@Getter
|
||||
private boolean logVotesToFile = false;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableMonthlyAwards")
|
||||
@Getter
|
||||
private boolean enableMonthlyAwards = false;
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
|
||||
@ConfigDataBoolean(path = "EnableWeeklyAwards")
|
||||
@Getter
|
||||
private boolean enableWeeklyAwards = false;
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Day")
|
||||
@Getter
|
||||
private double voteStreakRequirementDay = 50;
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Week")
|
||||
@Getter
|
||||
private double voteStreakRequirementWeek = 50;
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Month")
|
||||
@Getter
|
||||
private double voteStreakRequirementMonth = 50;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteStreak.Requirement.UsePercentage")
|
||||
@Getter
|
||||
private boolean voteStreakRequirementUsePercentage = false;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadCommandAliases")
|
||||
@Getter
|
||||
private boolean loadCommandAliases = true;
|
||||
|
||||
@ConfigDataBoolean(path = "GUI.VoteTop.UseSkull")
|
||||
@Getter
|
||||
private boolean guiVoteTopUseSkull = true;
|
||||
|
||||
@ConfigDataString(path = "GUI.VoteTop.PlayerItem.Material")
|
||||
@Getter
|
||||
private String guiVoteTopPlayerItemMaterial = "PAPER";
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
|
||||
@Getter
|
||||
private int formatPageSize = 10;
|
||||
|
||||
/**
|
||||
* Instantiates a new config.
|
||||
@@ -45,68 +274,6 @@ public class Config extends YMLFile {
|
||||
super(new File(Main.plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Enabled", defaultValue = "&cYou will now see vote broadcasts")
|
||||
public String formatCommandsVoteToggleBroadcastEnabled;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Disabled", defaultValue = "&cYou will no longer see vote broadcasts")
|
||||
public String formatCommandsVoteToggleBroadcastDisabled;
|
||||
|
||||
@ConfigDataBoolean(path = "Commands.VoteRewardFromVoteURL", defaultValue = false)
|
||||
public boolean commandsVoteRewardFromVoteURL;
|
||||
|
||||
/**
|
||||
* Allow un joined.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean allowUnJoined() {
|
||||
return getData().getBoolean("AllowUnjoined");
|
||||
}
|
||||
|
||||
public boolean getAddTotals() {
|
||||
return getData().getBoolean("AddTotals", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the all sites reward.
|
||||
*
|
||||
* @return the all sites reward
|
||||
*/
|
||||
public String getAllSitesRewardPath() {
|
||||
return "AllSites";
|
||||
}
|
||||
|
||||
public boolean getAlternateUUIDLookup() {
|
||||
return getData().getBoolean("AlternateUUIDLookup");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
* @return the rewards
|
||||
*/
|
||||
public String getAnySiteRewardsPath() {
|
||||
return "AnySiteRewards";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the auto create vote sites.
|
||||
*
|
||||
* @return the auto create vote sites
|
||||
*/
|
||||
public boolean getAutoCreateVoteSites() {
|
||||
return getData().getBoolean("AutoCreateVoteSites");
|
||||
}
|
||||
|
||||
public boolean getAutoDownload() {
|
||||
return getData().getBoolean("AutoDownload");
|
||||
}
|
||||
|
||||
public boolean getAutoKillInvs() {
|
||||
return getData().getBoolean("AutoKillInvs", true);
|
||||
}
|
||||
|
||||
public ConfigurationSection getBackButton() {
|
||||
return getData().getConfigurationSection("BackButton");
|
||||
}
|
||||
@@ -121,67 +288,6 @@ public class Config extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broad cast votes enabled.
|
||||
*
|
||||
* @return the broad cast votes enabled
|
||||
*/
|
||||
public boolean getBroadCastVotesEnabled() {
|
||||
return getData().getBoolean("BroadcastVote", true);
|
||||
}
|
||||
|
||||
public boolean getCheckNameMojang() {
|
||||
return getData().getBoolean("CheckNameMojang", true);
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnUpdate() {
|
||||
return getData().getBoolean("ClearCacheOnUpdate");
|
||||
}
|
||||
|
||||
public boolean getClearCacheOnVote() {
|
||||
return getData().getBoolean("ClearCacheOnVote");
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIBest() {
|
||||
return getData().getBoolean("Commands.UseGUI.Best");
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUILast() {
|
||||
return getData().getBoolean("Commands.UseGUI.Last", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUINext() {
|
||||
return getData().getBoolean("Commands.UseGUI.Next", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIStreak() {
|
||||
return getData().getBoolean("Commands.UseGUI.Streak");
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIToday() {
|
||||
return getData().getBoolean("Commands.UseGUI.Today", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUITopVoter() {
|
||||
return getData().getBoolean("Commands.UseGUI.TopVoter", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUITotal() {
|
||||
return getData().getBoolean("Commands.UseGUI.Total", true);
|
||||
}
|
||||
|
||||
public boolean getCommandsUseGUIVote() {
|
||||
return getData().getBoolean("Commands.UseGUI.Vote", true);
|
||||
}
|
||||
|
||||
public int getConvertDelay() {
|
||||
return getData().getInt("ConvertDelay", 30000);
|
||||
}
|
||||
|
||||
public boolean getCountFakeVotes() {
|
||||
return getData().getBoolean("CountFakeVotes", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative reward enabled.
|
||||
*
|
||||
@@ -240,15 +346,6 @@ public class Config extends YMLFile {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily awards enabled.
|
||||
*
|
||||
* @return the daily awards enabled
|
||||
*/
|
||||
public boolean getDailyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableDailyAwards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily possible reward places.
|
||||
*
|
||||
@@ -263,53 +360,6 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public String getDataStorage() {
|
||||
return getData().getString("DataStorage", "FLAT");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the debug enabled.
|
||||
*
|
||||
* @return the debug enabled
|
||||
*/
|
||||
public boolean getDebugEnabled() {
|
||||
return getData().getBoolean("Debug");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the debug info ingame.
|
||||
*
|
||||
* @return the debug info ingame
|
||||
*/
|
||||
public boolean getDebugInfoIngame() {
|
||||
return getData().getBoolean("DebugInfoIngame");
|
||||
}
|
||||
|
||||
public int getDelayBetweenUpdates() {
|
||||
return getData().getInt("DelayBetweenUpdates", 3);
|
||||
}
|
||||
|
||||
public boolean getDisableCheckOnWorldChange() {
|
||||
return getData().getBoolean("DisableCheckOnWorldChange");
|
||||
}
|
||||
|
||||
public boolean getDisableNoServiceSiteMessage() {
|
||||
return getData().getBoolean("DisableNoServiceSiteMessage");
|
||||
}
|
||||
|
||||
public boolean getExtraDebug() {
|
||||
return getData().getBoolean("ExtraDebug");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first vote rewards.
|
||||
*
|
||||
* @return the first vote rewards
|
||||
*/
|
||||
public String getFirstVoteRewardsPath() {
|
||||
return "FirstVote";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broad cast msg.
|
||||
*
|
||||
@@ -376,15 +426,6 @@ public class Config extends YMLFile {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote last line.
|
||||
*
|
||||
* @return the commands vote last line
|
||||
*/
|
||||
public String getFormatCommandsVoteLastLine() {
|
||||
return getData().getString("Format.Commands.Vote.Last.Line", "&3%SiteName%: &6%time%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote last title.
|
||||
*
|
||||
@@ -574,15 +615,6 @@ public class Config extends YMLFile {
|
||||
return getData().getString("Format.NotNumber", "&cError on &6%arg%&c, number expected!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the page size.
|
||||
*
|
||||
* @return the page size
|
||||
*/
|
||||
public int getFormatPageSize() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public String getFormatPrevPage() {
|
||||
return getData().getString("Format.PrevPage", "&aPrevious Page");
|
||||
}
|
||||
@@ -820,6 +852,22 @@ public class Config extends YMLFile {
|
||||
return getData().getConfigurationSection("GUI.VoteTotal.DayTotal.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getGUIVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getGUIVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getGUIVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getGUIVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getGUIVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteTotalMonthTotalItem() {
|
||||
return getData().getConfigurationSection("GUI.VoteTotal.MonthTotal.Item");
|
||||
}
|
||||
@@ -852,17 +900,8 @@ public class Config extends YMLFile {
|
||||
return getData().getInt("Shop." + identifier + ".Cost");
|
||||
}
|
||||
|
||||
public String getIdentifierFromSlot(int slot) {
|
||||
for (String identifier : getIdentifiers()) {
|
||||
if (getIdentifierSlot(identifier) == slot) {
|
||||
return identifier;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getIdentifierItemAmount(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Item.Amount");
|
||||
public int getIdentifierLimit(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Limit", -1);
|
||||
}
|
||||
|
||||
public String getIdentifierRewardsPath(String identifier) {
|
||||
@@ -882,8 +921,19 @@ public class Config extends YMLFile {
|
||||
return getData().getConfigurationSection("Shop." + identifier);
|
||||
}
|
||||
|
||||
public int getIdentifierSlot(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Slot");
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return getLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return getLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return getLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoterAllTime() {
|
||||
@@ -902,24 +952,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("LoadTopVoter.Weekly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log debug to file.
|
||||
*
|
||||
* @return the log debug to file
|
||||
*/
|
||||
public boolean getLogDebugToFile() {
|
||||
return getData().getBoolean("LogDebugToFile", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the log votes to file.
|
||||
*
|
||||
* @return the log votes to file
|
||||
*/
|
||||
public boolean getLogVotesToFile() {
|
||||
return getData().getBoolean("LogVotesToFile");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
*
|
||||
@@ -963,15 +995,6 @@ public class Config extends YMLFile {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly awards enabled.
|
||||
*
|
||||
* @return the monthly awards enabled
|
||||
*/
|
||||
public boolean getMonthlyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableMonthlyAwards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
@@ -985,10 +1008,6 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getMySql() {
|
||||
return getData().getConfigurationSection("MySQL");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
@@ -1024,15 +1043,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("ResetMilestonesMonthly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the send scoreboards.
|
||||
*
|
||||
* @return the send scoreboards
|
||||
*/
|
||||
public boolean getSendScoreboards() {
|
||||
return getData().getBoolean("SendScoreboards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the store top voters daily.
|
||||
*
|
||||
@@ -1068,10 +1078,6 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("TopVoterIgnorePermission");
|
||||
}
|
||||
|
||||
public int getUserVotesRequired() {
|
||||
return getData().getInt("VoteParty.UserVotesRequired");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
@@ -1121,7 +1127,7 @@ public class Config extends YMLFile {
|
||||
* @return the vote GUI slot slot
|
||||
*/
|
||||
public int getVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("GUI.VoteGUI." + slot + ".Slot");
|
||||
return getData().getInt("GUI.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
@@ -1167,13 +1173,8 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.ResetMonthly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party rewards.
|
||||
*
|
||||
* @return the vote party rewards
|
||||
*/
|
||||
public String getVotePartyRewardsPath() {
|
||||
return "VoteParty.Rewards";
|
||||
public int getVotePartyUserVotesRequired() {
|
||||
return getData().getInt("VoteParty.UserVotesRequired");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1379,15 +1380,6 @@ public class Config extends YMLFile {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly awards enabled.
|
||||
*
|
||||
* @return the weekly awards enabled
|
||||
*/
|
||||
public boolean getWeeklyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableWeeklyAwards");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly possible reward places.
|
||||
*
|
||||
@@ -1401,100 +1393,13 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("Config.yml", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the allow un joined.
|
||||
*
|
||||
* @param value
|
||||
* the new allow un joined
|
||||
*/
|
||||
public void setAllowUnJoined(boolean value) {
|
||||
getData().set("AllowUnjoined", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rewards.
|
||||
*
|
||||
* @param rewards
|
||||
* the new rewards
|
||||
*/
|
||||
public void setAnySiteRewards(ArrayList<String> rewards) {
|
||||
getData().set("AnySiteRewards", rewards);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the broadcast vote enabled.
|
||||
*
|
||||
* @param value
|
||||
* the new broadcast vote enabled
|
||||
*/
|
||||
public void setBroadcastVoteEnabled(boolean value) {
|
||||
getData().set("BroadcastVote", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug enabled.
|
||||
*
|
||||
* @param value
|
||||
* the new debug enabled
|
||||
*/
|
||||
public void setDebugEnabled(boolean value) {
|
||||
getData().set("Debug", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the debug info ingame.
|
||||
*
|
||||
* @param value
|
||||
* the new debug info ingame
|
||||
*/
|
||||
public void setDebugInfoIngame(boolean value) {
|
||||
getData().set("DebugInfoIngame", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the top voter awards enabled.
|
||||
*
|
||||
* @param value
|
||||
* the new top voter awards enabled
|
||||
*/
|
||||
public void setTopVoterAwardsEnabled(boolean value) {
|
||||
getData().set("TopVoterAwards", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingEnabled(boolean value) {
|
||||
getData().set("VoteReminding.Enabled", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRemindDelay(int value) {
|
||||
getData().set("VoteReminding.RemindDelay", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRemindOnLogin(boolean value) {
|
||||
getData().set("VoteReminding.RemindOnLogin", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRemindOnlyOnce(boolean value) {
|
||||
getData().set("VoteReminding.RemindOnlyOnce", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteRemindingRewards(ArrayList<String> value) {
|
||||
getData().set("VoteReminding.Rewards", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* the site name
|
||||
*/
|
||||
public void generateVoteSite(String siteName) {
|
||||
if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
if (Config.getInstance().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName
|
||||
@@ -252,6 +252,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(siteName).getString("VoteURL");
|
||||
}
|
||||
|
||||
public boolean getWaitUntilVoteDelay(String siteName) {
|
||||
return getData(siteName).getBoolean("WaitUntilVoteDelay", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is service site good.
|
||||
*
|
||||
@@ -353,6 +357,11 @@ public class ConfigVoteSites extends YMLFile {
|
||||
set(siteName, "Enabled", disabled);
|
||||
}
|
||||
|
||||
public void setForceOffline(String siteName, boolean value) {
|
||||
set(siteName, "ForceOffline", value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
@@ -401,6 +410,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
public void setVoteDelayDaily(String siteName, boolean value) {
|
||||
set(siteName, "VoteDelayDaily", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -78,7 +78,7 @@ public class ServerData {
|
||||
getData().set("Signs." + count + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
saveData();
|
||||
plugin.signs.add(new SignHandler("" + count, getSignLocation("" + count), getSignData("" + count),
|
||||
plugin.getSigns().add(new SignHandler("" + count, getSignLocation("" + count), getSignData("" + count),
|
||||
getSignPosition("" + count)));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(Main plugin) {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player login.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (event.getPlayer() == null
|
||||
|| (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() == null)) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player != null) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
if (user.getData().hasData()) {
|
||||
// give offline vote (if they voted
|
||||
// offline)
|
||||
|
||||
user.offVote();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}, 20L);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerReceivePointsEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private User player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int points;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
public PlayerReceivePointsEvent(User user, int points) {
|
||||
super(true);
|
||||
setPlayer(user);
|
||||
setPoints(points);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+15
-39
@@ -5,11 +5,14 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteAllSitesEvent extends Event {
|
||||
public class PlayerSpecialRewardEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
@@ -23,19 +26,26 @@ public class PlayerVoteAllSitesEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private User user;
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private SpecialRewardType type;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteAllSitesEvent(User user) {
|
||||
super();
|
||||
public PlayerSpecialRewardEvent(User user, SpecialRewardType type) {
|
||||
super(true);
|
||||
setType(type);
|
||||
setUser(user);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
@@ -43,38 +53,4 @@ public class PlayerVoteAllSitesEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* the user to set
|
||||
*/
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,9 @@ import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
@@ -23,24 +26,36 @@ public class PlayerVoteEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** The player. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String player;
|
||||
|
||||
/** The vote site. */
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername) {
|
||||
super();
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean realVote = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
setPlayer(voteUsername);
|
||||
setVoteSite(voteSite);
|
||||
setRealVote(realVote);
|
||||
setServiceSite(serviceSite);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
@@ -48,55 +63,4 @@ public class PlayerVoteEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site.
|
||||
*
|
||||
* @return the vote site
|
||||
*/
|
||||
public VoteSite getVoteSite() {
|
||||
return voteSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
public void setPlayer(String voteUsername) {
|
||||
this.player = voteUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote site.
|
||||
*
|
||||
* @param voteSite
|
||||
* the new vote site
|
||||
*/
|
||||
public void setVoteSite(VoteSite voteSite) {
|
||||
this.voteSite = voteSite;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, MILESTONE, VOTESTREAK, FIRSTVOTE;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@Getter
|
||||
private String type = "";
|
||||
|
||||
public SpecialRewardType setAmount(int num) {
|
||||
amount = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpecialRewardType setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package com.Ben12345rocks.VotingPlugin.Events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
@@ -21,16 +24,16 @@ public class VotePartyEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public VotePartyEvent() {
|
||||
super();
|
||||
super(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
@@ -38,23 +41,4 @@ public class VotePartyEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class VotiferEvent implements Listener {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
private static Object object = new Object();
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL) {
|
||||
playerVote(playerName, voteSiteURL, true);
|
||||
}
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL, final boolean realVote) {
|
||||
|
||||
if (!config.allowUnJoined() && !PlayerUtils.getInstance().isValidUser(playerName)) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(voteSiteURL);
|
||||
if (voteSite == null) {
|
||||
if (!Config.getInstance().getDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + voteSiteURL + "'");
|
||||
plugin.getLogger().warning(
|
||||
"Please read here on how to fix it: https://github.com/Ben12345rocks/VotingPlugin/wiki/Common-Problems");
|
||||
|
||||
ArrayList<String> services = new ArrayList<String>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger()
|
||||
.warning("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
|
||||
// vote party
|
||||
VoteParty.getInstance().vote(user, realVote);
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (config.getBroadCastVotesEnabled()) {
|
||||
if (!Config.getInstance().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
user.setTime(voteSite);
|
||||
|
||||
OtherVoteReward.getInstance().checkFirstVote(user);
|
||||
|
||||
if (user.isReminded()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
|
||||
if (user.isOnline() || voteSite.isGiveOffline()) {
|
||||
user.playerVote(voteSite, true, false);
|
||||
user.closeInv();
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(user.getOfflineVotes()));
|
||||
plugin.debug(
|
||||
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if (Config.getInstance().getCountFakeVotes() || realVote) {
|
||||
if (Config.getInstance().getAddTotals()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
|
||||
OtherVoteReward.getInstance().checkAllSites(user);
|
||||
OtherVoteReward.getInstance().checkCumualativeVotes(user);
|
||||
OtherVoteReward.getInstance().checkMilestone(user);
|
||||
|
||||
if (Config.getInstance().getClearCacheOnVote()) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().removePlayer(user.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VotiferEvent(Main plugin) {
|
||||
VotiferEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onVotiferEvent(VotifierEvent event) {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
final String voteSite = vote.getServiceName();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Recieved a vote from '" + voteSite + "' by player '" + voteUsername + "'!");
|
||||
|
||||
plugin.debug("PlayerUsername: " + voteUsername);
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String voteSiteName = plugin.getVoteSiteName(voteSite);
|
||||
|
||||
ArrayList<String> sites = configVoteSites.getVoteSitesNames();
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteName) && Config.getInstance().getAutoCreateVoteSites()) {
|
||||
plugin.getLogger()
|
||||
.warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
} else if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
plugin.getLogger().warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName), voteUsername);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
playerVote(voteUsername, voteSite, true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -45,7 +45,7 @@ public class BlockBreak implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
if (sign.getLocation().equals(loc)) {
|
||||
sign.removeSign();
|
||||
sign.setValid(false);
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.Ben12345rocks.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.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.CommandLoader;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerCommandSendListener implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static Main plugin;
|
||||
|
||||
public PlayerCommandSendListener(Main plugin) {
|
||||
PlayerCommandSendListener.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTab(PlayerCommandSendEvent event) {
|
||||
if (Config.getInstance().isDisableAdvancedTab()) {
|
||||
return;
|
||||
}
|
||||
ArrayList<String> removeCmds = new ArrayList<String>();
|
||||
ArrayList<String> whiteListed = new ArrayList<String>();
|
||||
for (String cmd : event.getCommands()) {
|
||||
if (CommandLoader.getInstance().isVotingPluginCommand(event.getPlayer(), cmd)) {
|
||||
if (!CommandLoader.getInstance().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);
|
||||
}
|
||||
}
|
||||
}
|
||||
event.getCommands().removeAll(removeCmds);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -44,7 +44,7 @@ public class PlayerInteract implements Listener {
|
||||
// plugin.debug("Checking for sign click");
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
// plugin.debug(player.getName() + " right clicked a sign");
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.AdvancedCoreLoginEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UserStorage;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
@SuppressWarnings("unused")
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(Main plugin) {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player login.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(AdvancedCoreLoginEvent event) {
|
||||
if (event.getPlayer() == null || (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() == null)) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
if (user.getData().hasData()) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.SpecialRewards.SpecialRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class PlayerVoteListener implements Listener {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
private static Object object = new Object();
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerVoteListener(Main plugin) {
|
||||
PlayerVoteListener.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onplayerVote(PlayerVoteEvent event) {
|
||||
String playerName = event.getPlayer();
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName)) {
|
||||
if (!config.isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VoteSite voteSite = event.getVoteSite();
|
||||
|
||||
// check valid service sites
|
||||
if (voteSite == null) {
|
||||
if (!Config.getInstance().isDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + event.getServiceSite() + "'");
|
||||
plugin.getLogger().warning(
|
||||
"Please read here on how to fix it: https://github.com/Ben12345rocks/VotingPlugin/wiki/Common-Problems");
|
||||
|
||||
ArrayList<String> services = new ArrayList<String>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger()
|
||||
.warning("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
user.updateName();
|
||||
|
||||
if (Config.getInstance().isClearCacheOnVote()) {
|
||||
user.clearCache();
|
||||
}
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
|
||||
// vote party
|
||||
VoteParty.getInstance().vote(user, event.isRealVote());
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (config.isBroadcastVotesEnabled()) {
|
||||
if (!Config.getInstance().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
user.setTime(voteSite);
|
||||
|
||||
// check first vote rewards
|
||||
SpecialRewards.getInstance().checkFirstVote(user);
|
||||
|
||||
if (user.isReminded()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
|
||||
if ((user.isOnline() || voteSite.isGiveOffline())
|
||||
&& AdvancedCoreHook.getInstance().getOptions().isProcessRewards()) {
|
||||
user.playerVote(voteSite, true, false);
|
||||
user.closeInv();
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
plugin.debug(
|
||||
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if (Config.getInstance().isCountFakeVotes() || event.isRealVote()) {
|
||||
if (Config.getInstance().isAddTotals()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
|
||||
user.checkDayVoteStreak();
|
||||
|
||||
// other rewards
|
||||
SpecialRewards.getInstance().checkAllSites(user);
|
||||
SpecialRewards.getInstance().checkCumualativeVotes(user);
|
||||
SpecialRewards.getInstance().checkMilestone(user);
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class VotiferEvent implements Listener {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VotiferEvent(Main plugin) {
|
||||
VotiferEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onVotiferEvent(VotifierEvent event) {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
final String voteSite = vote.getServiceName();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Recieved a vote from '" + voteSite + "' by player '" + voteUsername + "'!");
|
||||
|
||||
plugin.debug("PlayerUsername: " + voteUsername);
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String voteSiteName = plugin.getVoteSiteName(voteSite);
|
||||
|
||||
ArrayList<String> sites = configVoteSites.getVoteSitesNames();
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteName) && Config.getInstance().isAutoCreateVoteSites()) {
|
||||
plugin.getLogger()
|
||||
.warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
} else if (Config.getInstance().isAutoCreateVoteSites()) {
|
||||
plugin.getLogger().warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName), voteUsername,
|
||||
voteSite, true);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -16,6 +16,7 @@ import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -25,10 +26,16 @@ import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.NMSManager.NMSManager;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.Reward;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.Injected.RewardInjectInt;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.EditGUIButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueNumber;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Javascript.JavascriptPlaceholderRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Logger.Logger;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Metrics.BStatsMetrics;
|
||||
@@ -45,22 +52,30 @@ import com.Ben12345rocks.VotingPlugin.Commands.TabCompleter.VoteTabCompleter;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.BlockBreak;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerInteract;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerJoinEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.SignChange;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotingPluginUpdateEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.BlockBreak;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.PlayerCommandSendListener;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.PlayerInteract;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.PlayerJoinEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.PlayerVoteListener;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.SignChange;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Listeners.VotingPluginUpdateEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.Signs;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoterHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Updater.CheckUpdate;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.Util.Updater.CheckUpdate;
|
||||
import com.Ben12345rocks.VotingPlugin.Util.PlaceHolders.MVdWPlaceholders;
|
||||
import com.Ben12345rocks.VotingPlugin.Util.PlaceHolders.PlaceHolders;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The Class Main.
|
||||
*/
|
||||
@@ -75,47 +90,49 @@ public class Main extends JavaPlugin {
|
||||
/** The plugin. */
|
||||
public static Main plugin;
|
||||
|
||||
/** The top voter monthly. */
|
||||
public LinkedHashMap<User, Integer> topVoterAllTime;
|
||||
@Getter
|
||||
private LinkedHashMap<TopVoter, LinkedHashMap<User, Integer>> topVoter;
|
||||
|
||||
/** The top voter monthly. */
|
||||
public LinkedHashMap<User, Integer> topVoterMonthly;
|
||||
@Getter
|
||||
@Setter
|
||||
private Updater updater;
|
||||
|
||||
/** The top voter weekly. */
|
||||
public LinkedHashMap<User, Integer> topVoterWeekly;
|
||||
@Getter
|
||||
@Setter
|
||||
private ArrayList<CommandHandler> voteCommand;
|
||||
|
||||
/** The top voter daily. */
|
||||
public LinkedHashMap<User, Integer> topVoterDaily;
|
||||
@Getter
|
||||
@Setter
|
||||
private ArrayList<CommandHandler> adminVoteCommand;
|
||||
|
||||
/** The updater. */
|
||||
public Updater updater;
|
||||
|
||||
/** The vote command. */
|
||||
public ArrayList<CommandHandler> voteCommand;
|
||||
|
||||
/** The admin vote command. */
|
||||
public ArrayList<CommandHandler> adminVoteCommand;
|
||||
|
||||
/** The vote sites. */
|
||||
@Getter
|
||||
private List<VoteSite> voteSites;
|
||||
|
||||
/** The vote today. */
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
@Getter
|
||||
private LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
|
||||
/** The signs. */
|
||||
public ArrayList<SignHandler> signs;
|
||||
@Getter
|
||||
@Setter
|
||||
private ArrayList<SignHandler> signs;
|
||||
|
||||
/** The vote log. */
|
||||
public Logger voteLog;
|
||||
@Getter
|
||||
private Logger voteLog;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean update = true;
|
||||
|
||||
@Getter
|
||||
private boolean updateStarted = false;
|
||||
|
||||
public AdvancedCoreHook getAdvancedCoreHook() {
|
||||
return AdvancedCoreHook.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check votifier.
|
||||
*/
|
||||
public void checkVotifier() {
|
||||
private void checkVotifier() {
|
||||
try {
|
||||
Class.forName("com.vexsoftware.votifier.model.VotifierEvent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
@@ -129,7 +146,7 @@ public class Main extends JavaPlugin {
|
||||
throw new RuntimeException("Invalid Storage Method");
|
||||
}
|
||||
UserStorage cur = AdvancedCoreHook.getInstance().getStorageType();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
AdvancedCoreHook.getInstance().getOptions().setStorageType(from);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
@@ -138,14 +155,14 @@ public class Main extends JavaPlugin {
|
||||
|
||||
while (uuids.size() > 0) {
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
//AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
|
||||
AdvancedCoreHook.getInstance().getOptions().setStorageType(from);
|
||||
// AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
|
||||
|
||||
ArrayList<String> converted = new ArrayList<String>();
|
||||
int i = 0;
|
||||
while (i < 250 && i < uuids.size()) {
|
||||
@@ -181,7 +198,7 @@ public class Main extends JavaPlugin {
|
||||
plugin.getLogger()
|
||||
.info("Finished getting data from " + from.toString() + " Converting " + data.size() + " users");
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
AdvancedCoreHook.getInstance().getOptions().setStorageType(to);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
@@ -190,7 +207,7 @@ public class Main extends JavaPlugin {
|
||||
writeConvertData(data);
|
||||
}
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(cur);
|
||||
AdvancedCoreHook.getInstance().getOptions().setStorageType(cur);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
plugin.getLogger().info("Finished convertting");
|
||||
@@ -210,32 +227,8 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().debug(plugin, message);
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getAdminVoteCommand() {
|
||||
return adminVoteCommand;
|
||||
}
|
||||
|
||||
public ArrayList<SignHandler> getSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterAllTime() {
|
||||
return topVoterAllTime;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterDaily() {
|
||||
return topVoterDaily;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterMonthly() {
|
||||
return topVoterMonthly;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterWeekly() {
|
||||
return topVoterWeekly;
|
||||
}
|
||||
|
||||
public Updater getUpdater() {
|
||||
return updater;
|
||||
public LinkedHashMap<User, Integer> getTopVoter(TopVoter top) {
|
||||
return topVoter.get(top);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -253,14 +246,6 @@ public class Main extends JavaPlugin {
|
||||
return UserManager.getInstance();
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getVoteCommand() {
|
||||
return voteCommand;
|
||||
}
|
||||
|
||||
public Logger getVoteLog() {
|
||||
return voteLog;
|
||||
}
|
||||
|
||||
public VoteParty getVoteParty() {
|
||||
return VoteParty.getInstance();
|
||||
}
|
||||
@@ -279,7 +264,7 @@ public class Main extends JavaPlugin {
|
||||
return voteSite;
|
||||
}
|
||||
}
|
||||
if (Config.getInstance().getAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames().contains(siteName)) {
|
||||
if (Config.getInstance().isAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames().contains(siteName)) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
return new VoteSite(siteName.replace(".", "_"));
|
||||
}
|
||||
@@ -318,12 +303,26 @@ public class Main extends JavaPlugin {
|
||||
|
||||
}
|
||||
|
||||
public List<VoteSite> getVoteSites() {
|
||||
return voteSites;
|
||||
}
|
||||
public String getVoteSiteServiceSite(String name) {
|
||||
ArrayList<String> sites = ConfigVoteSites.getInstance().getVoteSitesNames();
|
||||
if (name == null) {
|
||||
return null;
|
||||
}
|
||||
if (sites != null) {
|
||||
for (String siteName : sites) {
|
||||
String URL = ConfigVoteSites.getInstance().getServiceSite(siteName);
|
||||
if (URL != null) {
|
||||
if (URL.equalsIgnoreCase(name)) {
|
||||
return URL;
|
||||
}
|
||||
if (name.equalsIgnoreCase(siteName)) {
|
||||
return URL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return name;
|
||||
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> getVoteToday() {
|
||||
return voteToday;
|
||||
}
|
||||
|
||||
public boolean hasVoteSite(String site) {
|
||||
@@ -336,14 +335,6 @@ public class Main extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
public boolean isUpdateStarted() {
|
||||
return updateStarted;
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@@ -388,7 +379,7 @@ public class Main extends JavaPlugin {
|
||||
* the vote site
|
||||
*/
|
||||
public void logVote(Date date, String playerName, String voteSite) {
|
||||
if (Config.getInstance().getLogVotesToFile()) {
|
||||
if (Config.getInstance().isLogVotesToFile()) {
|
||||
String str = new SimpleDateFormat("EEE, d MMM yyyy HH:mm").format(date);
|
||||
voteLog.logToFile(str + ": " + playerName + " voted on " + voteSite);
|
||||
}
|
||||
@@ -567,14 +558,14 @@ public class Main extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getAutoCreateVoteSites();
|
||||
return "" + Config.getInstance().isAutoCreateVoteSites();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("sendscoreboards") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getSendScoreboards();
|
||||
return "" + AdvancedCoreHook.getInstance().getOptions().isSendScoreboards();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofuser") {
|
||||
@@ -593,14 +584,14 @@ public class Main extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return Config.getInstance().getDataStorage().toUpperCase();
|
||||
return AdvancedCoreHook.getInstance().getOptions().getStorageType().toString();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getDisableCheckOnWorldChange();
|
||||
return "" + AdvancedCoreHook.getInstance().getOptions().isDisableCheckOnWorldChange();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votereminding_enabled") {
|
||||
@@ -614,56 +605,56 @@ public class Main extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIToday();
|
||||
return "" + Config.getInstance().isCommandsUseGUIToday();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_TopVoter") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUITopVoter();
|
||||
return "" + Config.getInstance().isCommandsUseGUITopVoter();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Last") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUILast();
|
||||
return "" + Config.getInstance().isCommandsUseGUILast();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Next") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUINext();
|
||||
return "" + Config.getInstance().isCommandsUseGUINext();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Total") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUITotal();
|
||||
return "" + Config.getInstance().isCommandsUseGUITotal();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Vote") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIVote();
|
||||
return "" + Config.getInstance().isCommandsUseGUIVote();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Best") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIBest();
|
||||
return "" + Config.getInstance().isCommandsUseGUIBest();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Streak") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIStreak();
|
||||
return "" + Config.getInstance().isCommandsUseGUIStreak();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly") {
|
||||
@@ -691,7 +682,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
@@ -709,7 +699,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
@@ -721,15 +710,10 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().setJenkinsSite("ben12345rocks.com");
|
||||
updateAdvancedCoreHook();
|
||||
AdvancedCoreHook.getInstance().loadHook(this);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
debug("UseBatchUpdates: " + AdvancedCoreHook.getInstance().getMysql().isUseBatchUpdates());
|
||||
}
|
||||
registerCommands();
|
||||
registerEvents();
|
||||
checkVotifier();
|
||||
|
||||
CheckUpdate.getInstance().startUp();
|
||||
|
||||
VoteReminding.getInstance().loadRemindChecking();
|
||||
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
@@ -742,16 +726,16 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
});
|
||||
|
||||
topVoterMonthly = new LinkedHashMap<User, Integer>();
|
||||
topVoterWeekly = new LinkedHashMap<User, Integer>();
|
||||
topVoterDaily = new LinkedHashMap<User, Integer>();
|
||||
topVoter = new LinkedHashMap<TopVoter, LinkedHashMap<User, Integer>>();
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
topVoter.put(top, new LinkedHashMap<User, Integer>());
|
||||
}
|
||||
voteToday = new LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>>();
|
||||
topVoterAllTime = new LinkedHashMap<User, Integer>();
|
||||
|
||||
voteLog = new Logger(plugin, new File(plugin.getDataFolder() + File.separator + "Log", "votelog.txt"));
|
||||
|
||||
AdminGUI.getInstance().loadHook();
|
||||
|
||||
// vote party
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
VoteParty.getInstance().check();
|
||||
}
|
||||
@@ -771,6 +755,12 @@ public class Main extends JavaPlugin {
|
||||
|
||||
loadTimer();
|
||||
|
||||
PlaceHolders.getInstance().load();
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
|
||||
MVdWPlaceholders.getInstance().loadMVdWPlaceholders();
|
||||
}
|
||||
|
||||
// set columns
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
@@ -778,7 +768,7 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("Reminded", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DisableBroadcast", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("LastOnline", "VARCHAR(20)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("PlayerName", "VARCHAR(20)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("PlayerName", "VARCHAR(30)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DailyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("WeeklyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DayVoteStreak", "INT DEFAULT '0'");
|
||||
@@ -796,19 +786,34 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
|
||||
}
|
||||
|
||||
RewardHandler.getInstance().getInjectedRewards().add(new RewardInjectInt("Points", 0) {
|
||||
|
||||
@Override
|
||||
public void onRewardRequest(Reward reward, com.Ben12345rocks.AdvancedCore.UserManager.User user, int num,
|
||||
HashMap<String, String> placeholders) {
|
||||
UserManager.getInstance().getVotingPluginUser(user).addPoints(num);
|
||||
}
|
||||
}.addEditButton(new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueNumber("Points", null) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number value) {
|
||||
Reward reward = (Reward) getInv().getData("Reward");
|
||||
reward.getConfig().set("Points", value.intValue());
|
||||
}
|
||||
})));
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
|
||||
boolean hasRewards = RewardHandler.getInstance().hasRewards(ConfigVoteSites.getInstance().getData(),
|
||||
ConfigVoteSites.getInstance().getEverySiteRewardPath());
|
||||
|
||||
boolean noIssues = true;
|
||||
boolean issues = true;
|
||||
ArrayList<String> services = ServerData.getInstance().getServiceSites();
|
||||
for (VoteSite site : getVoteSites()) {
|
||||
if (!site.hasRewards() && !hasRewards) {
|
||||
noIssues = false;
|
||||
issues = false;
|
||||
plugin.getLogger().warning("No rewards detected for the site: " + site.getKey()
|
||||
+ ". See https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards on how to add rewards");
|
||||
}
|
||||
@@ -820,13 +825,13 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
if (!contains) {
|
||||
noIssues = false;
|
||||
issues = false;
|
||||
plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite()
|
||||
+ ", may be an invalid service site. Vote on the site and look in console for a service site, if you get nothing then there is an issue with votifier");
|
||||
}
|
||||
}
|
||||
|
||||
if (!noIssues) {
|
||||
if (!issues) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -837,6 +842,10 @@ public class Main extends JavaPlugin {
|
||||
}, 30l);
|
||||
}
|
||||
|
||||
if (NMSManager.getInstance().isVersion("1.7", "1.8", "1.9", "1.10", "1.11", "1.12")) {
|
||||
plugin.getLogger().severe("Detected running " + NMSManager.getInstance().getVersion()
|
||||
+ ", this version is not supported on this build. Support is limited");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -879,14 +888,12 @@ public class Main extends JavaPlugin {
|
||||
|
||||
pm.registerEvents(new PlayerJoinEvent(this), this);
|
||||
pm.registerEvents(new VotiferEvent(this), this);
|
||||
|
||||
pm.registerEvents(new PlayerVoteListener(this), this);
|
||||
pm.registerEvents(new SignChange(this), this);
|
||||
|
||||
pm.registerEvents(new BlockBreak(this), this);
|
||||
|
||||
pm.registerEvents(new PlayerInteract(this), this);
|
||||
|
||||
pm.registerEvents(new VotingPluginUpdateEvent(this), this);
|
||||
pm.registerEvents(new PlayerCommandSendListener(this), this);
|
||||
|
||||
plugin.debug("Loaded Events");
|
||||
|
||||
@@ -898,23 +905,16 @@ public class Main extends JavaPlugin {
|
||||
public void reload() {
|
||||
setUpdate(true);
|
||||
config.reloadData();
|
||||
config.loadValues();
|
||||
configVoteSites.reloadData();
|
||||
updateAdvancedCoreHook();
|
||||
plugin.loadVoteSites();
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
// loadTimer();
|
||||
|
||||
PlaceHolders.getInstance().load();
|
||||
}
|
||||
|
||||
public void setUpdate(boolean update) {
|
||||
this.update = update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup files.
|
||||
*/
|
||||
public void setupFiles() {
|
||||
private void setupFiles() {
|
||||
try {
|
||||
config = Config.getInstance();
|
||||
config.setup();
|
||||
@@ -954,55 +954,60 @@ public class Main extends JavaPlugin {
|
||||
* Update.
|
||||
*/
|
||||
public void update() {
|
||||
if (update && plugin != null && !updateStarted) {
|
||||
updateStarted = true;
|
||||
update = false;
|
||||
if (update || Config.getInstance().isAlwaysUpdate()) {
|
||||
if (!updateStarted && plugin != null) {
|
||||
if (!Config.getInstance().isUpdateWithPlayersOnlineOnly() || Bukkit.getOnlinePlayers().size() != 0) {
|
||||
updateStarted = true;
|
||||
update = false;
|
||||
|
||||
synchronized (plugin) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else if (Config.getInstance().getClearCacheOnUpdate()) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCacheBasic();
|
||||
}
|
||||
}
|
||||
synchronized (plugin) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else if (Config.getInstance().isClearCacheOnUpdate()) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCacheBasic();
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Starting background task");
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
users.add(user);
|
||||
// AdvancedCoreHook.getInstance().extraDebug("Loading " + uuid);
|
||||
// java.lang.Thread.sleep(5000);
|
||||
plugin.debug("Starting background task");
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
users.add(user);
|
||||
// AdvancedCoreHook.getInstance().extraDebug("Loading " + uuid);
|
||||
// java.lang.Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + users.size()
|
||||
+ " users");
|
||||
TopVoterHandler.getInstance().updateTopVoters(users);
|
||||
Commands.getInstance().updateVoteToday(users);
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UserManager.getInstance().getVotingPluginUser(player).offVote();
|
||||
}
|
||||
time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Background task finished in " + time1 + " seconds");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + users.size() + " users");
|
||||
TopVoterHandler.getInstance().updateTopVoters(users);
|
||||
Commands.getInstance().updateVoteToday(users);
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UserManager.getInstance().getVotingPluginUser(player).offVote();
|
||||
}
|
||||
time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Background task finished in " + time1 + " seconds");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
updateStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
updateStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,18 +11,22 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardOptions;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerReceivePointsEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.SpecialRewards.SpecialRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
@@ -30,7 +34,7 @@ import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
/**
|
||||
* The Class User.
|
||||
*/
|
||||
public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
public class User extends com.Ben12345rocks.AdvancedCore.UserManager.User {
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
@@ -109,6 +113,47 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
setOfflineVotes(offlineVotes);
|
||||
}
|
||||
|
||||
public boolean hasPercentageTotal(TopVoter top, double percentage, LocalDateTime time) {
|
||||
int total = getTotal(top);
|
||||
switch (top) {
|
||||
case Daily:
|
||||
return total / plugin.getVoteSites().size() * 100 > percentage;
|
||||
case Monthly:
|
||||
return total / (plugin.getVoteSites().size() * time.getMonth().length(false)) * 100 > percentage;
|
||||
case Weekly:
|
||||
return total / (plugin.getVoteSites().size() * 7) * 100 > percentage;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkDayVoteStreak() {
|
||||
if (!voteStreakUpdatedToday(LocalDateTime.now())) {
|
||||
if (!Config.getInstance().isVoteStreakRequirementUsePercentage()
|
||||
|| hasPercentageTotal(TopVoter.Daily, Config.getInstance().getVoteStreakRequirementDay(), null)) {
|
||||
addDayVoteStreak();
|
||||
SpecialRewards.getInstance().checkVoteStreak(this, "Day");
|
||||
setDayVoteStreakLastUpdate(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean voteStreakUpdatedToday(LocalDateTime time) {
|
||||
return MiscUtils.getInstance().getTime(getDayVoteStreakLastUpdate()).getDayOfYear() == time.getDayOfYear();
|
||||
}
|
||||
|
||||
public long getDayVoteStreakLastUpdate() {
|
||||
String str = getData().getString("DayVoteStreakLastUpdate");
|
||||
if (str.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return Long.parseLong(str);
|
||||
}
|
||||
|
||||
public void setDayVoteStreakLastUpdate(long time) {
|
||||
getData().setString("DayVoteStreakLastUpdate", "" + time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the points.
|
||||
*/
|
||||
@@ -126,7 +171,14 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
* the value
|
||||
*/
|
||||
public void addPoints(int value) {
|
||||
setPoints(getPoints() + value);
|
||||
PlayerReceivePointsEvent event = new PlayerReceivePointsEvent(this, value);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setPoints(getPoints() + event.getPoints());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,14 +228,6 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean getDisableBroadcast() {
|
||||
return getUserData().getBoolean("DisableBroadcast");
|
||||
}
|
||||
|
||||
public void setDisableBroadcast(boolean value) {
|
||||
getUserData().setBoolean("DisableBroadcast", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can vote site.
|
||||
*
|
||||
@@ -265,12 +309,12 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
}
|
||||
|
||||
public void clearTotals() {
|
||||
setAllTimeTotal(0);
|
||||
resetDailyTotalVotes();
|
||||
resetMonthlyTotalVotes();
|
||||
setWeeklyTotal(0);
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
resetTotals(top);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getAllTimeTotal() {
|
||||
return getUserData().getInt("AllTimeTotal");
|
||||
}
|
||||
@@ -287,6 +331,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("BestWeekVoteStreak");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getDailyTotal() {
|
||||
return getUserData().getInt("DailyTotal");
|
||||
}
|
||||
@@ -295,6 +340,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("DayVoteStreak");
|
||||
}
|
||||
|
||||
public boolean getDisableBroadcast() {
|
||||
return getUserData().getBoolean("DisableBroadcast");
|
||||
}
|
||||
|
||||
public HashMap<String, Boolean> getHasGottenMilestone() {
|
||||
HashMap<String, Boolean> hasGottenMilestone = new HashMap<String, Boolean>();
|
||||
ArrayList<String> milestoneList = getUserData().getStringList("GottenMileStones");
|
||||
@@ -357,9 +406,9 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
times.put(voteSite, getTime(voteSite));
|
||||
}
|
||||
LinkedHashMap<VoteSite, Long> sorted = (LinkedHashMap<VoteSite, Long>) times.entrySet().stream()
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
LinkedHashMap<VoteSite, Long> sorted = new LinkedHashMap<>(
|
||||
times.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
|
||||
return sorted;
|
||||
}
|
||||
|
||||
@@ -367,6 +416,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("MilestoneCount", getAllTimeTotal());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMonthTotal() {
|
||||
return getData().getInt("MonthTotal");
|
||||
}
|
||||
@@ -407,10 +457,31 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getTotal(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getUserData().getInt("AllTimeTotal");
|
||||
case Daily:
|
||||
return getUserData().getInt("DailyTotal");
|
||||
case Monthly:
|
||||
return getData().getInt("MonthTotal");
|
||||
case Weekly:
|
||||
return getUserData().getInt("WeeklyTotal");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getVotePartyVotes() {
|
||||
return getUserData().getInt("VotePartyVotes");
|
||||
}
|
||||
|
||||
public int getVoteShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("VoteShopLimit" + identifier);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getWeeklyTotal() {
|
||||
return getUserData().getInt("WeeklyTotal");
|
||||
}
|
||||
@@ -421,30 +492,32 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
|
||||
public void giveDailyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getDailyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Daily").send(this);
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Daily").setOnline(isOnline())
|
||||
.send(this);
|
||||
}
|
||||
|
||||
public void giveMonthlyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMonthlyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Monthly").send(this);
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Monthly").setOnline(isOnline())
|
||||
.send(this);
|
||||
}
|
||||
|
||||
public void giveOfflineOtherRewards() {
|
||||
ArrayList<String> offlineRewards = getOfflineOtherRewards();
|
||||
for (String str : offlineRewards) {
|
||||
if (str.equalsIgnoreCase("FirstVote")) {
|
||||
OtherVoteReward.getInstance().giveFirstVoteRewards(this, false);
|
||||
SpecialRewards.getInstance().giveFirstVoteRewards(this, false);
|
||||
} else if (str.equalsIgnoreCase("AllSites")) {
|
||||
OtherVoteReward.getInstance().giveAllSitesRewards(this, false);
|
||||
SpecialRewards.getInstance().giveAllSitesRewards(this, false);
|
||||
} else if (str.equalsIgnoreCase("VoteParty")) {
|
||||
VoteParty.getInstance().giveReward(this);
|
||||
VoteParty.getInstance().giveReward(this, false);
|
||||
} else if (str.contains("Cumulative")) {
|
||||
String st = str.substring("Cumulative".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int votesRequired = Integer.parseInt(st);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getCumulativeRewardEnabled(votesRequired)) {
|
||||
OtherVoteReward.getInstance().giveCumulativeVoteReward(this, false, votesRequired);
|
||||
SpecialRewards.getInstance().giveCumulativeVoteReward(this, false, votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -454,7 +527,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
int votesRequired = Integer.parseInt(st);
|
||||
if (votesRequired > 0) {
|
||||
if (Config.getInstance().getMilestoneRewardEnabled(votesRequired)) {
|
||||
OtherVoteReward.getInstance().giveMilestoneVoteReward(this, true, votesRequired);
|
||||
SpecialRewards.getInstance().giveMilestoneVoteReward(this, true, votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -465,7 +538,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
String st = args[2];
|
||||
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled(type, st)) {
|
||||
OtherVoteReward.getInstance().giveVoteStreakReward(this, false, type, "" + st, -1);
|
||||
SpecialRewards.getInstance().giveVoteStreakReward(this, false, type, "" + st, -1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -481,7 +554,8 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
|
||||
public void giveWeeklyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getWeeklyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Weekly").send(this);
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Weekly").setOnline(isOnline())
|
||||
.send(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -490,7 +564,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
* @return true if user got the first vote reward
|
||||
*/
|
||||
public boolean hasGottenFirstVote() {
|
||||
return getAllTimeTotal() != 0;
|
||||
return getTotal(TopVoter.AllTime) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -509,11 +583,11 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
}
|
||||
|
||||
public boolean isReminded() {
|
||||
return Boolean.valueOf(getUserData().getString("Reminded"));
|
||||
return getUserData().getBoolean("Reminded");
|
||||
}
|
||||
|
||||
public boolean isTopVoterIgnore() {
|
||||
return Boolean.valueOf(getUserData().getString("TopVoterIgnore"));
|
||||
return getUserData().getBoolean("TopVoterIgnore");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -529,6 +603,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
* Off vote.
|
||||
*/
|
||||
public void offVote() {
|
||||
if (!AdvancedCoreHook.getInstance().getOptions().isProcessRewards()) {
|
||||
AdvancedCoreHook.getInstance().debug("Processing rewards is disabled");
|
||||
return;
|
||||
}
|
||||
AdvancedCoreHook.getInstance().extraDebug("Checking offline vote site votes");
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
@@ -568,11 +646,11 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
* the broadcast
|
||||
*/
|
||||
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast) {
|
||||
if (Config.getInstance().getFormatBroadcastWhenOnline() && Config.getInstance().getBroadCastVotesEnabled()
|
||||
if (Config.getInstance().getFormatBroadcastWhenOnline() && Config.getInstance().isBroadcastVotesEnabled()
|
||||
&& broadcast) {
|
||||
voteSite.broadcastVote(this);
|
||||
}
|
||||
voteSite.giveSiteReward(this, online);
|
||||
voteSite.giveRewards(this, online);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -590,17 +668,11 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetDailyTotalVotes() {
|
||||
setDailyTotal(0);
|
||||
}
|
||||
|
||||
public void resetMonthlyTotalVotes() {
|
||||
setLastMonthTotal(getMonthTotal());
|
||||
setMonthTotal(0);
|
||||
}
|
||||
|
||||
public void resetWeeklyTotalVotes() {
|
||||
setWeeklyTotal(0);
|
||||
public void resetTotals(TopVoter topVoter) {
|
||||
if (topVoter.equals(TopVoter.Monthly)) {
|
||||
setLastMonthTotal(getTotal(TopVoter.Monthly));
|
||||
}
|
||||
setTotal(topVoter, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -611,9 +683,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
*/
|
||||
public void sendVoteEffects(boolean online) {
|
||||
RewardHandler.getInstance().giveReward(this, Config.getInstance().getData(),
|
||||
Config.getInstance().getAnySiteRewardsPath(), online);
|
||||
Config.getInstance().getAnySiteRewardsPath(), new RewardOptions().setOnline(online));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setAllTimeTotal(int allTimeTotal) {
|
||||
getUserData().setInt("AllTimeTotal", allTimeTotal);
|
||||
}
|
||||
@@ -630,6 +703,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
getData().setInt("BestWeekVoteStreak", streak);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDailyTotal(int total) {
|
||||
getUserData().setInt("DailyTotal", total);
|
||||
}
|
||||
@@ -641,6 +715,10 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
}
|
||||
}
|
||||
|
||||
public void setDisableBroadcast(boolean value) {
|
||||
getUserData().setBoolean("DisableBroadcast", value);
|
||||
}
|
||||
|
||||
public void setHasGotteMilestone(int votesRequired, boolean b) {
|
||||
HashMap<String, Boolean> hasGottenMilestone = getHasGottenMilestone();
|
||||
hasGottenMilestone.put("" + votesRequired, b);
|
||||
@@ -685,6 +763,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
getData().setInt("MilestoneCount", value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMonthTotal(int total) {
|
||||
getData().setInt("MonthTotal", total);
|
||||
}
|
||||
@@ -732,10 +811,35 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
getUserData().setString("TopVoterIgnore", "" + topVoterIgnore);
|
||||
}
|
||||
|
||||
public void setTotal(TopVoter top, int value) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
getUserData().setInt("AllTimeTotal", value);
|
||||
break;
|
||||
case Daily:
|
||||
getUserData().setInt("DailyTotal", value);
|
||||
break;
|
||||
case Monthly:
|
||||
getData().setInt("MonthTotal", value);
|
||||
break;
|
||||
case Weekly:
|
||||
getUserData().setInt("WeeklyTotal", value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void setVotePartyVotes(int value) {
|
||||
getUserData().setInt("VotePartyVotes", value);
|
||||
}
|
||||
|
||||
public void setVoteShopIdentifierLimit(String identifier, int value) {
|
||||
getData().setInt("VoteShopLimit" + identifier, value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setWeeklyTotal(int total) {
|
||||
getUserData().setInt("WeeklyTotal", total);
|
||||
}
|
||||
|
||||
@@ -8,16 +8,21 @@ import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The Class VoteSite.
|
||||
*/
|
||||
@@ -32,32 +37,49 @@ public class VoteSite {
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/** The vote URL. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String voteURL;
|
||||
|
||||
/** The service site. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite;
|
||||
|
||||
/** The site name. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String key;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String displayName;
|
||||
|
||||
/** The vote delay. */
|
||||
@Getter
|
||||
@Setter
|
||||
private double voteDelay;
|
||||
|
||||
/** The enabled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean enabled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean voteDelayDaily;
|
||||
|
||||
/** The priority. */
|
||||
@Getter
|
||||
@Setter
|
||||
private int priority;
|
||||
|
||||
@Setter
|
||||
private ConfigurationSection item;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean giveOffline;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean waitUntilVoteDelay;
|
||||
|
||||
/**
|
||||
* Instantiates a new vote site.
|
||||
*
|
||||
@@ -94,6 +116,7 @@ public class VoteSite {
|
||||
placeholders.put("nickname",
|
||||
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
|
||||
placeholders.put("sitename", getDisplayName());
|
||||
placeholders.put("servicesite", getServiceSite());
|
||||
bc = StringUtils.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
@@ -106,13 +129,6 @@ public class VoteSite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the displayName
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
@@ -126,49 +142,6 @@ public class VoteSite {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
* @return the priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service site.
|
||||
*
|
||||
* @return the service site
|
||||
*/
|
||||
public String getServiceSite() {
|
||||
return serviceSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
* @return the vote delay
|
||||
*/
|
||||
public double getVoteDelay() {
|
||||
return voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL() {
|
||||
return voteURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give rewards.
|
||||
*
|
||||
@@ -187,18 +160,6 @@ public class VoteSite {
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give site reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveSiteReward(User user, boolean online) {
|
||||
giveRewards(user, online);
|
||||
}
|
||||
|
||||
public boolean hasRewards() {
|
||||
return RewardHandler.getInstance().hasRewards(configVoteSites.getData(), configVoteSites.getRewardsPath(key));
|
||||
}
|
||||
@@ -219,119 +180,12 @@ public class VoteSite {
|
||||
item = configVoteSites.getItem(key);
|
||||
voteDelayDaily = configVoteSites.getVoteSiteResetVoteDelayDaily(key);
|
||||
giveOffline = configVoteSites.getVoteSiteGiveOffline(key);
|
||||
waitUntilVoteDelay = configVoteSites.getWaitUntilVoteDelay(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is enabled.
|
||||
*
|
||||
* @return true, if is enabled
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the giveOffline
|
||||
*/
|
||||
public boolean isGiveOffline() {
|
||||
return giveOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the voteDelayDaily
|
||||
*/
|
||||
public boolean isVoteDelayDaily() {
|
||||
return voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayName
|
||||
* the displayName to set
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param enabled
|
||||
* the new enabled
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param giveOffline
|
||||
* the giveOffline to set
|
||||
*/
|
||||
public void setGiveOffline(boolean giveOffline) {
|
||||
this.giveOffline = giveOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* the item to set
|
||||
*/
|
||||
public void setItem(ConfigurationSection item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* the key to set
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
* @param priority
|
||||
* the new priority
|
||||
*/
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the service site.
|
||||
*
|
||||
* @param serviceSite
|
||||
* the new service site
|
||||
*/
|
||||
public void setServiceSite(String serviceSite) {
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote delay.
|
||||
*
|
||||
* @param voteDelay
|
||||
* the new vote delay
|
||||
*/
|
||||
public void setVoteDelay(double voteDelay) {
|
||||
this.voteDelay = voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param voteDelayDaily
|
||||
* the voteDelayDaily to set
|
||||
*/
|
||||
public void setVoteDelayDaily(boolean voteDelayDaily) {
|
||||
this.voteDelayDaily = voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
* @param voteURL
|
||||
* the new vote URL
|
||||
*/
|
||||
public void setVoteURL(String voteURL) {
|
||||
this.voteURL = voteURL;
|
||||
public boolean isVaidServiceSite() {
|
||||
return ArrayUtils.getInstance().containsIgnoreCase(ServerData.getInstance().getServiceSites(),
|
||||
getServiceSite());
|
||||
}
|
||||
|
||||
}
|
||||
+23
-90
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
package com.Ben12345rocks.VotingPlugin.Signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -16,6 +16,11 @@ import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -23,13 +28,16 @@ import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
*/
|
||||
public class SignHandler {
|
||||
|
||||
/** The sign. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String sign;
|
||||
|
||||
/** The location. */
|
||||
@Getter
|
||||
@Setter
|
||||
private Location location;
|
||||
|
||||
/** The data. */
|
||||
@Getter
|
||||
@Setter
|
||||
private String data;
|
||||
|
||||
/** The lines. */
|
||||
@@ -47,8 +55,9 @@ public class SignHandler {
|
||||
/** The votes. */
|
||||
private int votes;
|
||||
|
||||
/** The is valid. */
|
||||
private boolean isValid;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean valid;
|
||||
|
||||
/**
|
||||
* Instantiates a new sign handler.
|
||||
@@ -115,24 +124,6 @@ public class SignHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location.
|
||||
*
|
||||
* @return the location
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the right click message.
|
||||
*
|
||||
@@ -147,15 +138,6 @@ public class SignHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign.
|
||||
*
|
||||
* @return the sign
|
||||
*/
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is location same.
|
||||
*
|
||||
@@ -167,15 +149,6 @@ public class SignHandler {
|
||||
return loc.equals(getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is valid.
|
||||
*
|
||||
* @return true, if is valid
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*/
|
||||
@@ -183,46 +156,6 @@ public class SignHandler {
|
||||
ServerData.getInstance().removeSign(sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data.
|
||||
*
|
||||
* @param data
|
||||
* the new data
|
||||
*/
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location.
|
||||
*
|
||||
* @param location
|
||||
* the new location
|
||||
*/
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sign.
|
||||
*
|
||||
* @param sign
|
||||
* the new sign
|
||||
*/
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the valid.
|
||||
*
|
||||
* @param isValid
|
||||
* the new valid
|
||||
*/
|
||||
public void setValid(boolean isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store sign.
|
||||
*/
|
||||
@@ -248,13 +181,13 @@ public class SignHandler {
|
||||
|
||||
ArrayList<User> users = null;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
users = plugin.convertSet(plugin.topVoterAllTime.keySet());
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.AllTime).keySet());
|
||||
} else if (data.equalsIgnoreCase("monthly")) {
|
||||
users = plugin.convertSet(plugin.topVoterMonthly.keySet());
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.Monthly).keySet());
|
||||
} else if (data.equalsIgnoreCase("weekly")) {
|
||||
users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
|
||||
} else if (data.equalsIgnoreCase("daily")) {
|
||||
users = plugin.convertSet(plugin.topVoterDaily.keySet());
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.Daily).keySet());
|
||||
}
|
||||
|
||||
if (users != null && users.size() >= position) {
|
||||
@@ -263,13 +196,13 @@ public class SignHandler {
|
||||
|
||||
votes = 0;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
votes = plugin.topVoterAllTime.get(user);
|
||||
votes = plugin.getTopVoter(TopVoter.AllTime).get(user);
|
||||
} else if (data.equalsIgnoreCase("monthly")) {
|
||||
votes = plugin.topVoterMonthly.get(user);
|
||||
votes = plugin.getTopVoter(TopVoter.Monthly).get(user);
|
||||
} else if (data.equalsIgnoreCase("weekly")) {
|
||||
votes = plugin.topVoterWeekly.get(user);
|
||||
votes = plugin.getTopVoter(TopVoter.Weekly).get(user);
|
||||
} else if (data.equalsIgnoreCase("daily")) {
|
||||
votes = plugin.topVoterDaily.get(user);
|
||||
votes = plugin.getTopVoter(TopVoter.Daily).get(user);
|
||||
}
|
||||
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
@@ -6,7 +6,6 @@ import org.bukkit.Location;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -66,10 +65,10 @@ public class Signs {
|
||||
* Load signs.
|
||||
*/
|
||||
public void loadSigns() {
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
plugin.setSigns(new ArrayList<SignHandler>());
|
||||
for (String sign : ServerData.getInstance().getSigns()) {
|
||||
// plugin.getLogger().info("Loading sign " + sign);
|
||||
plugin.signs.add(new SignHandler(sign, ServerData.getInstance().getSignLocation(sign),
|
||||
plugin.getSigns().add(new SignHandler(sign, ServerData.getInstance().getSignLocation(sign),
|
||||
ServerData.getInstance().getSignData(sign), ServerData.getInstance().getSignPosition(sign)));
|
||||
}
|
||||
}
|
||||
@@ -78,7 +77,7 @@ public class Signs {
|
||||
* Store signs.
|
||||
*/
|
||||
public void storeSigns() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
sign.storeSign();
|
||||
}
|
||||
}
|
||||
@@ -87,14 +86,16 @@ public class Signs {
|
||||
* Update signs.
|
||||
*/
|
||||
public void updateSigns() {
|
||||
for (int i = plugin.signs.size() - 1; i >= 0; i--) {
|
||||
if (!plugin.signs.get(i).isValid()) {
|
||||
int time = 0;
|
||||
for (int i = plugin.getSigns().size() - 1; i >= 0; i--) {
|
||||
if (!plugin.getSigns().get(i).isValid()) {
|
||||
plugin.debug("Sign " + i + " invalid, removing from data.");
|
||||
plugin.signs.get(i).removeSign();
|
||||
plugin.signs.remove(i);
|
||||
plugin.getSigns().get(i).removeSign();
|
||||
plugin.getSigns().remove(i);
|
||||
} else {
|
||||
plugin.signs.get(i).updateLines();
|
||||
plugin.signs.get(i).updateSign(i * 3);
|
||||
plugin.getSigns().get(i).updateLines();
|
||||
plugin.getSigns().get(i).updateSign(time);
|
||||
time += 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+47
-16
@@ -1,23 +1,26 @@
|
||||
package com.Ben12345rocks.VotingPlugin.OtherRewards;
|
||||
package com.Ben12345rocks.VotingPlugin.SpecialRewards;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardOptions;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteAllSitesEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerSpecialRewardEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.SpecialRewardType;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OtherVoteReward.
|
||||
*/
|
||||
public class OtherVoteReward {
|
||||
public class SpecialRewards {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
@@ -26,7 +29,7 @@ public class OtherVoteReward {
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The instance. */
|
||||
static OtherVoteReward instance = new OtherVoteReward();
|
||||
static SpecialRewards instance = new SpecialRewards();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
@@ -36,14 +39,14 @@ public class OtherVoteReward {
|
||||
*
|
||||
* @return single instance of OtherVoteReward
|
||||
*/
|
||||
public static OtherVoteReward getInstance() {
|
||||
public static SpecialRewards getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new other vote reward.
|
||||
*/
|
||||
private OtherVoteReward() {
|
||||
private SpecialRewards() {
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,8 +55,8 @@ public class OtherVoteReward {
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public OtherVoteReward(Main plugin) {
|
||||
OtherVoteReward.plugin = plugin;
|
||||
public SpecialRewards(Main plugin) {
|
||||
SpecialRewards.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -90,11 +93,11 @@ public class OtherVoteReward {
|
||||
Config.getInstance().getCumulativeRewardsPath(votesRequired))) {
|
||||
int total = 0;
|
||||
if (Config.getInstance().getCumulativeVotesInSameDay(votesRequired)) {
|
||||
total = user.getDailyTotal();
|
||||
total = user.getTotal(TopVoter.Daily);
|
||||
} else if (Config.getInstance().getCumulativeVotesInSameWeek(votesRequired)) {
|
||||
total = user.getWeeklyTotal();
|
||||
total = user.getTotal(TopVoter.Weekly);
|
||||
} else {
|
||||
total = user.getAllTimeTotal();
|
||||
total = user.getTotal(TopVoter.AllTime);
|
||||
}
|
||||
|
||||
if ((total % votesRequired) == 0 && total != 0) {
|
||||
@@ -226,14 +229,14 @@ public class OtherVoteReward {
|
||||
* the online
|
||||
*/
|
||||
public void giveAllSitesRewards(User user, boolean online) {
|
||||
PlayerVoteAllSitesEvent event = new PlayerVoteAllSitesEvent(user);
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.ALLSITE);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getAllSitesRewardPath(), online);
|
||||
Config.getInstance().getAllSitesRewardPath(), new RewardOptions().setOnline(online));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -247,6 +250,14 @@ public class OtherVoteReward {
|
||||
* the cumulative
|
||||
*/
|
||||
public void giveCumulativeVoteReward(User user, boolean online, int cumulative) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.CUMMULATIVE.setAmount(cumulative));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getCumulativeRewardsPath(cumulative))
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
}
|
||||
@@ -260,8 +271,14 @@ public class OtherVoteReward {
|
||||
* the online
|
||||
*/
|
||||
public void giveFirstVoteRewards(User user, boolean online) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.FIRSTVOTE);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath(), online);
|
||||
Config.getInstance().getFirstVoteRewardsPath(), new RewardOptions().setOnline(online));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -275,11 +292,25 @@ public class OtherVoteReward {
|
||||
* the milestone
|
||||
*/
|
||||
public void giveMilestoneVoteReward(User user, boolean online, int milestone) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.MILESTONE.setAmount(milestone));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMilestoneRewardsPath(milestone))
|
||||
.setOnline(online).withPlaceHolder("Milestone", "" + milestone).send(user);
|
||||
}
|
||||
|
||||
public void giveVoteStreakReward(User user, boolean online, String type, String string, int votes) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.VOTESTREAK.setType(type).setAmount(votes));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVoteStreakRewardsPath(type, string))
|
||||
.setOnline(online).withPlaceHolder("Type", type).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class VoteTester {
|
||||
|
||||
private static VoteTester instance = new VoteTester();
|
||||
|
||||
public static VoteTester getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
public void testVotes(int amount, String name, String site) {
|
||||
long time1 = System.currentTimeMillis();
|
||||
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,
|
||||
plugin.getVoteSiteServiceSite(site), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
long start2 = System.currentTimeMillis();
|
||||
timesPerVote.add(start2 - start1);
|
||||
}
|
||||
long time2 = System.currentTimeMillis();
|
||||
long time = time2 - time1;
|
||||
long timeTotal = 0;
|
||||
for (Long t : timesPerVote) {
|
||||
timeTotal += t.longValue();
|
||||
}
|
||||
long timePerVoteAvg = timeTotal / timesPerVote.size();
|
||||
Main.plugin.getLogger()
|
||||
.info("Time to process votes (" + amount + "): " + time + " ms, average per vote " + timePerVoteAvg
|
||||
+ " ms. " + AdvancedCoreHook.getInstance().getStorageType() + ", "
|
||||
+ UserManager.getInstance().getAllUUIDs().size() + " users. "
|
||||
+ Main.plugin.getVoteSites().size() + " votesites");
|
||||
}
|
||||
|
||||
}
|
||||
+15
-3
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
package com.Ben12345rocks.VotingPlugin.TopVoter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -24,6 +24,18 @@ public enum TopVoter {
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return Config.getInstance().getFormatTopVoterMonthly();
|
||||
} else if (this.equals(TopVoter.Weekly)) {
|
||||
return Config.getInstance().getFormatTopVoterWeekly();
|
||||
} else if (this.equals(TopVoter.Daily)) {
|
||||
return Config.getInstance().getFormatTopVoterDaily();
|
||||
} else {
|
||||
return Config.getInstance().getFormatTopVoterAllTime();
|
||||
}
|
||||
}
|
||||
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
@@ -64,11 +76,11 @@ public enum TopVoter {
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
for (int i = list.size()-1; i >= 0; i--) {
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int prev = i - 1;
|
||||
if (prev < 0) {
|
||||
prev = list.size()-1;
|
||||
prev = list.size() - 1;
|
||||
}
|
||||
return TopVoter.values()[prev];
|
||||
}
|
||||
@@ -17,19 +17,19 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.PreDateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.WeekChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.DateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.PreDateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.WeekChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFileHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.SpecialRewards.SpecialRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class TopVoterHandler implements Listener {
|
||||
@@ -66,11 +66,11 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
public String[] getTopVotersWeekly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
ArrayList<User> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine().replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%", "" + plugin.topVoterWeekly.get(users.get(i)));
|
||||
.replace("%votes%", "" + plugin.getTopVoter(TopVoter.Weekly).get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
@@ -100,38 +100,37 @@ public class TopVoterHandler implements Listener {
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onDateChanged(DateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getDailyTotal() == 0 && user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
} else {
|
||||
user.addDayVoteStreak();
|
||||
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
|
||||
if (user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
}
|
||||
}
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Day");
|
||||
|
||||
if (user.getHighestDailyTotal() < user.getDailyTotal()) {
|
||||
user.setHighestDailyTotal(user.getDailyTotal());
|
||||
if (user.getHighestDailyTotal() < user.getTotal(TopVoter.Daily)) {
|
||||
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersDaily()) {
|
||||
plugin.debug("Storing TopVoters Daily");
|
||||
storeDailyTopVoters();
|
||||
storeTopVoters(TopVoter.Daily);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
if (Config.getInstance().isEnableDailyRewards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getDailyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterDaily.keySet()) {
|
||||
for (User user : plugin.getTopVoter(TopVoter.Daily).keySet()) {
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getDailyTotal() != lastTotal) {
|
||||
if (user.getTotal(TopVoter.Daily) != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
@@ -141,10 +140,10 @@ public class TopVoterHandler implements Listener {
|
||||
user.giveDailyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getDailyTotal();
|
||||
lastTotal = user.getTotal(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
resetDailyTotals();
|
||||
resetTotals(TopVoter.Daily);
|
||||
|
||||
}
|
||||
|
||||
@@ -152,32 +151,36 @@ public class TopVoterHandler implements Listener {
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getMonthTotal() == 0 && user.getMonthVoteStreak() != 0) {
|
||||
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
} else {
|
||||
user.addMonthVoteStreak();
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Month");
|
||||
if (!Config.getInstance().isVoteStreakRequirementUsePercentage() || user.hasPercentageTotal(
|
||||
TopVoter.Monthly, Config.getInstance().getVoteStreakRequirementMonth(),
|
||||
LocalDateTime.now().minusDays(1))) {
|
||||
user.addMonthVoteStreak();
|
||||
SpecialRewards.getInstance().checkVoteStreak(user, "Month");
|
||||
}
|
||||
}
|
||||
|
||||
if (user.getHighestMonthlyTotal() < user.getMonthTotal()) {
|
||||
user.setHighestMonthlyTotal(user.getMonthTotal());
|
||||
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
|
||||
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersMonthly()) {
|
||||
plugin.debug("Storing TopVoters Monthly");
|
||||
storeMonthlyTopVoters();
|
||||
storeTopVoters(TopVoter.Monthly);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
if (Config.getInstance().isEnableMonthlyAwards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getMonthlyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterMonthly.keySet()) {
|
||||
for (User user : plugin.getTopVoter(TopVoter.Monthly).keySet()) {
|
||||
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getMonthTotal() != lastTotal) {
|
||||
if (user.getTotal(TopVoter.Monthly) != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
@@ -187,10 +190,10 @@ public class TopVoterHandler implements Listener {
|
||||
user.giveMonthlyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getMonthTotal();
|
||||
lastTotal = user.getTotal(TopVoter.Monthly);
|
||||
}
|
||||
}
|
||||
resetMonthlyTotals();
|
||||
resetTotals(TopVoter.Monthly);
|
||||
|
||||
if (Config.getInstance().getResetMilestonesMonthly()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
@@ -212,31 +215,34 @@ public class TopVoterHandler implements Listener {
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getWeeklyTotal() == 0 && user.getWeekVoteStreak() != 0) {
|
||||
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
} else {
|
||||
user.addWeekVoteStreak();
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Week");
|
||||
if (!Config.getInstance().isVoteStreakRequirementUsePercentage() || user.hasPercentageTotal(
|
||||
TopVoter.Weekly, Config.getInstance().getVoteStreakRequirementWeek(), null)) {
|
||||
user.addWeekVoteStreak();
|
||||
SpecialRewards.getInstance().checkVoteStreak(user, "Week");
|
||||
}
|
||||
}
|
||||
|
||||
if (user.getHighestWeeklyTotal() < user.getWeeklyTotal()) {
|
||||
user.setHighestWeeklyTotal(user.getWeeklyTotal());
|
||||
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
|
||||
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersWeekly()) {
|
||||
plugin.debug("Storing TopVoters Weekly");
|
||||
storeWeeklyTopVoters();
|
||||
storeTopVoters(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
if (Config.getInstance().isEnableWeeklyAwards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getWeeklyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterWeekly.keySet()) {
|
||||
for (User user : plugin.getTopVoter(TopVoter.Weekly).keySet()) {
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getWeeklyTotal() != lastTotal) {
|
||||
if (user.getTotal(TopVoter.Weekly) != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
@@ -246,10 +252,10 @@ public class TopVoterHandler implements Listener {
|
||||
user.giveWeeklyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getWeeklyTotal();
|
||||
lastTotal = user.getTotal(TopVoter.Weekly);
|
||||
}
|
||||
}
|
||||
resetWeeklyTotals();
|
||||
resetTotals(TopVoter.Weekly);
|
||||
|
||||
}
|
||||
|
||||
@@ -257,29 +263,11 @@ public class TopVoterHandler implements Listener {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void resetDailyTotals() {
|
||||
public void resetTotals(TopVoter topVoter) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getDailyTotal() != 0) {
|
||||
user.resetDailyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetMonthlyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getMonthTotal() != 0) {
|
||||
user.resetMonthlyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetWeeklyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getWeeklyTotal() != 0) {
|
||||
user.resetWeeklyTotalVotes();
|
||||
if (user.getTotal(topVoter) != 0) {
|
||||
user.resetTotals(topVoter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,56 +299,30 @@ public class TopVoterHandler implements Listener {
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
public void storeDailyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(5);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
int day = time.getDayOfMonth();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Daily" + File.separator + year + "_" + month + "_" + day + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Day", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
public void storeMonthlyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(10);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Monthly" + File.separator + month + "_" + year + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Month", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
public void storeWeeklyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(10);
|
||||
public void storeTopVoters(TopVoter top) {
|
||||
LocalDateTime time = LocalDateTime.now().minusDays(1);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
int week = time.getDayOfYear();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Weekly" + File.separator + year + "_" + month + "_" + week + ".yml"));
|
||||
int day = time.getDayOfMonth();
|
||||
String fileName = "TopVoter" + File.separator + top.toString() + File.separator + year + "_" + month;
|
||||
|
||||
if (top.equals(TopVoter.Daily)) {
|
||||
fileName += "_" + day;
|
||||
} else if (top.equals(TopVoter.Weekly)) {
|
||||
fileName += "_" + week;
|
||||
}
|
||||
fileName += ".yml";
|
||||
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(), fileName));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(top).entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Week", topVoters);
|
||||
file.getData().set(top.toString(), topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
@@ -376,7 +338,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -416,7 +378,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -456,7 +418,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -491,7 +453,8 @@ public class TopVoterHandler implements Listener {
|
||||
*/
|
||||
public String[] topVotersAllTime() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(plugin.topVoterAllTime.entrySet());
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(
|
||||
plugin.getTopVoter(TopVoter.AllTime).entrySet());
|
||||
int i = 0;
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
@@ -519,7 +482,7 @@ public class TopVoterHandler implements Listener {
|
||||
|
||||
public String[] topVotersDaily() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterDaily.keySet());
|
||||
ArrayList<User> 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));
|
||||
@@ -528,7 +491,7 @@ public class TopVoterHandler implements Listener {
|
||||
} catch (Exception ex) {
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
line = line.replace("%votes%", "" + plugin.topVoterMonthly.get(users.get(i)));
|
||||
line = line.replace("%votes%", "" + plugin.getTopVoter(TopVoter.Monthly).get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
@@ -543,7 +506,8 @@ public class TopVoterHandler implements Listener {
|
||||
*/
|
||||
public String[] topVotersMonthly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(plugin.topVoterMonthly.entrySet());
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(
|
||||
plugin.getTopVoter(TopVoter.Monthly).entrySet());
|
||||
int i = 0;
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
@@ -575,7 +539,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
@@ -614,53 +578,19 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.topVoterAllTime.clear();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
for (User user : users) {
|
||||
int total = user.getAllTimeTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterAllTime.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterAllTime = sortByValues(plugin.topVoterAllTime, false);
|
||||
plugin.debug("All Time TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterMonthly.clear();
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
for (User user : users) {
|
||||
int total = user.getMonthTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterMonthly.put(user, total);
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
plugin.getTopVoter(top).clear();
|
||||
if (Config.getInstance().getLoadTopVoter(top)) {
|
||||
for (User user : users) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
plugin.getTopVoter(top).put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.getTopVoter().put(top, sortByValues(plugin.getTopVoter(top), false));
|
||||
plugin.debug(top.toString() + " TopVoter loaded");
|
||||
}
|
||||
plugin.topVoterMonthly = sortByValues(plugin.topVoterMonthly, false);
|
||||
plugin.debug("Monthly TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly.clear();
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
for (User user : users) {
|
||||
int total = user.getWeeklyTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterWeekly.put(user, total);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly = sortByValues(plugin.topVoterWeekly, false);
|
||||
plugin.debug("Weekly TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterDaily.clear();
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
for (User user : users) {
|
||||
int total = user.getDailyTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterDaily.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterDaily = sortByValues(plugin.topVoterDaily, false);
|
||||
plugin.debug("Daily TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.debug("Updated TopVoter");
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Updater;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CheckUpdate.
|
||||
*/
|
||||
public class CheckUpdate {
|
||||
|
||||
/** The instance. */
|
||||
static CheckUpdate instance = new CheckUpdate();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of CheckUpdate.
|
||||
*
|
||||
* @return single instance of CheckUpdate
|
||||
*/
|
||||
public static CheckUpdate getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new check update.
|
||||
*/
|
||||
private CheckUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new check update.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CheckUpdate(Main plugin) {
|
||||
CheckUpdate.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check update.
|
||||
*/
|
||||
public void checkUpdate() {
|
||||
if (Config.getInstance().isDisableUpdateChecking()) {
|
||||
return;
|
||||
}
|
||||
plugin.setUpdater(new Updater(plugin, 15358, false));
|
||||
final Updater.UpdateResult result = plugin.getUpdater().getResult();
|
||||
switch (result) {
|
||||
case FAIL_SPIGOT: {
|
||||
plugin.getLogger().info("Failed to check for update for " + plugin.getName() + "!");
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " is up to date! Version: " + plugin.getUpdater().getVersion());
|
||||
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!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkUpdateBasic() {
|
||||
if (Config.getInstance().isDisableUpdateChecking()) {
|
||||
return;
|
||||
}
|
||||
plugin.setUpdater(new Updater(plugin, 15358, false));
|
||||
final Updater.UpdateResult result = plugin.getUpdater().getResult();
|
||||
switch (result) {
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: "
|
||||
+ plugin.getUpdater().getVersion() + " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start up.
|
||||
*/
|
||||
public void startUp() {
|
||||
if (Config.getInstance().isDisableUpdateChecking()) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdate();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdateBasic();
|
||||
}
|
||||
}, 1000 * 60 * 1200, 1000 * 60 * 1200);
|
||||
|
||||
}
|
||||
}, 10l);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import java.util.ArrayList;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
@@ -32,6 +32,10 @@ public class UserManager {
|
||||
return com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().getAllUUIDs();
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(com.Ben12345rocks.AdvancedCore.UserManager.User user) {
|
||||
return getVotingPluginUser(java.util.UUID.fromString(user.getUUID()));
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(java.util.UUID uuid) {
|
||||
return getVotingPluginUser(new UUID(uuid.toString()));
|
||||
}
|
||||
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
import be.maximvdw.placeholderapi.PlaceholderAPI;
|
||||
import be.maximvdw.placeholderapi.PlaceholderReplaceEvent;
|
||||
import be.maximvdw.placeholderapi.PlaceholderReplacer;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlaceHolders.
|
||||
*/
|
||||
public class MVdWPlaceholders {
|
||||
|
||||
/** The instance. */
|
||||
static MVdWPlaceholders instance = new MVdWPlaceholders();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of PlaceHolders.
|
||||
*
|
||||
* @return single instance of PlaceHolders
|
||||
*/
|
||||
public static MVdWPlaceholders getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*/
|
||||
private MVdWPlaceholders() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public MVdWPlaceholders(Main plugin) {
|
||||
MVdWPlaceholders.plugin = plugin;
|
||||
}
|
||||
|
||||
public void loadMVdWPlaceholders() {
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
|
||||
// The plugin is enabled
|
||||
for (final PlaceHolder place : PlaceHolders.getInstance().getPlaceholders()) {
|
||||
String str = place.getIdentifier();
|
||||
if (!str.endsWith("_")) {
|
||||
PlaceholderAPI.registerPlaceholder(Main.plugin, "VotingPlugin_" + str, new PlaceholderReplacer() {
|
||||
|
||||
@Override
|
||||
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
|
||||
return place.placeholderRequest(event.getOfflinePlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(event.getOfflinePlayer()),
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (final PlaceHolder place : PlaceHolders.getInstance().getNonPlayerPlaceholders()) {
|
||||
String str = place.getIdentifier();
|
||||
if (!str.endsWith("_")) {
|
||||
PlaceholderAPI.registerPlaceholder(Main.plugin, "VotingPlugin_" + str, new PlaceholderReplacer() {
|
||||
|
||||
@Override
|
||||
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
|
||||
return place.placeholderRequest(event.getOfflinePlayer(), null,
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public abstract class PlaceHolder {
|
||||
@Getter
|
||||
private String identifier;
|
||||
@Getter
|
||||
private boolean useStartsWith = false;
|
||||
@Getter
|
||||
private String description;
|
||||
|
||||
public PlaceHolder(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public PlaceHolder(String identifier, boolean useStartsWith) {
|
||||
this.identifier = identifier;
|
||||
this.useStartsWith = useStartsWith;
|
||||
}
|
||||
|
||||
public boolean hasDescription() {
|
||||
return description != null;
|
||||
}
|
||||
|
||||
public boolean matches(String identifier) {
|
||||
if (isUseStartsWith()) {
|
||||
if (StringUtils.getInstance().startsWithIgnoreCase(identifier, getIdentifier())) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (getIdentifier().equalsIgnoreCase(identifier)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract String placeholderRequest(OfflinePlayer p, User user, String identifier);
|
||||
|
||||
public PlaceHolder useStartsWith() {
|
||||
useStartsWith = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PlaceHolder withDescription(String desc) {
|
||||
description = desc;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+406
-182
@@ -1,5 +1,6 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -8,12 +9,15 @@ import org.bukkit.entity.Player;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlaceHolders.
|
||||
@@ -35,6 +39,12 @@ public class PlaceHolders {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder> placeholders = new ArrayList<PlaceHolder>();
|
||||
|
||||
@Getter
|
||||
private ArrayList<PlaceHolder> nonPlayerPlaceholders = new ArrayList<PlaceHolder>();
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*/
|
||||
@@ -54,176 +64,17 @@ public class PlaceHolders {
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
// vote party rewards
|
||||
if (identifier.equalsIgnoreCase("VotePartyVotesNeeded")) {
|
||||
return Integer.toString(VoteParty.getInstance().getNeededVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesCurrent")) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesRequired")) {
|
||||
return Integer.toString(VoteParty.getInstance().getVotesRequired());
|
||||
for (PlaceHolder placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, null, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
|
||||
// %VotingPlugin_total% - Total votes of all vote sites
|
||||
if (identifier.equalsIgnoreCase("total")) {
|
||||
return Integer.toString(user.getMonthTotal());
|
||||
} else if (identifier.equalsIgnoreCase("alltimetotal")) {
|
||||
return Integer.toString(user.getAllTimeTotal());
|
||||
} else if (identifier.equalsIgnoreCase("lastmonthtotal")) {
|
||||
return Integer.toString(user.getLastMonthTotal());
|
||||
}
|
||||
|
||||
String[] args = identifier.split("_");
|
||||
if (args.length > 1 && args[0].equalsIgnoreCase("total")) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
return Integer.toString(user.getAllTimeTotal());
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
return Integer.toString(user.getMonthTotal());
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
return Integer.toString(user.getWeeklyTotal());
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
return Integer.toString(user.getDailyTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (identifier.equalsIgnoreCase("BestDailyTotal")) {
|
||||
return "" + user.getHighestDailyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("BestWeeklyTotal")) {
|
||||
return "" + user.getHighestWeeklyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("BestMonthlyTotal")) {
|
||||
return "" + user.getHighestMonthlyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("DailyVoteStreak")) {
|
||||
return "" + user.getDayVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("WeeklyVoteStreak")) {
|
||||
return "" + user.getWeekVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("MonthlyVoteStreak")) {
|
||||
return "" + user.getMonthVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestDailyVoteStreak")) {
|
||||
return "" + user.getBestDayVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestWeeklyVoteStreak")) {
|
||||
return "" + user.getBestWeekVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestMonthlyVoteStreak")) {
|
||||
return "" + user.getBestMonthVoteStreak();
|
||||
}
|
||||
|
||||
// %VotingPlugin_points% - Total votes of all vote sites
|
||||
if (identifier.equalsIgnoreCase("points")) {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
|
||||
// %VotingPlugin_canvote% - Whether or not a player can vote on all
|
||||
// sites
|
||||
if (identifier.equalsIgnoreCase("canvote")) {
|
||||
return Boolean.toString(user.canVoteAll());
|
||||
}
|
||||
|
||||
// %VotingPlugin_next_SITENAME% - Next time you can vote for voteSite
|
||||
if (startsWithIgnoreCase(identifier, "next")) {
|
||||
if (args.length > 1) {
|
||||
String str = args[1];
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
str += "_" + args[i];
|
||||
}
|
||||
return playerNextVote(user, str);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// %VotingPlugin_last_SITENAME% - Next time you can vote for voteSite
|
||||
if (startsWithIgnoreCase(identifier, "last")) {
|
||||
if (args.length > 1) {
|
||||
String str = args[1];
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
str += "_" + args[i];
|
||||
}
|
||||
return playerLastVote(user, str);
|
||||
}
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[0].equalsIgnoreCase("top")) {
|
||||
if (StringUtils.getInstance().isInt(args[2])) {
|
||||
int number = Integer.parseInt(args[2]);
|
||||
int num = 1;
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
} else if (args[2].equalsIgnoreCase("Position")) {
|
||||
int num = 1;
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (PlaceHolder placeholder : placeholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
return placeholder.placeholderRequest(p, user, identifier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,26 +86,399 @@ public class PlaceHolders {
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
}
|
||||
|
||||
public String playerLastVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
public void load() {
|
||||
placeholders.clear();
|
||||
nonPlayerPlaceholders.clear();
|
||||
|
||||
// older placeholders, might be removed in the future
|
||||
placeholders.add(new PlaceHolder("total") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getTotal(TopVoter.Monthly));
|
||||
}
|
||||
}.withDescription("Month total"));
|
||||
|
||||
placeholders.add(new PlaceHolder("alltimetotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getTotal(TopVoter.AllTime));
|
||||
}
|
||||
}.withDescription("Alltime total"));
|
||||
|
||||
placeholders.add(new PlaceHolder("lastmonthtotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getLastMonthTotal());
|
||||
}
|
||||
}.withDescription("Last month total"));
|
||||
|
||||
// end of older placeholders
|
||||
|
||||
placeholders.add(new PlaceHolder("DisableBroadcast") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return "" + user.getDisableBroadcast();
|
||||
}
|
||||
}.withDescription("Returns true/false if user has broadcast disabled"));
|
||||
|
||||
placeholders.add(new PlaceHolder("MilestoneCount") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return "" + user.getMilestoneCount();
|
||||
}
|
||||
}.withDescription("User milestonecount"));
|
||||
|
||||
for (final String identifier : Config.getInstance().getIdentifiers()) {
|
||||
if (Config.getInstance().getIdentifierLimit(identifier) > 0) {
|
||||
placeholders.add(new PlaceHolder("VoteShopLimit_" + identifier) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String ident) {
|
||||
return "" + user.getVoteShopIdentifierLimit(identifier);
|
||||
}
|
||||
}.withDescription("User voteshop limit for " + identifier));
|
||||
}
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
return Commands.getInstance().voteCommandLastDate(user, voteSite);
|
||||
}
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
placeholders.add(new PlaceHolder("Total_" + top.toString()) {
|
||||
|
||||
public String playerNextVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getTotal(top));
|
||||
}
|
||||
}.withDescription("User total for " + top.getName()));
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
return Commands.getInstance().voteCommandNextInfo(user, voteSite);
|
||||
}
|
||||
placeholders.add(new PlaceHolder("BestDailyTotal") {
|
||||
|
||||
public boolean startsWithIgnoreCase(String str1, String str2) {
|
||||
return str1.toLowerCase().startsWith(str2.toLowerCase());
|
||||
}
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getHighestDailyTotal());
|
||||
}
|
||||
}.withDescription("Best daily total"));
|
||||
|
||||
placeholders.add(new PlaceHolder("BestWeeklyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getHighestWeeklyTotal());
|
||||
}
|
||||
}.withDescription("Best weekly total"));
|
||||
|
||||
placeholders.add(new PlaceHolder("BestMonthlyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getHighestMonthlyTotal());
|
||||
}
|
||||
}.withDescription("Best monthly total"));
|
||||
|
||||
placeholders.add(new PlaceHolder("DailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getDayVoteStreak());
|
||||
}
|
||||
}.withDescription("Current daily votestreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder("WeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getWeekVoteStreak());
|
||||
}
|
||||
}.withDescription("Current weekly votestreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder("MonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getMonthVoteStreak());
|
||||
}
|
||||
}.withDescription("Current month votestreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder("BestDailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getBestDayVoteStreak());
|
||||
}
|
||||
}.withDescription("Best daily votestreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder("BestWeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getBestWeekVoteStreak());
|
||||
}
|
||||
}.withDescription("Best weekly votestreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder("BestMonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getBestMonthVoteStreak());
|
||||
}
|
||||
}.withDescription("Best month votestreak"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Points") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
}.withDescription("User points"));
|
||||
|
||||
placeholders.add(new PlaceHolder("CanVote") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Boolean.toString(user.canVoteAll());
|
||||
}
|
||||
}.withDescription("Return true/false if player can vote on all sites"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
placeholders.add(new PlaceHolder("Next_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Commands.getInstance().voteCommandNextInfo(user, voteSite);
|
||||
}
|
||||
}.withDescription("How long until user can vote on " + voteSite.getKey()));
|
||||
placeholders.add(new PlaceHolder("Last_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Commands.getInstance().voteCommandLastDuration(user, voteSite);
|
||||
}
|
||||
}.withDescription("How long ago user voted on " + voteSite.getKey()));
|
||||
placeholders.add(new PlaceHolder("CanVote_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return "" + user.canVoteSite(voteSite);
|
||||
}
|
||||
}.withDescription("Whether or not player can vote on " + voteSite.getKey()));
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_All_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_AllVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.AllTime);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_All_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_Month_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_Month_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_MonthVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.Monthly);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_Week_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_Week_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_WeekVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.Weekly);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_Daily_Position") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_Daily_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (num == number) {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user at postion in top voter"));
|
||||
|
||||
placeholders.add(new PlaceHolder("Top_DailyVotes_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
int num = 1;
|
||||
int number = Integer.parseInt(identifier.split("_")[2]);
|
||||
for (Entry<User, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
if (num == number) {
|
||||
return "" + entry.getKey().getTotal(TopVoter.Daily);
|
||||
}
|
||||
num++;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}.useStartsWith().withDescription("Get user votes at position in top voter"));
|
||||
|
||||
// non players
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder("VotePartyVotesCurrent") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
}
|
||||
}.withDescription("Current amount of voteparty votes"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder("VotePartyVotesNeeded") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(VoteParty.getInstance().getNeededVotes());
|
||||
}
|
||||
}.withDescription("Voteparty votes needed"));
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder("VotePartyVotesRequired") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(VoteParty.getInstance().getVotesRequired());
|
||||
}
|
||||
}.withDescription("Amount of votes needed for voteparty"));
|
||||
}
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.Updater;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CheckUpdate.
|
||||
*/
|
||||
public class CheckUpdate {
|
||||
|
||||
/** The instance. */
|
||||
static CheckUpdate instance = new CheckUpdate();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of CheckUpdate.
|
||||
*
|
||||
* @return single instance of CheckUpdate
|
||||
*/
|
||||
public static CheckUpdate getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new check update.
|
||||
*/
|
||||
private CheckUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new check update.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CheckUpdate(Main plugin) {
|
||||
CheckUpdate.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check update.
|
||||
*/
|
||||
public void checkUpdate() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case FAIL_SPIGOT: {
|
||||
plugin.getLogger().info("Failed to check for update for " + plugin.getName() + "!");
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
plugin.getLogger().info(plugin.getName() + " is up to date! Version: " + plugin.updater.getVersion());
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkUpdateBasic() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start up.
|
||||
*/
|
||||
public void startUp() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdate();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdateBasic();
|
||||
}
|
||||
}, 1000 * 60 * 1200, 1000 * 60 * 1200);
|
||||
|
||||
}
|
||||
}, 10l);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
|
||||
package com.Ben12345rocks.VotingPlugin.VoteParty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -8,10 +9,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
@@ -94,8 +95,8 @@ public class VoteParty implements Listener {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
giveRewards();
|
||||
MiscUtils.getInstance().broadcast(Config.getInstance().getVotePartyBroadcast());
|
||||
giveRewards();
|
||||
|
||||
if (Config.getInstance().getVotePartyIncreaseVotesRquired() > 0) {
|
||||
ServerData.getInstance().setVotePartyExtraRequired(ServerData.getInstance().getVotePartyExtraRequired()
|
||||
@@ -114,7 +115,7 @@ public class VoteParty implements Listener {
|
||||
public void commandVoteParty(CommandSender sender) {
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
ArrayList<String> msg = Config.getInstance().getFormatCommandsVoteParty();
|
||||
int votesRequired = Config.getInstance().getVotePartyVotesRequired();
|
||||
int votesRequired = getVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
@@ -172,22 +173,18 @@ public class VoteParty implements Listener {
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void giveReward(User user) {
|
||||
/*
|
||||
* if (PlayerUtils.getInstance().isPlayerOnline(user.getPlayerName())) { if
|
||||
* (user.getVotePartyVotes() >= Config.getInstance().getUserVotesRequired()) {
|
||||
* RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
* Config.getInstance().getVotePartyRewardsPath()); } } else {
|
||||
* user.addOfflineOtherReward("VoteParty"); }
|
||||
*/
|
||||
if (Config.getInstance().getVotePartyUserVotesRequired() > 0) {
|
||||
if (user.getVotePartyVotes() < Config.getInstance().getVotePartyUserVotesRequired()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
giveReward(user, user.isOnline());
|
||||
}
|
||||
|
||||
public void giveReward(User user, boolean online) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVotePartyRewardsPath())
|
||||
.setOnline(user.isOnline())
|
||||
.setOnline(online)
|
||||
.withPlaceHolder("VotesRequired", "" + Config.getInstance().getVotePartyVotesRequired()).send(user);
|
||||
}
|
||||
|
||||
@@ -207,11 +204,13 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVotePartyGiveAllPlayers()) {
|
||||
plugin.debug("Giving all players vote party");
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
giveReward(user);
|
||||
}
|
||||
} else {
|
||||
plugin.debug(ArrayUtils.getInstance().makeStringList(getVotedUsers()));
|
||||
for (String uuid : getVotedUsers()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
giveReward(user);
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.Ben12345rocks.VotingPlugin.VoteReminding;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteShop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.GUI.PlayerGUIs;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class VoteShop {
|
||||
static VoteShop instance = new VoteShop();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static VoteShop getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private VoteShop() {
|
||||
}
|
||||
|
||||
public VoteShop(Main plugin) {
|
||||
VoteShop.plugin = plugin;
|
||||
}
|
||||
|
||||
public void voteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
if (hasPerm) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
|
||||
if (identifier != null) {
|
||||
if (user.removePoints(points)) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier));
|
||||
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getFormatShopFailedMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.Ben12345rocks.VotingPlugin;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.Injected.RewardInject;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class VotingPluginHooks {
|
||||
private static VotingPluginHooks instance = new VotingPluginHooks();
|
||||
|
||||
public static VotingPluginHooks getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Main getMainClass() {
|
||||
return Main.plugin;
|
||||
}
|
||||
|
||||
public void addCustomReward(RewardInject inject) {
|
||||
RewardHandler.getInstance().getInjectedRewards().add(inject);
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return UserManager.getInstance();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user