Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
57795bdb23 | ||
|
|
52bbb76aad | ||
|
|
1257ac4600 | ||
|
|
64ffc38405 | ||
|
|
f8009b05bc | ||
|
|
114f217046 | ||
|
|
2de309cccc | ||
|
|
7f827857bc | ||
|
|
75e244f678 | ||
|
|
a346f28df1 | ||
|
|
afa57566da | ||
|
|
6f46469ff6 | ||
|
|
7edf33a448 | ||
|
|
4d7b30eb20 | ||
|
|
ed8d92e4a4 | ||
|
|
f7e62f5790 | ||
|
|
84146236b1 | ||
|
|
97c4ee3564 | ||
|
|
f8547c5d86 | ||
|
|
c97acf7a29 | ||
|
|
fbbb11a4b0 | ||
|
|
e517bb43b8 | ||
|
|
e43ef1ea3e | ||
|
|
7ab78f30d5 | ||
|
|
668bc34157 | ||
|
|
5f89b30628 | ||
|
|
2145c9bc40 | ||
|
|
fdb3bca7f8 | ||
|
|
c96610d137 | ||
|
|
be6414602d | ||
|
|
a7b2d8010c | ||
|
|
4ccc5def2b | ||
|
|
5378d4e372 | ||
|
|
8d37d39b1c | ||
|
|
473a83604c | ||
|
|
4f72fbab78 | ||
|
|
1f62d68aed | ||
|
|
7c063bbe68 | ||
|
|
4c11df4b37 | ||
|
|
f859caf1ee | ||
|
|
566d688b57 | ||
|
|
e4209b15c3 | ||
|
|
bd5b26805a | ||
|
|
27c43b8e8e | ||
|
|
5b719141fe | ||
|
|
f8ee0bba17 | ||
|
|
d5ea3c60a9 | ||
|
|
3be9eaf47a | ||
|
|
f385927958 |
No files matched your search
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=Cp1252
|
||||
encoding/Resources=Cp1252
|
||||
encoding/src=Cp1252
|
||||
@@ -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,18 +74,9 @@ VoteReminding:
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
|
||||
Commands:
|
||||
# Wether or not the following commands will open GUIs rather than display text
|
||||
UseGUI:
|
||||
Today: true
|
||||
TopVoter: true
|
||||
Last: true
|
||||
Next: true
|
||||
Total: true
|
||||
Vote: true
|
||||
Best: true
|
||||
Streak: true
|
||||
ActionBar:
|
||||
Message: '&cRemember to vote'
|
||||
Delay: 30
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
@@ -110,6 +90,24 @@ Commands:
|
||||
#
|
||||
# Set Message to '' (2 ') to disable message
|
||||
|
||||
Commands:
|
||||
# Wether or not the following commands will open GUIs rather than display text
|
||||
UseGUI:
|
||||
Today: true
|
||||
TopVoter: true
|
||||
Last: true
|
||||
Next: true
|
||||
Total: true
|
||||
Vote: true
|
||||
Best: true
|
||||
Streak: true
|
||||
# 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
|
||||
HelpLine: '&3&l%Command% - &3%HelpMessage%'
|
||||
@@ -166,7 +164,11 @@ 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% ago'
|
||||
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
NeverVoted: 'Never voted'
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
@@ -230,6 +232,10 @@ Format:
|
||||
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
ToggleBroadcast:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
@@ -239,6 +245,16 @@ Format:
|
||||
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
TimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
TimeFomrats:
|
||||
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
|
||||
@@ -300,42 +316,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: 'WATCH'
|
||||
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'
|
||||
@@ -344,7 +354,6 @@ GUI:
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
Slot: 6
|
||||
|
||||
# GUI for /vote url
|
||||
# And /vote if enabled in Config.yml
|
||||
@@ -405,7 +414,6 @@ GUI:
|
||||
# Remove this line for no lore
|
||||
Lore:
|
||||
- '&4Line 1'
|
||||
Slot: 0
|
||||
VoteLast:
|
||||
Name: 'VoteLast: %player%'
|
||||
BackButton: true
|
||||
@@ -436,25 +444,25 @@ GUI:
|
||||
BackButton: true
|
||||
DayTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
WeekTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
MonthTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
AllTimeTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cAllTime Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
@@ -462,19 +470,19 @@ GUI:
|
||||
Name: 'VoteBest: %player%'
|
||||
DayBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
WeekBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
MonthBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
@@ -483,37 +491,37 @@ GUI:
|
||||
BackButton: false
|
||||
CurrentDayStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentWeekStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentMonthStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestDayStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestWeekStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestMonthStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
@@ -530,6 +538,7 @@ BackButton:
|
||||
Name: '&8Back to VoteGUI'
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
@@ -546,14 +555,16 @@ Shop:
|
||||
- '&c&lCost: &c3 Voting Points'
|
||||
# Number of voting points this cost
|
||||
Cost: 3
|
||||
# Permission required, leave blank for no permission
|
||||
Permission: ''
|
||||
# Limit how many times you can buy this
|
||||
#Limit: 3
|
||||
# Rewards to run if player buys succesfully
|
||||
Rewards:
|
||||
Items:
|
||||
Diamond:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
# Slot
|
||||
Slot: 0
|
||||
Amount: 1
|
||||
|
||||
# ------------------------------------------------
|
||||
# Extra Rewards
|
||||
@@ -597,6 +608,8 @@ VoteParty:
|
||||
Enabled: false
|
||||
# Number of votes required to give rewards
|
||||
VotesRequired: 20
|
||||
# Increase the amount of votes required on each vote party reached
|
||||
#IncreaseVotesRquired: 10
|
||||
# If true, players who did not vote to reach the votes required will
|
||||
# recieve the reward
|
||||
GiveAllPlayers: false
|
||||
@@ -611,11 +624,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:
|
||||
@@ -628,13 +648,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
|
||||
@@ -665,10 +685,11 @@ VoteStreak:
|
||||
|
||||
|
||||
# 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: []
|
||||
|
||||
|
||||
@@ -677,12 +698,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
|
||||
@@ -710,6 +732,7 @@ EnableMonthlyAwards: true
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
# Using 1-10 will reward players in first to tenth place with the same reward
|
||||
1:
|
||||
Rewards:
|
||||
Messages:
|
||||
@@ -748,7 +771,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
|
||||
@@ -759,10 +782,6 @@ PointsOnVote: 1
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
DisableCheckOnWorldChange: false
|
||||
|
||||
# Debug
|
||||
Debug: false
|
||||
|
||||
@@ -794,31 +813,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
|
||||
@@ -834,6 +844,58 @@ 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
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: 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: true
|
||||
#CheckNameMojang: false
|
||||
|
||||
# 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,7 @@ 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:
|
||||
description: Vote command
|
||||
@@ -27,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
|
||||
@@ -57,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
|
||||
@@ -93,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
|
||||
@@ -120,9 +108,6 @@ commands:
|
||||
adminvotevote:
|
||||
description: Command Alias
|
||||
aliases: [avvote, fakevote]
|
||||
adminvoteTriggerPlayerVoteEvent:
|
||||
description: Command Alias
|
||||
aliases: avTriggerPlayerVoteEvent
|
||||
adminvotesetpoints:
|
||||
description: Command Alias
|
||||
aliases: avsetpoints
|
||||
@@ -198,6 +183,18 @@ 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
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
@@ -217,4 +214,6 @@ permissions:
|
||||
VotingPlugin.NoRemind:
|
||||
description: Ignore vote reminding
|
||||
default: false
|
||||
VotingPlugin.Sign.Create:
|
||||
description: Permission to create sign
|
||||
|
||||
+86
-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.12.7</version>
|
||||
<version>5.16.2</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.12.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.13.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -189,5 +265,11 @@
|
||||
<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>
|
||||
</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 {
|
||||
@@ -320,10 +321,10 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterAllTimeScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
public void sendTopVoterAllTimeScoreBoard(final Player player, int page) {
|
||||
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);
|
||||
@@ -346,8 +347,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
@@ -361,10 +361,10 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterDailyScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
public void sendTopVoterDailyScoreBoard(final Player player, int page) {
|
||||
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) {
|
||||
@@ -378,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);
|
||||
@@ -387,8 +387,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
@@ -402,10 +401,10 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterMonthlyScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
public void sendTopVoterMonthlyScoreBoard(final Player player, int page) {
|
||||
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) {
|
||||
@@ -419,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);
|
||||
@@ -428,8 +427,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
@@ -443,10 +441,10 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterWeeklyScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
public void sendTopVoterWeeklyScoreBoard(final Player player, int page) {
|
||||
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) {
|
||||
@@ -460,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);
|
||||
@@ -469,8 +467,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
|
||||
@@ -485,8 +482,8 @@ public class Commands {
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendVoteTodayScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
public void sendVoteTodayScoreBoard(final Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().getOptions().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
|
||||
String[] voteToday = voteToday();
|
||||
@@ -508,8 +505,7 @@ public class Commands {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
}
|
||||
}, 90);
|
||||
|
||||
@@ -540,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>();
|
||||
@@ -555,7 +551,7 @@ public class Commands {
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
plugin.voteToday.put(user, times);
|
||||
plugin.getVoteToday().put(user, times);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -595,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) {
|
||||
@@ -605,11 +602,89 @@ 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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -713,10 +788,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);
|
||||
@@ -749,10 +824,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()) {
|
||||
@@ -781,7 +856,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) {
|
||||
@@ -805,11 +880,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);
|
||||
}
|
||||
}
|
||||
@@ -842,10 +917,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,20 +8,22 @@ 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.EditGUIValueType;
|
||||
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.ArrayUtils;
|
||||
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 +54,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 +110,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 +136,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 +154,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 +163,99 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetPriority", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.DIAMOND), "Priority", voteSite.getPriority(),
|
||||
EditGUIValueType.NUMBER) {
|
||||
|
||||
@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, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().setPriority(voteSite.getKey(), (int) value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetServiceSite", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.DIAMOND), "ServiceSite", voteSite.getServiceSite(),
|
||||
EditGUIValueType.STRING) {
|
||||
|
||||
@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, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setServiceSite(siteName, (String) value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetName", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.DIAMOND), "Name", voteSite.getDisplayName(),
|
||||
EditGUIValueType.STRING) {
|
||||
|
||||
@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, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().setDisplayName(voteSite.getKey(), (String) value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteURL", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.DIAMOND), "VoteURL", voteSite.getVoteURL(),
|
||||
EditGUIValueType.STRING) {
|
||||
|
||||
@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, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteURL(siteName, (String) value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteDelay", new String[0], new ItemStack(Material.STONE)) {
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.DIAMOND), "VoteDelay", voteSite.getVoteDelay(),
|
||||
EditGUIValueType.NUMBER) {
|
||||
|
||||
@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, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelay(siteName, (int) value);
|
||||
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 ItemBuilder(Material.DIAMOND), "Enabled", voteSite.isEnabled(),
|
||||
EditGUIValueType.BOOLEAN) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + ConfigVoteSites.getInstance().getVoteSiteEnabled(voteSite.getKey()),
|
||||
new BooleanListener() {
|
||||
@Override
|
||||
public void setValue(Player player, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setEnabled(siteName, (boolean) 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 ItemBuilder(Material.DIAMOND), "ForceOffline", voteSite.isGiveOffline(),
|
||||
EditGUIValueType.BOOLEAN) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void setValue(Player player, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setForceOffline(siteName, (boolean) value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.DIAMOND), "VoteDelayDaily",
|
||||
voteSite.isVoteDelayDaily(), EditGUIValueType.BOOLEAN) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Object value) {
|
||||
VoteSite voteSite = (VoteSite) getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelayDaily(siteName, (boolean) value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@@ -5,13 +5,14 @@ import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
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 +24,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 +109,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,7 +157,7 @@ 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) {
|
||||
@@ -181,7 +182,7 @@ public class PlayerGUIs {
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
VoteShop.getInstance().voteShop(player);
|
||||
openVoteShop(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,6 +250,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 +424,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,24 +461,14 @@ 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) {
|
||||
|
||||
@@ -404,6 +492,7 @@ public class PlayerGUIs {
|
||||
}.addData("player", entry.getKey().getPlayerName()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Config.getInstance().getGUIVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
@@ -427,6 +516,7 @@ public class PlayerGUIs {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
@@ -437,37 +527,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 +546,7 @@ public class PlayerGUIs {
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
@@ -523,7 +594,7 @@ public class PlayerGUIs {
|
||||
count++;
|
||||
}
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteURLAlreadyVotedItemSection());
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(Config.getInstance().getVoteURLCanVoteItemSection());
|
||||
@@ -541,14 +612,18 @@ public class PlayerGUIs {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
if (Config.getInstance().isCommandsVoteRewardFromVoteURL()
|
||||
&& event.getClick().equals(ClickType.RIGHT)) {
|
||||
voteReward(player, voteSite.getKey());
|
||||
} else {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -596,7 +671,7 @@ public class PlayerGUIs {
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.WATCH).setName("&4Last Vote")
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.CLOCK).setName("&4Last Vote")
|
||||
.addLoreLine(Commands.getInstance().voteCommandLastLine(user, site))) {
|
||||
|
||||
@Override
|
||||
@@ -633,31 +708,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) {
|
||||
|
||||
}
|
||||
@@ -671,10 +734,6 @@ public class PlayerGUIs {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
+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) {
|
||||
|
||||
@@ -7,8 +7,15 @@ import java.util.Set;
|
||||
|
||||
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.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
|
||||
/**
|
||||
@@ -31,6 +38,183 @@ public class Config extends YMLFile {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@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.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;
|
||||
|
||||
@ConfigDataInt(path = "ConvertDelay", defaultValue = 30000)
|
||||
@Getter
|
||||
private int convertDelay;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableDailyRewards")
|
||||
@Getter
|
||||
private boolean enableDailyRewards = false;
|
||||
|
||||
@ConfigDataInt(path = "DelayBetweenUpdates")
|
||||
@Getter
|
||||
private int delayBetweenUpdates = 3;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableNoServiceSiteMessage")
|
||||
@Getter
|
||||
private boolean disableNoServiceSiteMessage = 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;
|
||||
|
||||
/**
|
||||
* Instantiates a new config.
|
||||
*/
|
||||
@@ -38,59 +222,6 @@ public class Config extends YMLFile {
|
||||
super(new File(Main.plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
@@ -105,63 +236,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 boolean getCountFakeVotes() {
|
||||
return getData().getBoolean("CountFakeVotes", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative reward enabled.
|
||||
*
|
||||
@@ -216,24 +290,8 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily award rewards path
|
||||
*
|
||||
* @param pos
|
||||
* the pos
|
||||
* @return the daily award rewards
|
||||
*/
|
||||
public String getDailyAwardRewardsPath(int pos) {
|
||||
return "DailyAwards." + pos + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily awards enabled.
|
||||
*
|
||||
* @return the daily awards enabled
|
||||
*/
|
||||
public boolean getDailyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableDailyAwards");
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,53 +308,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.
|
||||
*
|
||||
@@ -363,15 +374,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.
|
||||
*
|
||||
@@ -561,14 +563,8 @@ 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;
|
||||
}
|
||||
@Getter
|
||||
private int formatPageSize = 10;
|
||||
|
||||
public String getFormatPrevPage() {
|
||||
return getData().getString("Format.PrevPage", "&aPrevious Page");
|
||||
@@ -807,6 +803,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");
|
||||
}
|
||||
@@ -839,17 +851,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) {
|
||||
@@ -869,8 +872,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() {
|
||||
@@ -889,24 +903,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.
|
||||
*
|
||||
@@ -946,24 +942,8 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly award rewards.
|
||||
*
|
||||
* @param pos
|
||||
* the pos
|
||||
* @return the monthly award rewards
|
||||
*/
|
||||
public String getMonthlyAwardRewardsPath(int pos) {
|
||||
return "MonthlyAwards." + pos + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly awards enabled.
|
||||
*
|
||||
* @return the monthly awards enabled
|
||||
*/
|
||||
public boolean getMonthlyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableMonthlyAwards");
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -979,10 +959,6 @@ public class Config extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getMySql() {
|
||||
return getData().getConfigurationSection("MySQL");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
@@ -1018,15 +994,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.
|
||||
*
|
||||
@@ -1115,7 +1082,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() {
|
||||
@@ -1149,6 +1116,10 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteParty.GiveAllPlayers");
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRquired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
@@ -1157,15 +1128,6 @@ 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";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party votes required.
|
||||
*
|
||||
@@ -1224,10 +1186,18 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("VoteShopBackButton", true);
|
||||
}
|
||||
|
||||
public boolean getVoteShopEnabled() {
|
||||
return getData().getBoolean("VoteShopEnabled", true);
|
||||
}
|
||||
|
||||
public String getVoteShopName() {
|
||||
return getData().getString("GUI.VoteShopName", "VoteShop");
|
||||
}
|
||||
|
||||
public String getVoteShopPermission(String ident) {
|
||||
return getData().getString("Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site items.
|
||||
*
|
||||
@@ -1357,24 +1327,8 @@ public class Config extends YMLFile {
|
||||
return getData().getBoolean("GUI.VoteURL.ViewAllUrlsButtonEnabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly award rewards.
|
||||
*
|
||||
* @param pos
|
||||
* the pos
|
||||
* @return the weekly award rewards
|
||||
*/
|
||||
public String getWeeklyAwardRewardsPath(int pos) {
|
||||
return "WeeklyAwards." + pos + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly awards enabled.
|
||||
*
|
||||
* @return the weekly awards enabled
|
||||
*/
|
||||
public boolean getWeeklyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableWeeklyAwards");
|
||||
public String getWeeklyAwardRewardsPath(String path) {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1390,100 +1344,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
|
||||
@@ -124,6 +124,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
public boolean getWaitUntilVoteDelay(String siteName) {
|
||||
return getData(siteName).getBoolean("WaitUntilVoteDelay", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
@@ -151,6 +151,10 @@ public class ServerData {
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
@@ -238,6 +242,11 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
|
||||
+14
-38
@@ -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) {
|
||||
public PlayerSpecialRewardEvent(User user, SpecialRewardType type) {
|
||||
super();
|
||||
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,25 @@
|
||||
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,7 +24,8 @@ public class VotePartyEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public VotePartyEvent() {
|
||||
@@ -30,7 +34,6 @@ public class VotePartyEvent extends Event {
|
||||
|
||||
/*
|
||||
* (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 (!PlayerUtils.getInstance().isValidUser(playerName) && !config.allowUnJoined()) {
|
||||
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);
|
||||
+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");
|
||||
+3
-4
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -7,7 +7,7 @@ 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.AdvancedCore.UserManager.UserStorage;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
@@ -58,8 +58,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
user.loginMessage();
|
||||
|
||||
if (user.getData().hasData()) {
|
||||
// give offline vote (if they voted
|
||||
// offline)
|
||||
// give offline vote (if they voted offline)
|
||||
|
||||
user.offVote();
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
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);
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
// 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;
|
||||
@@ -25,14 +25,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.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Javascript.JavascriptPlaceholderRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Logger.Logger;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Metrics.BStatsMetrics;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Metrics.MCStatsMetrics;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.CommandLoader;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
@@ -44,22 +46,28 @@ 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.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.PlaceHolders;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The Class Main.
|
||||
*/
|
||||
@@ -74,41 +82,39 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -128,43 +134,68 @@ public class Main extends JavaPlugin {
|
||||
throw new RuntimeException("Invalid Storage Method");
|
||||
}
|
||||
UserStorage cur = AdvancedCoreHook.getInstance().getStorageType();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
try {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
AdvancedCoreHook.getInstance().getOptions().setStorageType(from);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
ArrayList<String> uuids = new ArrayList<String>(UserManager.getInstance().getAllUUIDs());
|
||||
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
values.put(key, user.getData().getString(key));
|
||||
}
|
||||
data.put(user, values);
|
||||
debug("[Convert] Added " + uuid);
|
||||
} catch (Exception e) {
|
||||
AdvancedCoreHook.getInstance().debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
while (uuids.size() > 0) {
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
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()) {
|
||||
String uuid = uuids.get(i);
|
||||
try {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
String value = user.getData().getValue(key);
|
||||
if (value != null && !value.isEmpty() && !value.equalsIgnoreCase("null")) {
|
||||
values.put(key, value);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
converted.add(uuid);
|
||||
data.put(user, values);
|
||||
debug("[Convert] Added " + uuid);
|
||||
} catch (Exception e) {
|
||||
AdvancedCoreHook.getInstance().debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
wait(Config.getInstance().getConvertDelay());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
uuids.removeAll(converted);
|
||||
|
||||
plugin.getLogger()
|
||||
.info("Finished getting data from " + from.toString() + " Converting " + data.size() + " users");
|
||||
|
||||
AdvancedCoreHook.getInstance().getOptions().setStorageType(to);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() != null) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
}
|
||||
|
||||
writeConvertData(data);
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Finished getting data from " + from.toString());
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
entry.getKey().getData().setString(values.getKey(), values.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().warning("Exception occoured for '" + entry.getKey().getUUID() + "': "
|
||||
+ e.getMessage() + ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
AdvancedCoreHook.getInstance().setStorageType(cur);
|
||||
AdvancedCoreHook.getInstance().getOptions().setStorageType(cur);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
plugin.getLogger().info("Finished convertting");
|
||||
@@ -184,32 +215,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,14 +234,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();
|
||||
}
|
||||
@@ -253,7 +252,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(".", "_"));
|
||||
}
|
||||
@@ -292,12 +291,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) {
|
||||
@@ -310,14 +323,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() {
|
||||
|
||||
@@ -362,7 +367,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);
|
||||
}
|
||||
@@ -541,14 +546,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") {
|
||||
@@ -567,14 +572,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") {
|
||||
@@ -588,56 +593,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") {
|
||||
@@ -665,7 +670,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
@@ -683,7 +687,6 @@ public class Main extends JavaPlugin {
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
@@ -692,11 +695,9 @@ public class Main extends JavaPlugin {
|
||||
|
||||
setupFiles();
|
||||
loadVoteSites();
|
||||
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();
|
||||
@@ -715,11 +716,11 @@ 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"));
|
||||
|
||||
@@ -744,16 +745,46 @@ public class Main extends JavaPlugin {
|
||||
|
||||
loadTimer();
|
||||
|
||||
PlaceHolders.getInstance().load();
|
||||
|
||||
// set columns
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
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("DailyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("WeeklyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("DayVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("BestDayVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("WeekVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("BestWeekVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("VotePartyVotes", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MonthVoteStreak", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("Points", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("HighestDailyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MileStoneTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("AllTimeTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("HighestMonthlyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MilestoneCount", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
AdvancedCoreHook.getInstance().getMysql().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
@@ -765,23 +796,27 @@ 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
|
||||
public void run() {
|
||||
plugin.getLogger()
|
||||
.warning("Detected an issue with voting sites, check the plugin startup log for more details");
|
||||
plugin.getLogger().warning(
|
||||
"Detected an issue with voting sites, check the plugin startup log for more details");
|
||||
}
|
||||
}, 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");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -824,6 +859,7 @@ 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);
|
||||
|
||||
@@ -843,19 +879,17 @@ 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();
|
||||
PlaceHolders.getInstance().load();
|
||||
// loadTimer();
|
||||
|
||||
}
|
||||
|
||||
public void setUpdate(boolean update) {
|
||||
this.update = update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup files.
|
||||
*/
|
||||
@@ -863,6 +897,7 @@ public class Main extends JavaPlugin {
|
||||
try {
|
||||
config = Config.getInstance();
|
||||
config.setup();
|
||||
config.loadValues();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@@ -898,55 +933,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,4 +996,30 @@ public class Main extends JavaPlugin {
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
}
|
||||
|
||||
private void writeConvertData(HashMap<User, HashMap<String, String>> data) {
|
||||
boolean checkInt = AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL);
|
||||
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
String value = values.getValue();
|
||||
if (value != null && !value.equalsIgnoreCase("null")) {
|
||||
if (checkInt) {
|
||||
if (StringUtils.getInstance().isInt(value)) {
|
||||
entry.getKey().getData().setInt(values.getKey(), Integer.parseInt(value));
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
} else {
|
||||
entry.getKey().getData().setString(values.getKey(), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().warning("Exception occoured for '" + entry.getKey().getUUID() + "': "
|
||||
+ e.getMessage() + ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,15 +14,17 @@ import java.util.stream.Collectors;
|
||||
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.SpecialRewards.SpecialRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
@@ -30,7 +32,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;
|
||||
@@ -204,7 +206,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() && now.getYear() != lastVote.getYear()) {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() || now.getYear() != lastVote.getYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -257,12 +259,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");
|
||||
}
|
||||
@@ -279,6 +281,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("BestWeekVoteStreak");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getDailyTotal() {
|
||||
return getUserData().getInt("DailyTotal");
|
||||
}
|
||||
@@ -287,6 +290,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");
|
||||
@@ -359,6 +366,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("MilestoneCount", getAllTimeTotal());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public int getMonthTotal() {
|
||||
return getData().getInt("MonthTotal");
|
||||
}
|
||||
@@ -399,10 +407,29 @@ 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");
|
||||
}
|
||||
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");
|
||||
}
|
||||
@@ -411,25 +438,13 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
return getData().getInt("WeekVoteStreak");
|
||||
}
|
||||
|
||||
/**
|
||||
* Give daily top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveDailyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getDailyAwardRewardsPath(place))
|
||||
public void giveDailyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getDailyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Daily").send(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give monthly top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveMonthlyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMonthlyAwardRewardsPath(place))
|
||||
public void giveMonthlyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMonthlyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Monthly").send(this);
|
||||
}
|
||||
|
||||
@@ -437,18 +452,18 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -458,37 +473,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("MonthlyTopVoter")) {
|
||||
String st = str.substring("MontlyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
giveMonthlyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("WeeklyTopVoter")) {
|
||||
String st = str.substring("WeeklyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
giveWeeklyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("DailyTopVoter")) {
|
||||
String st = str.substring("DailyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
giveDailyTopVoterAward(place);
|
||||
SpecialRewards.getInstance().giveMilestoneVoteReward(this, true, votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,7 +484,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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -513,14 +498,8 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Give weekly top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveWeeklyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getWeeklyAwardRewardsPath(place))
|
||||
public void giveWeeklyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getWeeklyAwardRewardsPath(path))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Weekly").send(this);
|
||||
}
|
||||
|
||||
@@ -530,7 +509,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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,11 +528,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");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -569,6 +548,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) {
|
||||
@@ -608,11 +591,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -630,17 +613,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -651,9 +628,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);
|
||||
}
|
||||
@@ -670,6 +648,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
getData().setInt("BestWeekVoteStreak", streak);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setDailyTotal(int total) {
|
||||
getUserData().setInt("DailyTotal", total);
|
||||
}
|
||||
@@ -681,6 +660,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);
|
||||
@@ -725,6 +708,7 @@ public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
getData().setInt("MilestoneCount", value);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setMonthTotal(int total) {
|
||||
getData().setInt("MonthTotal", total);
|
||||
}
|
||||
@@ -772,10 +756,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);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteSite.
|
||||
*/
|
||||
@@ -27,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.
|
||||
*
|
||||
@@ -84,16 +111,22 @@ public class VoteSite {
|
||||
if (!user.isVanished()) {
|
||||
String playerName = user.getPlayerName();
|
||||
String bc = StringUtils.getInstance().colorize(config.getFormatBroadCastMsg());
|
||||
bc = bc.replace("%player%", playerName).replace("%SiteName%", getDisplayName());
|
||||
MiscUtils.getInstance().broadcast(bc);
|
||||
}
|
||||
}
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("player", playerName);
|
||||
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()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the displayName
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
MiscUtils.getInstance().broadcast(bc, players);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,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.
|
||||
*
|
||||
@@ -170,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));
|
||||
}
|
||||
@@ -202,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");
|
||||
}
|
||||
|
||||
}
|
||||
+35
-14
@@ -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()) {
|
||||
@@ -51,19 +63,28 @@ public enum TopVoter {
|
||||
}
|
||||
|
||||
public TopVoter prev() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return Daily;
|
||||
case Daily:
|
||||
return Weekly;
|
||||
case Monthly:
|
||||
return AllTime;
|
||||
case Weekly:
|
||||
return Monthly;
|
||||
default:
|
||||
return AllTime;
|
||||
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
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;
|
||||
}
|
||||
return TopVoter.values()[prev];
|
||||
}
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
}
|
||||
@@ -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,65 +66,85 @@ 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);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
private HashMap<Integer, String> handlePlaces(Set<String> places) {
|
||||
HashMap<Integer, String> place = new HashMap<Integer, String>();
|
||||
for (String p : places) {
|
||||
String[] data = p.split("-");
|
||||
try {
|
||||
if (data.length > 1) {
|
||||
for (int i = Integer.parseInt(data[0]); i < Integer.parseInt(data[1]); i++) {
|
||||
place.put(i, p);
|
||||
}
|
||||
} else {
|
||||
place.put(Integer.parseInt(data[0]), p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return place;
|
||||
}
|
||||
|
||||
@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) {
|
||||
if (user.getTotal(TopVoter.Daily) == 0 && user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
} else {
|
||||
user.addDayVoteStreak();
|
||||
SpecialRewards.getInstance().checkVoteStreak(user, "Day");
|
||||
}
|
||||
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()) {
|
||||
Set<String> places = Config.getInstance().getDailyPossibleRewardPlaces();
|
||||
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 {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveDailyTopVoterAward(i);
|
||||
if (places.containsKey(i)) {
|
||||
user.giveDailyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getDailyTotal();
|
||||
lastTotal = user.getTotal(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
resetDailyTotals();
|
||||
resetTotals(TopVoter.Daily);
|
||||
|
||||
}
|
||||
|
||||
@@ -132,45 +152,45 @@ 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");
|
||||
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()) {
|
||||
Set<String> places = Config.getInstance().getMonthlyPossibleRewardPlaces();
|
||||
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 {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveMonthlyTopVoterAward(i);
|
||||
if (places.containsKey(i)) {
|
||||
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()) {
|
||||
@@ -180,7 +200,6 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
@@ -193,44 +212,44 @@ 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");
|
||||
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()) {
|
||||
Set<String> places = Config.getInstance().getWeeklyPossibleRewardPlaces();
|
||||
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 {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveWeeklyTopVoterAward(i);
|
||||
if (places.containsKey(i)) {
|
||||
user.giveWeeklyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getWeeklyTotal();
|
||||
lastTotal = user.getTotal(TopVoter.Weekly);
|
||||
}
|
||||
}
|
||||
resetWeeklyTotals();
|
||||
resetTotals(TopVoter.Weekly);
|
||||
|
||||
}
|
||||
|
||||
@@ -238,29 +257,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,56 +293,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();
|
||||
}
|
||||
|
||||
@@ -357,7 +332,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());
|
||||
@@ -397,7 +372,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());
|
||||
@@ -437,7 +412,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());
|
||||
@@ -472,7 +447,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%";
|
||||
@@ -500,7 +476,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));
|
||||
@@ -509,7 +485,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);
|
||||
}
|
||||
|
||||
@@ -524,7 +500,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%";
|
||||
@@ -556,7 +533,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());
|
||||
@@ -595,53 +572,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,115 @@
|
||||
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;
|
||||
|
||||
// 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.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() {
|
||||
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() {
|
||||
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;
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
|
||||
public PlaceHolder(String identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public PlaceHolder(String identifier, boolean useStartsWith) {
|
||||
this.identifier = identifier;
|
||||
this.useStartsWith = useStartsWith;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
+343
-185
@@ -1,19 +1,23 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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.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 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.
|
||||
*/
|
||||
@@ -51,205 +61,353 @@ public class PlaceHolders {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
public synchronized String getPlaceHolder(Player p, String identifier) {
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
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_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(Config.getInstance().getVotePartyVotesRequired());
|
||||
}
|
||||
|
||||
// %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);
|
||||
}
|
||||
}
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public String playerLastVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("alltimetotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getTotal(TopVoter.AllTime));
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("lastmonthtotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getLastMonthTotal());
|
||||
}
|
||||
});
|
||||
|
||||
// end of older placeholders
|
||||
|
||||
placeholders.add(new PlaceHolder("DisableBroadcast") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return "" + user.getDisableBroadcast();
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("MilestoneCount") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return "" + user.getMilestoneCount();
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("BestWeeklyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getHighestWeeklyTotal());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("BestMonthlyTotal") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getHighestMonthlyTotal());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("DailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getDayVoteStreak());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("WeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getWeekVoteStreak());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("MonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getMonthVoteStreak());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("BestDailyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getBestDayVoteStreak());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("BestWeeklyVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getBestWeekVoteStreak());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("BestMonthVoteStreak") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getBestMonthVoteStreak());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("Points") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
});
|
||||
|
||||
placeholders.add(new PlaceHolder("CanVote") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Boolean.toString(user.canVoteAll());
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
placeholders.add(new PlaceHolder("Last_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Commands.getInstance().voteCommandLastDuration(user, voteSite);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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 "";
|
||||
}
|
||||
});
|
||||
|
||||
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());
|
||||
|
||||
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 "";
|
||||
}
|
||||
});
|
||||
|
||||
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());
|
||||
|
||||
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 "";
|
||||
}
|
||||
});
|
||||
|
||||
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());
|
||||
|
||||
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 "";
|
||||
}
|
||||
});
|
||||
|
||||
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());
|
||||
|
||||
// non players
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder("VotePartyVotesCurrent") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
}
|
||||
});
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder("VotePartyVotesNeeded") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(VoteParty.getInstance().getNeededVotes());
|
||||
}
|
||||
});
|
||||
|
||||
nonPlayerPlaceholders.add(new PlaceHolder("VotePartyVotesRequired") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(OfflinePlayer p, User user, String identifier) {
|
||||
return Integer.toString(VoteParty.getInstance().getVotesRequired());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
@@ -86,8 +87,8 @@ public class VoteParty implements Listener {
|
||||
* Check.
|
||||
*/
|
||||
public void check() {
|
||||
if (getTotalVotes() >= Config.getInstance().getVotePartyVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - Config.getInstance().getVotePartyVotesRequired());
|
||||
if (getTotalVotes() >= getVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
@@ -96,6 +97,11 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
giveRewards();
|
||||
MiscUtils.getInstance().broadcast(Config.getInstance().getVotePartyBroadcast());
|
||||
|
||||
if (Config.getInstance().getVotePartyIncreaseVotesRquired() > 0) {
|
||||
ServerData.getInstance().setVotePartyExtraRequired(ServerData.getInstance().getVotePartyExtraRequired()
|
||||
+ Config.getInstance().getVotePartyIncreaseVotesRquired());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -109,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>();
|
||||
@@ -129,7 +135,7 @@ public class VoteParty implements Listener {
|
||||
* @return the needed votes
|
||||
*/
|
||||
public int getNeededVotes() {
|
||||
int votesRequired = Config.getInstance().getVotePartyVotesRequired();
|
||||
int votesRequired = getVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
return neededVotes;
|
||||
@@ -158,13 +164,16 @@ public class VoteParty implements Listener {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Give reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void giveReward(User user) {
|
||||
public int getVotesRequired() {
|
||||
int required = Config.getInstance().getVotePartyVotesRequired();
|
||||
int extra = ServerData.getInstance().getVotePartyExtraRequired();
|
||||
if (extra > 0) {
|
||||
return required + extra;
|
||||
}
|
||||
return required;
|
||||
}
|
||||
|
||||
public void giveReward(User user, boolean online) {
|
||||
/*
|
||||
* if (PlayerUtils.getInstance().isPlayerOnline(user.getPlayerName())) { if
|
||||
* (user.getVotePartyVotes() >= Config.getInstance().getUserVotesRequired()) {
|
||||
@@ -173,10 +182,14 @@ public class VoteParty implements Listener {
|
||||
* user.addOfflineOtherReward("VoteParty"); }
|
||||
*/
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVotePartyRewardsPath())
|
||||
.setOnline(user.isOnline())
|
||||
.setOnline(online)
|
||||
.withPlaceHolder("VotesRequired", "" + Config.getInstance().getVotePartyVotesRequired()).send(user);
|
||||
}
|
||||
|
||||
public void giveReward(User user) {
|
||||
giveReward(user, user.isOnline());
|
||||
}
|
||||
|
||||
/**
|
||||
* Give rewards.
|
||||
*/
|
||||
|
||||
@@ -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,78 +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.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) {
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user