Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a78624eafb | ||
|
|
3249a43f4a | ||
|
|
8e15ba0a3a | ||
|
|
25969f35e0 | ||
|
|
6625bf9830 | ||
|
|
a925dcfd88 | ||
|
|
40357def84 | ||
|
|
b4806abf70 | ||
|
|
f847c033fd | ||
|
|
2919d23fd5 | ||
|
|
78412f4717 | ||
|
|
438504a344 | ||
|
|
d27bc2580f | ||
|
|
665865c5b3 | ||
|
|
d4124c78c2 | ||
|
|
63acc39588 | ||
|
|
46d7a3e95c | ||
|
|
39e5b54af6 | ||
|
|
1a47862d22 | ||
|
|
63c73b8871 | ||
|
|
3bfab3518b | ||
|
|
843d47cfb5 | ||
|
|
f7617eba61 | ||
|
|
1c95d37ce4 | ||
|
|
db65b564a5 | ||
|
|
6f88e126e4 | ||
|
|
25ea0b3a37 | ||
|
|
d3bdcc762f | ||
|
|
d72eb0e2a7 | ||
|
|
7b3a458b25 | ||
|
|
e2b79072d0 | ||
|
|
7845741cec | ||
|
|
6e2497dee7 | ||
|
|
7982c3df80 | ||
|
|
a7701f27f1 | ||
|
|
bbe95bf83a | ||
|
|
4e944df7f2 | ||
|
|
6461aac03d | ||
|
|
1ece7935a2 | ||
|
|
e130261a75 | ||
|
|
c65c241b4d | ||
|
|
9876e8e77b | ||
|
|
674c41fec2 | ||
|
|
6c295ec07f | ||
|
|
332b7b667e | ||
|
|
173bd381a5 | ||
|
|
6154efdd50 | ||
|
|
ee0dcf8019 | ||
|
|
6a4740f729 | ||
|
|
ccf58be365 | ||
|
|
b871278d82 | ||
|
|
90bc2dd3ee | ||
|
|
a85b9dce23 | ||
|
|
a171fad307 | ||
|
|
eba230e5c0 | ||
|
|
ffd1f616d4 | ||
|
|
4dfbf0c71f | ||
|
|
c97616eb8d | ||
|
|
6039bb12b8 | ||
|
|
11bf99faf9 | ||
|
|
cbfde9bedd | ||
|
|
0ab0fa5fb5 | ||
|
|
fd460787c3 | ||
|
|
524d22d37a | ||
|
|
220368d037 | ||
|
|
5d86c5297d | ||
|
|
7d69f1e496 | ||
|
|
e2784c6b17 | ||
|
|
f9ce8f325d | ||
|
|
b059fc644a | ||
|
|
5c7e5d2d59 | ||
|
|
3b4dde335d | ||
|
|
f00ca81c28 | ||
|
|
36ef5e15cf | ||
|
|
9a122fb46d | ||
|
|
17fc78a15f | ||
|
|
0718f0976d | ||
|
|
580e7d3061 | ||
|
|
29af36a9e9 | ||
|
|
56d39722cb | ||
|
|
6a202d4768 | ||
|
|
d399684bfa | ||
|
|
1a0da65c66 | ||
|
|
463b303f2e | ||
|
|
abf0e2bebb | ||
|
|
29670f8c22 | ||
|
|
7b08d6806b | ||
|
|
3211e22963 | ||
|
|
2634639f6b | ||
|
|
0798110743 | ||
|
|
2f90e112b1 | ||
|
|
661ea3ce94 | ||
|
|
8d6e95927c | ||
|
|
c138edccc8 | ||
|
|
e59b171aae | ||
|
|
36cfe6c9c6 | ||
|
|
45a413c3a6 | ||
|
|
a640582278 | ||
|
|
94122a1c80 | ||
|
|
0448278ba1 | ||
|
|
097bff23a2 | ||
|
|
be76d8f4af | ||
|
|
6122805c0d | ||
|
|
392d5cb17a | ||
|
|
ec1352d52b | ||
|
|
c3a4db1ac8 | ||
|
|
442eb35a4f | ||
|
|
d0851a9365 | ||
|
|
5273745be5 | ||
|
|
ca937f6879 | ||
|
|
a4c4fa5556 | ||
|
|
480c303f2f | ||
|
|
347640f346 | ||
|
|
1d8314c0eb | ||
|
|
20d95baea9 | ||
|
|
510f400c1b | ||
|
|
c49d0b3ede | ||
|
|
ff197cb6b6 | ||
|
|
9e4605258b | ||
|
|
c54e8bc8bd | ||
|
|
fe937b8f8d | ||
|
|
d262b3689a | ||
|
|
aac5226fce | ||
|
|
1d1b9722ac | ||
|
|
94193501ba | ||
|
|
2b142316dc | ||
|
|
a06124e49c | ||
|
|
c1bd04f117 | ||
|
|
4272d15a8b | ||
|
|
0537dad68e | ||
|
|
c1f09a6bd9 | ||
|
|
69ea7c71b3 | ||
|
|
3052f28b2c | ||
|
|
892d23e0d0 | ||
|
|
b217edeadf | ||
|
|
aa4ad384c1 | ||
|
|
8021024b48 | ||
|
|
d3f246d048 | ||
|
|
9c2dfcab06 | ||
|
|
8b4224a034 | ||
|
|
61bf0007c1 | ||
|
|
151559c50e | ||
|
|
2dccf6e790 | ||
|
|
bc510b1ba0 | ||
|
|
0253d86b8d | ||
|
|
59cd31a6c8 | ||
|
|
068b24bd39 | ||
|
|
7f06797f5f | ||
|
|
3e2bdf4772 | ||
|
|
3b049299b1 | ||
|
|
05670bebeb | ||
|
|
81f73590a6 | ||
|
|
163e4cdadb | ||
|
|
512c02e501 | ||
|
|
25ef8ba315 | ||
|
|
8966feb35a | ||
|
|
0d29be48c7 | ||
|
|
bc2827659d | ||
|
|
0a72247a5d | ||
|
|
a102ec3566 | ||
|
|
f91b02d572 | ||
|
|
0f00741151 | ||
|
|
922302082f | ||
|
|
24e1fbb6e5 | ||
|
|
3026a2d48f | ||
|
|
58101bfea0 | ||
|
|
0a9e46ee85 | ||
|
|
fd67e45c58 | ||
|
|
b6af6de2df | ||
|
|
173051829e | ||
|
|
8a9ef4811f | ||
|
|
4fd6d580b1 | ||
|
|
415970101c | ||
|
|
668dcdd8b4 | ||
|
|
bf24533b54 | ||
|
|
b2daada576 | ||
|
|
9dd2c58134 | ||
|
|
7674c68bc7 | ||
|
|
0b3b0b29f5 | ||
|
|
60370a1a83 | ||
|
|
3bf273e854 | ||
|
|
a8e53c9b62 | ||
|
|
3015cd9604 | ||
|
|
839119e0a9 | ||
|
|
409a0665cc | ||
|
|
0549fe9c21 | ||
|
|
f047bb6176 | ||
|
|
ad04b7e966 | ||
|
|
2591cbf029 | ||
|
|
8213e07c74 | ||
|
|
972f9581e3 | ||
|
|
2e17b3defd | ||
|
|
76dbfb8fdf | ||
|
|
8fd206b119 | ||
|
|
9c6e514234 | ||
|
|
eb66ccb90d | ||
|
|
c004dc6106 | ||
|
|
f54ccbd7b2 | ||
|
|
8cdd0b713b | ||
|
|
2562e749db | ||
|
|
1a1e5d84bb | ||
|
|
d4d23035e3 | ||
|
|
5e334e4a8a | ||
|
|
22991efccf | ||
|
|
5341fbc3ba | ||
|
|
2e0fbd01e6 | ||
|
|
d1d395d9b3 | ||
|
|
9aeedac2ad | ||
|
|
265ed68e0f | ||
|
|
b73daaf917 | ||
|
|
39d8e414f4 | ||
|
|
693541dd00 | ||
|
|
5dce8031c5 | ||
|
|
babef8ccf3 | ||
|
|
7a881206ca | ||
|
|
aed8ecca26 | ||
|
|
25dab3157a | ||
|
|
81d8b535ee | ||
|
|
c94802a141 | ||
|
|
85e31f8292 | ||
|
|
da642cb3b2 | ||
|
|
96c707eca4 | ||
|
|
ce5c469637 | ||
|
|
4126c4a7a1 | ||
|
|
fb430a930b | ||
|
|
2c6f8c79c2 | ||
|
|
1b94f23ff2 | ||
|
|
72c0a88fc1 | ||
|
|
e532987c6a | ||
|
|
2168d92b12 | ||
|
|
d68758f34e | ||
|
|
e1b7844501 | ||
|
|
01b6ed185b | ||
|
|
3ee31012ce | ||
|
|
ba312961b8 | ||
|
|
a2484969ee | ||
|
|
470196741c | ||
|
|
2abce5ebe7 | ||
|
|
20f775c119 | ||
|
|
e0821ed2b1 | ||
|
|
6fbcc89fc8 | ||
|
|
11f86194b0 | ||
|
|
46c112d2ea | ||
|
|
0269578e5e | ||
|
|
fc14b19d9f | ||
|
|
9c25f848c6 | ||
|
|
b7f53aabfb | ||
|
|
926a009085 | ||
|
|
f0737861de | ||
|
|
8e14a92813 | ||
|
|
78fc8069b3 | ||
|
|
eed98ed638 | ||
|
|
f3653c20f6 | ||
|
|
675f4bb6e9 | ||
|
|
4dbb8b7360 | ||
|
|
5040ee2946 | ||
|
|
d7e1408c30 | ||
|
|
73fda9027a | ||
|
|
b762c6000f | ||
|
|
16dcd85807 | ||
|
|
d9b5fcf250 | ||
|
|
b85f49010b | ||
|
|
42b64b86bd | ||
|
|
266014cbe2 | ||
|
|
1e27e28a33 | ||
|
|
1c530c18ce | ||
|
|
c2ebd2251e | ||
|
|
c2fb84dc61 | ||
|
|
39e21bffe7 | ||
|
|
226b6eb01e | ||
|
|
76a40fd889 | ||
|
|
32f43e7713 | ||
|
|
601e57572f | ||
|
|
4a8bd40a8b | ||
|
|
8294e99eeb | ||
|
|
162e7f7faa | ||
|
|
7463074b5a | ||
|
|
bbec19d5c9 | ||
|
|
72ed4223c4 | ||
|
|
603656248b | ||
|
|
4455a0254f | ||
|
|
3227c47d9b | ||
|
|
bf6885875f | ||
|
|
72934d1286 | ||
|
|
2a4840814d | ||
|
|
8b8e8acbc8 | ||
|
|
a4ff2d8dcf | ||
|
|
a6ca0c8121 | ||
|
|
f3e88859d3 | ||
|
|
7249159ec9 | ||
|
|
61c3eccb19 | ||
|
|
4ec800c83e | ||
|
|
20e42b0ae7 | ||
|
|
d95becce22 | ||
|
|
04fd38a10d | ||
|
|
a30b2319f5 | ||
|
|
a1b08f6dd0 | ||
|
|
614193716f | ||
|
|
b68ac4cdd5 | ||
|
|
3767ca2883 | ||
|
|
73b7abf3e6 | ||
|
|
285719ae28 | ||
|
|
22fd1ac1e4 | ||
|
|
6127a2ab23 | ||
|
|
0054b6e06f | ||
|
|
b0f1e0bcb6 | ||
|
|
ddd0dba728 | ||
|
|
9595164f69 | ||
|
|
66092ba3fd | ||
|
|
5c41c7f4c9 | ||
|
|
dfa772af4b | ||
|
|
78f33661aa | ||
|
|
45f2bb2c72 | ||
|
|
f20c7a58ac | ||
|
|
4d1b37c37b | ||
|
|
d323cd7691 | ||
|
|
67fc73b530 | ||
|
|
13872fd9d1 | ||
|
|
a76da52a0a | ||
|
|
36fabe10a6 | ||
|
|
eada7af420 | ||
|
|
63fc7d64be | ||
|
|
0ed5b12f8b | ||
|
|
504f9edbb2 | ||
|
|
8060ece2eb | ||
|
|
254442fa2e | ||
|
|
febead9d5a | ||
|
|
d8cd0c278d | ||
|
|
fe0d7cd671 | ||
|
|
c9d8878bb3 | ||
|
|
0f450e9b60 | ||
|
|
667d0b544e | ||
|
|
6e1e6bd928 | ||
|
|
1cfc447445 | ||
|
|
6d3e68e548 | ||
|
|
855dde196e | ||
|
|
d5a9e1012a | ||
|
|
f5d67833b2 | ||
|
|
a1eb2f63e5 | ||
|
|
a882b8d86f | ||
|
|
0a745ae4c0 | ||
|
|
d38a0549d3 | ||
|
|
6e6394f1fb | ||
|
|
ce58e12740 | ||
|
|
2411354a5f | ||
|
|
13efd0c482 | ||
|
|
8fce74f30d | ||
|
|
3f54c05f86 | ||
|
|
dd1cf02c49 | ||
|
|
b462373dfc | ||
|
|
c6e5d008d2 | ||
|
|
9a91561304 | ||
|
|
1c6981e538 | ||
|
|
b6e366ff9d | ||
|
|
ca0fbe7e3b | ||
|
|
27d8b3e718 | ||
|
|
8430609d0f | ||
|
|
8fe5e87999 | ||
|
|
6b985e19c2 | ||
|
|
4636cc78b2 | ||
|
|
8c66b50749 | ||
|
|
7f6e95d47e | ||
|
|
cd60ade45f | ||
|
|
f82945b97b | ||
|
|
a3e9651378 | ||
|
|
a764ca0ed7 | ||
|
|
d21464560a | ||
|
|
88c5dc7c86 | ||
|
|
b2b2c710c5 | ||
|
|
4175e2d36a | ||
|
|
a84adb367d | ||
|
|
7368158707 | ||
|
|
5d3c1cb553 | ||
|
|
cb1206db0b | ||
|
|
03396e447f | ||
|
|
6dec0826af | ||
|
|
f443f77dfe | ||
|
|
5c4636d8c2 | ||
|
|
51c6c4066b | ||
|
|
161fc6da95 | ||
|
|
aba23f355e | ||
|
|
ac78b4d350 |
No files matched your search
@@ -0,0 +1,11 @@
|
||||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "maven" # See documentation for possible values
|
||||
directory: "/VotingPlugin/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
@@ -1,17 +0,0 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 20
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 5
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- Priority
|
||||
- nonstale
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
@@ -0,0 +1,24 @@
|
||||
name: Deploy Javadoc
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Deploy JavaDoc 🚀
|
||||
uses: MathieuSoysal/Javadoc-publisher.yml@main
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
javadoc-branch: gh-pages
|
||||
java-version: 17
|
||||
target-folder: ''
|
||||
project: maven # or gradle
|
||||
# subdirectories: moduleA moduleB #for subdirectories support, needs to be run with custom command
|
||||
custom-command: mvn -f VotingPlugin/pom.xml deploy -P javadoc javadoc:aggregate
|
||||
javadoc-source-folder: 'VotingPlugin/target/apidocs'
|
||||
@@ -0,0 +1,27 @@
|
||||
# This workflow warns and then closes issues and PRs that have had no activity for a specified amount of time.
|
||||
#
|
||||
# You can adjust the behavior by modifying this file.
|
||||
# For more information, see:
|
||||
# https://github.com/actions/stale
|
||||
name: Mark stale issues and pull requests
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '19 16 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'Stale issue message'
|
||||
stale-pr-message: 'Stale pull request message'
|
||||
stale-issue-label: 'no-issue-activity'
|
||||
stale-pr-label: 'no-pr-activity'
|
||||
@@ -2,10 +2,6 @@
|
||||
Plugin on SpigotMC
|
||||
https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/BenCodez/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
@@ -23,19 +19,6 @@ https://github.com/BenCodez/VotingPlugin/blob/master/VotingPlugin/Resources/LICE
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
BACKUP/OLD WAY
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.BenCodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
Versions:
|
||||
LATEST - latest stable release
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# --------------------------
|
||||
##########################################
|
||||
# Bungee Setup
|
||||
# Only if using votingplugin bungee to send votes
|
||||
# REQUIRES RESTART FOR CHANGES TO TAKE EFFECT
|
||||
# --------------------------
|
||||
##########################################
|
||||
|
||||
# Plugin using bungee, requires plugin on bungee server
|
||||
UseBungeecord: false
|
||||
@@ -12,7 +12,7 @@ UseBungeecord: false
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
@@ -62,8 +62,49 @@ Server: PleaseSet
|
||||
# Can edit via /av gui
|
||||
BungeeVotePartyRewards: {}
|
||||
|
||||
# -----------------------------
|
||||
# For socket setup below only
|
||||
# -----------------------------
|
||||
# List of commands to run on bungee party
|
||||
# This runs a one time command only
|
||||
BungeeVotePartyGlobalCommands: []
|
||||
|
||||
####################################################################################
|
||||
# Global mysql data handle for between server commmunications
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
# This will create a different table then from users storing server info to process
|
||||
#
|
||||
# If you use this you need to enable this on BungeeSettings.yml on each server with votingplugin
|
||||
# Make sure server name is set correctly in BungeeSettings.yml or this will not work correctly
|
||||
#
|
||||
# Please use PLUGINMESSAGING for this, SOCKETS should work as well, but not fully tested
|
||||
#
|
||||
# This will make votes cache until time change has finished processing
|
||||
# In the event a server is offline or time change fails, the time change process
|
||||
# will continue after a set amount of time (in essense skipping a specific server)
|
||||
# This will also respect blocked servers in bungeeconfig.yml
|
||||
GlobalData:
|
||||
Enabled: false
|
||||
# Use existing mysql connection from config.yml
|
||||
UseMainMySQL: true
|
||||
# Mysql settings only used if above is false
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Must be the same on all servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
##########################################
|
||||
# For socket setup
|
||||
# Recommend to try PLUGINMESSAGING setup first
|
||||
# Options hidden by default to avoid confusion
|
||||
##########################################
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
+315
-196
@@ -4,10 +4,13 @@
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki
|
||||
# Config is sorted in sections
|
||||
# Use Control + F to search with Notepad++
|
||||
#
|
||||
|
||||
|
||||
###########################################
|
||||
# User storage
|
||||
###########################################
|
||||
# Valid Options:
|
||||
# - SQLITE
|
||||
# - FLAT
|
||||
# - MYSQL
|
||||
DataStorage: SQLITE
|
||||
|
||||
@@ -33,22 +36,10 @@ MySQL:
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# --------------------
|
||||
# AllowUnJoined options
|
||||
# May need to set to true for bungee setup
|
||||
# --------------------
|
||||
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
# VoteReminding
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
|
||||
# Configuration for VoteReminding
|
||||
# By default this should be all setup to work
|
||||
@@ -91,9 +82,9 @@ VoteReminding:
|
||||
Message: '&cRemember to vote'
|
||||
Delay: 30
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
# Format options
|
||||
###########################################
|
||||
|
||||
# Common PlacesHolders:
|
||||
# Special PlaceHolders will be commented where available
|
||||
@@ -109,6 +100,7 @@ Format:
|
||||
|
||||
# Broadcast vote message
|
||||
# Set to an empty message to disable
|
||||
# Use %NewLine% for a new line
|
||||
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
|
||||
# If true uses broadcast setting below for offline votes
|
||||
OnlyOneOfflineBroadcast: false
|
||||
@@ -120,6 +112,8 @@ Format:
|
||||
# Broadcast every x number of minutes with number of players that voted
|
||||
AlternateBroadcast:
|
||||
Enabled: false
|
||||
# Use %players% for all players names
|
||||
# Use %numberofplayers% for number of players that voted
|
||||
Broadcast: '&6[&4Broadcast&6] &2%numberofplayers% voted in the last half hour! /vote'
|
||||
# Delay in minutes
|
||||
Delay: 30
|
||||
@@ -178,6 +172,8 @@ Format:
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
LastVoted: '%times% ago'
|
||||
NeverVoted: 'Never voted'
|
||||
# Whether or not to include seconds into last voted time
|
||||
IncludeSeconds: true
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
@@ -251,6 +247,16 @@ Format:
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
# /vote givepoints command
|
||||
# Transfer between players command
|
||||
# Enable command below
|
||||
GivePoints:
|
||||
NotEnoughPoints: '&cNot enough points'
|
||||
NotJoinedServer: '&c%player% has not joined the server'
|
||||
NumberLowerThanZero: '&cNumber of points needs to be greater than 0'
|
||||
TransferFrom: '&c%transfer% points given to %touser%'
|
||||
TransferTo: '&cYou received %transfer% points from %fromuser%'
|
||||
|
||||
ToggleBroadcasts:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
@@ -302,6 +308,7 @@ Format:
|
||||
# Shop messages when using the /vote shop
|
||||
ShopPurchase: '&aYou bought the %Identifier% for %Points% Points!'
|
||||
ShopFailed: '&cYou do not have %Points% points to purchase this!'
|
||||
ShopNotPurchasable: '&cThis item is not buyable!'
|
||||
|
||||
# User not exist message, from commands such as /vote next (player)
|
||||
UserNotExist: '&cUser does not exist: %player%'
|
||||
@@ -326,11 +333,24 @@ Format:
|
||||
Weekly: 'Weekly'
|
||||
Monthly: 'Monthly'
|
||||
AllTime: 'AllTime'
|
||||
|
||||
# Invalid command messages
|
||||
InvalidCommand:
|
||||
Vote: '&4No valid arguments, see /vote help!'
|
||||
AdminVote: '&4No valid arguments, see /adminvote help!'
|
||||
|
||||
# Playernames to not be broadcasted when voting
|
||||
# case sensitive
|
||||
VotingBroadcastBlacklist: []
|
||||
|
||||
# ------------------------------------------------
|
||||
# Playernames to not be broadcasted when broadcast comes from reward file
|
||||
# case sensitive
|
||||
BroadcastBlacklist: []
|
||||
|
||||
###########################################
|
||||
# Top Voter
|
||||
# Top voter rewards available in specialrewards.yml
|
||||
# ------------------------------------------------
|
||||
###########################################
|
||||
|
||||
# Top voter blacklist
|
||||
# Hide these names from top voter lists
|
||||
@@ -366,131 +386,13 @@ MaxiumNumberOfTopVotersToLoad: 1000
|
||||
StoreTopVoters:
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# ------------------------------------------------
|
||||
# Advanced
|
||||
# Most of these values can be left untouched for most setups
|
||||
# ------------------------------------------------
|
||||
|
||||
# If true vanished players are treated as if they are offline
|
||||
TreatVanishAsOffline: false
|
||||
|
||||
# If true, cooldown check is disabled
|
||||
DisableCoolDownCheck: false
|
||||
|
||||
# If true, disable PlayerInteractEvent (for clicking signs and skulls)
|
||||
DisableInteractEvent: false
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In ticks
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
UseVoteStreaks: true
|
||||
|
||||
# If false, storing best totals will be disabled
|
||||
UseHighestTotals: true
|
||||
|
||||
# If true, /vote will open /vote gui by default
|
||||
UseVoteGUIMainCommand: false
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# If true, items given for rewards are dropped on the ground
|
||||
# If false, items will be given when there is space
|
||||
DropOnFullInv: true
|
||||
|
||||
# If true, allsites will have an extra check to prevent duplicate allsites from being given
|
||||
ExtraAllSitesCheck: false
|
||||
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# Playernames to not be broadcasted when voting
|
||||
# case sensitive
|
||||
VotingBroadcastBlacklist: []
|
||||
|
||||
# Playernames to not be broadcasted when broadcast comes from reward file
|
||||
# case sensitive
|
||||
BroadcastBlacklist: []
|
||||
|
||||
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
|
||||
# Limit monthly votes to number of days of a month multipled by the number of sites
|
||||
LimitMonthlyVotes: false
|
||||
|
||||
# This is an extra safe guard to prevent milestones
|
||||
# from being executed more than once
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# Close inventory on player vote
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# When enabled the command /vote setprimaryaccount (playername)
|
||||
# will be shown (after restart)
|
||||
# Primary account will be used instead of the players account to get
|
||||
# placeholder and other data such as vote reminding
|
||||
# Mainly to be used for alts and such
|
||||
UsePrimaryAccountForPlaceholders: false
|
||||
|
||||
# Always force placeholders to return value if the value isn't cached
|
||||
# This should prevent server from crashing when pulling placeholders on main thread
|
||||
# Only affects placeholderapi placeholders
|
||||
AlwaysWaitForCachePlaceholders: false
|
||||
|
||||
# Enable auto caching placeholders
|
||||
# Generally this works well, but if you need to cache placeholders manually set them below
|
||||
AutoCachePlaceholders: false
|
||||
|
||||
# Set which placeholders to cache at all times
|
||||
# Use for placeholders to are pulled constantly or on the main thread
|
||||
# Mainly aimed for scoreboards
|
||||
# Placeholders may auto cache in certain conditions
|
||||
# Will use additional memory, but not a lot
|
||||
# Still in early stages, please report bugs
|
||||
# Please remove VotingPlugin_ from the placeholder listed here
|
||||
CachedPlaceholders: []
|
||||
#- Total_AllTime
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
# Requires AddCustomCommand: true to be set
|
||||
CustomCommands:
|
||||
# identifier, not specific name
|
||||
command1:
|
||||
Args:
|
||||
- token
|
||||
# Message to send on command
|
||||
Message: 'token message'
|
||||
# Permission for this command
|
||||
Permission: 'votingplugin.commands.vote.token'
|
||||
# help message
|
||||
HelpMessage: 'See tokens'
|
||||
# Forces player to run this command
|
||||
Commands:
|
||||
- tokencommand
|
||||
|
||||
######################
|
||||
###########################################
|
||||
# Debug
|
||||
######################
|
||||
###########################################
|
||||
|
||||
# Debug levels:
|
||||
# NONE
|
||||
@@ -512,16 +414,83 @@ DebugInGame: false
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
# Only update in the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
###########################################
|
||||
# Placeholderapi placeholders settings
|
||||
###########################################
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
# When enabled the command /vote setprimaryaccount (playername)
|
||||
# will be shown (after restart)
|
||||
# Primary account will be used instead of the players account to get
|
||||
# placeholder and other data such as vote reminding
|
||||
# Mainly to be used for alts and such
|
||||
UsePrimaryAccountForPlaceholders: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
# Valid Options:
|
||||
# AUTOALL - Auto cache placeholders after they have been used and cache all players placeholder all the time
|
||||
# AUTO - Auto cache after they have been used and cache online players placeholders (Recommended)
|
||||
# SPECIFIC - Only cache certain placeholders for online players
|
||||
# SPECIFICALL - Only cache certain placeholders for all players
|
||||
# NONE - Don't cache any placeholders
|
||||
PlaceholderCacheLevel: AUTO
|
||||
|
||||
# Placeholder controls
|
||||
# Add _process to end of placeholder to force a return value rather than . or .. if no cached value is ready
|
||||
# Add _nocache to end of placeholder to skip cache and retrive a live value, uses a direct mysql connection, do not use on main thread
|
||||
#
|
||||
|
||||
# Set which placeholders to cache at all times
|
||||
# Use for placeholders to are pulled constantly or on the main thread
|
||||
# Mainly aimed for scoreboards that pull placeholders often
|
||||
# Placeholders may auto cache in certain conditions (if enabled above)
|
||||
# Will use additional memory, but not a lot
|
||||
# Still in early stages, please report bugs
|
||||
# Please remove VotingPlugin_ from the placeholder listed here
|
||||
CachedPlaceholders: []
|
||||
#- Total_AllTime
|
||||
|
||||
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
|
||||
# Custom placeholder returns
|
||||
# For the example below use %votingplugin_custom_enoughpoints_5%
|
||||
# DO NOT USE ON MAIN THREAD IF POSSIBLE
|
||||
# Keep everything lowercase
|
||||
# Example:
|
||||
#CustomPlaceholderReturns:
|
||||
# 'enoughpoints_5':
|
||||
# 'true': 'User has enough points'
|
||||
# 'false': 'User does not have enough points'
|
||||
CustomPlaceholderReturns: {}
|
||||
|
||||
###########################################
|
||||
# Login options
|
||||
###########################################
|
||||
|
||||
# If true vanished players are treated as if they are offline
|
||||
TreatVanishAsOffline: false
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In miliseconds, 1000 = 1 second
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe or LoginSecurity
|
||||
WaitUntilLoggedIn: true
|
||||
|
||||
###########################################
|
||||
# Disable/Enable features
|
||||
###########################################
|
||||
|
||||
# If true, cooldown check is disabled
|
||||
DisableCoolDownCheck: false
|
||||
|
||||
# If true, disable PlayerInteractEvent (for clicking signs and skulls)
|
||||
DisableInteractEvent: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
@@ -532,55 +501,91 @@ DisableNoServiceSiteMessage: false
|
||||
# If true fake votes will give points and totals
|
||||
CountFakeVotes: true
|
||||
|
||||
# Give VotingPlugin.Player by default
|
||||
# Requires restart to take affect
|
||||
GiveDefaultPermission: true
|
||||
# Whether or not to disable update checks
|
||||
DisableUpdateChecking: false
|
||||
|
||||
# Permissions given by VotingPlugin.Player by default
|
||||
# Permissions listed here will no be accessible with the default permission
|
||||
DisabledDefaultPermissions: []
|
||||
# Enable per site cooldown events, requires more resources to use
|
||||
# Requires restart
|
||||
PerSiteCoolDownEvents: false
|
||||
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
# Queue votes during a time change (doesn't apply to bungee voting)
|
||||
# Votes will be given when time change is completed
|
||||
QueueVotesDuringTimeChange: false
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# Disabling this prevents offline votes from adding totals to users
|
||||
AddTotalsOffline: true
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
UseVoteStreaks: true
|
||||
|
||||
# If false, storing best totals will be disabled
|
||||
UseHighestTotals: true
|
||||
|
||||
# Enable Geyser prefix support
|
||||
# May take time before geyser players can vote properly
|
||||
# If players vote with prefix, then this is probably not needed and
|
||||
# may work better disabled
|
||||
# Geyser support is currently hit or miss
|
||||
GeyserPrefixSupport: false
|
||||
GeyserPrefix: '*'
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note: It takes 30-40 minutes before being able to download the latest build
|
||||
# You can also use /av download
|
||||
AutoDownload: false
|
||||
|
||||
# Whether or not to disable update checks
|
||||
DisableUpdateChecking: false
|
||||
# If false plugin will use offline player UUIDs
|
||||
OnlineMode: true
|
||||
|
||||
# Allow transfer of vote points between players
|
||||
AllowVotePointTransfers: false
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
#DisableCheckOnWorldChange: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
# Disable javascript processing in messages/rewards
|
||||
DisableJavascript: false
|
||||
|
||||
# Disable checking permissions on tab complete
|
||||
DisableAdvancedTab: false
|
||||
# If true, number of vote shop purchases will be tracked
|
||||
# Data will be tracked in serverdata.yml, may change in the future
|
||||
# No commands to view data currently
|
||||
TrackShopPurchases: false
|
||||
|
||||
# Load command aliases, such as /avgui
|
||||
# Requires restart to take effect
|
||||
LoadCommandAliases: true
|
||||
# Limits about of offline votesites
|
||||
# Does not currently work with bungee votes from votingplugin
|
||||
OfflineVotesLimit:
|
||||
# Enable or disable
|
||||
Enabled: false
|
||||
# Limit of votes per votesite
|
||||
Amount: 5
|
||||
|
||||
# Default worlds set for all rewards
|
||||
DefaultRewardWorlds: []
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe
|
||||
WaitUntilLoggedIn: true
|
||||
# Default blackedlisted worlds set for all rewards
|
||||
DefaultRewardBlackListedWorlds: []
|
||||
|
||||
# If enabled Config.yml will add new options as they are added to default file
|
||||
# Expiremental at this time, make backups
|
||||
# Still a WIP, DO NOT USE IN LIVE SERVERS
|
||||
# Use /av config update to do manual update if you so desire
|
||||
# Config backup will be made
|
||||
AutoConfigUpdating: false
|
||||
|
||||
###########################################
|
||||
# Skull settings
|
||||
###########################################
|
||||
|
||||
# Preload skulls to improve performance for vote top
|
||||
# when using skulls as the item to display players
|
||||
@@ -592,10 +597,53 @@ PreloadSkulls: false
|
||||
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
|
||||
LoadSkulls: true
|
||||
|
||||
# Limit number of users to load in a second
|
||||
# Effects background tasks mainly
|
||||
# set to -1 to disable (default value)
|
||||
#PlayerDataLoadLimit: 500
|
||||
###########################################
|
||||
# Extra checks on vote
|
||||
###########################################
|
||||
|
||||
# If true, allsites will have an extra check to prevent duplicate allsites from being given
|
||||
ExtraAllSitesCheck: false
|
||||
|
||||
# This is an extra safe guard to prevent milestones
|
||||
# from being executed more than once
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
|
||||
# May need to enable this for bungee setups
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
##############################################
|
||||
# Command/Permission settings
|
||||
##############################################
|
||||
|
||||
# Give VotingPlugin.Player by default
|
||||
# Requires restart to take affect
|
||||
GiveDefaultPermission: true
|
||||
|
||||
# Permissions given by VotingPlugin.Player by default
|
||||
# Permissions listed here will no be accessible with the default permission
|
||||
DisabledDefaultPermissions: []
|
||||
|
||||
# If true, /vote will open /vote gui by default
|
||||
UseVoteGUIMainCommand: false
|
||||
|
||||
# Disable checking permissions on tab complete
|
||||
# Could increase performance slightly, but probably not
|
||||
DisableAdvancedTab: false
|
||||
|
||||
# Load command aliases, such as /avgui
|
||||
# Requires restart to take effect
|
||||
LoadCommandAliases: true
|
||||
|
||||
# Use vault for permission checks
|
||||
# May not work on some plugins
|
||||
@@ -607,27 +655,104 @@ UseVaultPermissions: false
|
||||
# - PERMISSION
|
||||
DisabledCommands: []
|
||||
|
||||
# Enable Geyser prefix support
|
||||
GeyserPrefixSupport: false
|
||||
GeyserPrefix: '*'
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
# Allow transfer of vote points between players
|
||||
# Requires restart for command to load
|
||||
# Command: /vote givepoints (player) (points)
|
||||
AllowVotePointTransfers: false
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
# Requires AddCustomCommand: true to be set
|
||||
CustomCommands:
|
||||
# identifier, not specific name
|
||||
command1:
|
||||
Args:
|
||||
- token
|
||||
# Message to send on command
|
||||
Message: 'token message'
|
||||
# Permission for this command
|
||||
Permission: 'votingplugin.commands.vote.token'
|
||||
# help message
|
||||
HelpMessage: 'See tokens'
|
||||
# Forces player to run this command
|
||||
Commands:
|
||||
- tokencommand
|
||||
|
||||
##############################################
|
||||
# Background task settings
|
||||
##############################################
|
||||
|
||||
# Only update in the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Enable to true for extra player checks
|
||||
# Recommend leaving this to false
|
||||
ExtraBackgroundUpdate: false
|
||||
|
||||
##########################################
|
||||
# Inventory controls
|
||||
##########################################
|
||||
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# If true, items given for rewards are dropped on the ground
|
||||
# If false, items will be given when there is space
|
||||
DropOnFullInv: true
|
||||
|
||||
# This will prevent spam clicking GUI's to prevent exploits
|
||||
# Number is time in between clicking in milliseconds
|
||||
SpamClickTime: 150
|
||||
SpamClickTime: 100
|
||||
# Message to send when inventory forced closed when spam clicking
|
||||
# Uncomment to use
|
||||
#SpamClickMessage: '&cDetected spam clicking GUI, closing to prevent exploits'
|
||||
|
||||
# ###############################################################
|
||||
# Deprecated options, don't recommend using any of these
|
||||
|
||||
# Will force GUI's to close on every click
|
||||
AlwaysCloseInventory: false
|
||||
|
||||
# Close inventory on player vote
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# This will close GUI's if you shift click them rather than a regular
|
||||
# This can help prevent exploits
|
||||
CloseGUIOnShiftClick: false
|
||||
|
||||
###########################################
|
||||
# Purge settings
|
||||
###########################################
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
##########################################
|
||||
# Extra options
|
||||
# Options below don't need to be touched
|
||||
##########################################
|
||||
|
||||
# If enabled, data is repulled from storage on vote shop purchase
|
||||
# This prevents possible exploits with vote shop
|
||||
ExtraVoteShopCheck: true
|
||||
|
||||
# Options for request api
|
||||
# Current methods:
|
||||
# ANVIL
|
||||
@@ -638,9 +763,3 @@ RequestAPI:
|
||||
DefaultMethod: 'Anvil'
|
||||
DisabledMethods: []
|
||||
|
||||
# Shouldn't need to change this
|
||||
#AutoKillInvs: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
#DisableCheckOnWorldChange: false
|
||||
@@ -123,6 +123,7 @@ CHEST:
|
||||
# URL when clicking item in /vote (GUI version)
|
||||
URLText: '%VoteUrl%'
|
||||
# #Add Extra items
|
||||
# This extra item format works across other gui settings below
|
||||
# ExtraItems:
|
||||
# Item1:
|
||||
# Material: DIRT
|
||||
@@ -138,9 +139,14 @@ CHEST:
|
||||
# %time% = time, using timeformat below
|
||||
# %timesince% = time since vote
|
||||
Line: '&6%timeSince%'
|
||||
ClickableLinks: true
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
# Extra customization for displaying site names in GUI only
|
||||
#CustomSiteNamesDisplays:
|
||||
# Site1: site name display
|
||||
LoreLine: '%time%'
|
||||
VoteToday:
|
||||
Name: 'VoteToday'
|
||||
Line: '&6%VoteSite% : %Time%'
|
||||
@@ -160,11 +166,17 @@ CHEST:
|
||||
Lore: '&3&lVotes: &3%votes%'
|
||||
# Opens main GUI of the specific player that gets clicked
|
||||
OpenMainGUIOnClick: true
|
||||
# Close GUI when clicking on a player item
|
||||
CloseGUIOnClick: true
|
||||
SwitchItem:
|
||||
Name: '&3Switch TopVoter'
|
||||
Lore: '&bCurrently: %Top%'
|
||||
Material: 'OAK_SIGN'
|
||||
Amount: 1
|
||||
# Top voters for the switch item to use
|
||||
#TopVoters:
|
||||
#- ALLTIME
|
||||
#- MONTHLY
|
||||
# 8 Slots over from the bottom left
|
||||
# Bottom of GUI
|
||||
Slot: 7
|
||||
@@ -175,6 +187,15 @@ CHEST:
|
||||
# Item for player in GUI if use skull is false
|
||||
PlayerItem:
|
||||
Material: 'PAPER'
|
||||
Customization:
|
||||
Enabled: false
|
||||
# List of slots for top voter
|
||||
PlayerSlots: []
|
||||
# Add extra items
|
||||
ExtraItems: {}
|
||||
RemoveBottomBar: false
|
||||
# Set slot for backbutton
|
||||
BackButtonSlot: 0
|
||||
VoteTotal:
|
||||
Name: 'VoteTotal: %player%'
|
||||
BackButton: true
|
||||
@@ -277,6 +298,8 @@ CHEST:
|
||||
OpenVoteURL: false
|
||||
# If true, backbutton will be the last slot of the GUI
|
||||
EndOfGUI: false
|
||||
# If true, this item will become an exit button instead
|
||||
Exit: false
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
@@ -286,6 +309,12 @@ CHEST:
|
||||
VoteShopLimitReached: '&aYou reached your limit'
|
||||
VoteShopRequireConfirmation: false
|
||||
VoteShopDisabled: '&cVote shop disabled'
|
||||
# If true, shop gui will reopen, updating all placeholders
|
||||
VoteShopReopenGUIOnPurchase: false
|
||||
# VoteShop extra items for display only
|
||||
#VoteShopExtraItems:
|
||||
#Item:
|
||||
#...
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
@@ -349,7 +378,11 @@ BOOK:
|
||||
CanVoteText: 'Click me'
|
||||
CanVoteColor: 'GREEN'
|
||||
AlreadyVotedText: 'Click me'
|
||||
AlreadyVotedColor: 'RED'
|
||||
AlreadyVotedColor: 'RED'
|
||||
# If true the layout below is the full book text
|
||||
Manual: false
|
||||
# Only works if Manual is enabled
|
||||
TopLayout: []
|
||||
Layout:
|
||||
- '&3&l%Sitename%'
|
||||
- '[UrlText]'
|
||||
|
||||
@@ -13,10 +13,17 @@ FirstVote:
|
||||
FirstVoteToday: {}
|
||||
|
||||
# All vote rewards
|
||||
# Reward for voting on all sites in one day
|
||||
# One time reward for voting on all sites in one day
|
||||
# Enable ExtraAllSitesCheck if you get double rewards
|
||||
AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
# Give a reward for voting on all sites minus 1
|
||||
# Similar to allsites
|
||||
#AlmostAllSites:
|
||||
# Messages:
|
||||
# Player: '&aYou almost voted on all sites in 1 day!'
|
||||
|
||||
|
||||
# If true only cumulative reward at a time can be given
|
||||
@@ -33,7 +40,7 @@ Cumulative:
|
||||
# Can have multiple listed here
|
||||
'20':
|
||||
Enabled: false
|
||||
# Wether or not votes must be made in same day/week
|
||||
# Whether or not votes must be made in same day/week
|
||||
# Useful if you want to require a certain number of voting sites to be voted on
|
||||
# for a daily/weekly reward instead of all of them
|
||||
# Valid options
|
||||
@@ -42,6 +49,11 @@ Cumulative:
|
||||
# Weekly
|
||||
# Daily
|
||||
TotalToUse: AllTime
|
||||
# Blacklist recurring votes
|
||||
#BlackList:
|
||||
#- 40
|
||||
# Whether or not to gives cumulative reward for every x number of votes, default: true
|
||||
#Recurring: true
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %cumulative% cumulative votes!'
|
||||
@@ -69,6 +81,8 @@ VoteParty:
|
||||
ResetMonthly: false
|
||||
# If true, will give voteparty only once per day
|
||||
OnlyOncePerDay: false
|
||||
# If true, will give voteparty once per week only
|
||||
OnlyOncePerWeek: false
|
||||
# Reset extra votes
|
||||
ResetExtraVotesMonthly: false
|
||||
# Count votes from /av vote?
|
||||
@@ -81,7 +95,10 @@ VoteParty:
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# List of commands to execute, these only execute once.
|
||||
# %player% does not work here
|
||||
Commands: []
|
||||
GlobalCommands: []
|
||||
# List of commands to execute once
|
||||
# Only run will run
|
||||
GlobalRandomCommand: []
|
||||
# Rewards to give per player
|
||||
Rewards:
|
||||
# Uncomment below for online players to be rewarded only
|
||||
@@ -114,6 +131,7 @@ VoteStreak:
|
||||
# Number of days in a row
|
||||
# Each day requires one vote
|
||||
# Add a - to give a reward for every multiple (e.g. 2- = 2,4,6,8, and so on)
|
||||
# This may not work perfectly on bungee setups at this time
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
|
||||
@@ -2,6 +2,7 @@ VoteSites:
|
||||
# VoteSite key
|
||||
# Used for saving data for votesites
|
||||
# Use a short name if you can
|
||||
# No spaces or dots
|
||||
ExampleVoteSite:
|
||||
# Enable voteSite
|
||||
# If false, votesite will not be loaded by plugin
|
||||
@@ -60,6 +61,12 @@ VoteSites:
|
||||
DisplayItem:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Reward to run when cooldown ends for this votesite
|
||||
# Enable PerSiteCoolDownEvents in Config.yml to use this
|
||||
#CoolDownEndRewards:
|
||||
# Messages:
|
||||
# Player: '&aTime to go vote on site1'
|
||||
|
||||
# Rewards to give
|
||||
# https://github.com/BenCodez/AdvancedCore/wiki/Rewards
|
||||
|
||||
@@ -12,12 +12,59 @@ Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
# Don't use with PLUGINMESSAGING bungee setup
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# Online mode for UUIDS
|
||||
# Offline mode setups are not fully tested and are not supported currently
|
||||
OnlineMode: true
|
||||
|
||||
|
||||
####################################################################################
|
||||
# Global mysql data handle for between server commmunications
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
# This will create a different table then from users storing server info to process
|
||||
#
|
||||
# If you use this you need to enable this on BungeeSettings.yml on each server with votingplugin
|
||||
# Make sure server name is set correctly in BungeeSettings.yml or this will not work correctly
|
||||
#
|
||||
# Please use PLUGINMESSAGING for this, SOCKETS should work as well, but not fully tested
|
||||
#
|
||||
# This will make votes cache until time change has finished processing
|
||||
# In the event a server is offline or time change fails, the time change process
|
||||
# will continue after a set amount of time (in essense skipping a specific server)
|
||||
# This will also respect blocked servers
|
||||
GlobalData:
|
||||
Enabled: false
|
||||
# Use existing connection above
|
||||
UseMainMySQL: true
|
||||
# Mysql settings only used if above is false
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Must be the same on all servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# Time offset for time changes
|
||||
# Must match on all servers
|
||||
TimeHourOffSet: 0
|
||||
|
||||
####################################################################################
|
||||
|
||||
Debug: false
|
||||
# Have a reward on each server
|
||||
# If false, will send to online server only
|
||||
@@ -27,12 +74,17 @@ SendVotesToAllServers: true
|
||||
BlockedServers:
|
||||
- hub
|
||||
|
||||
|
||||
# Similar to BlockServers
|
||||
# If a server is listed then blockedservers is ignored
|
||||
WhiteListedServers: []
|
||||
|
||||
# What type of bungee setup
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
@@ -46,18 +98,25 @@ PointsOnVote: 1
|
||||
|
||||
# If true, bungee will handle adding totals
|
||||
# If false, spigot servers will EACH set their own totals
|
||||
# If false, AllowUnJoined should false on bungee, spigot servers will handle that
|
||||
# Recommened to leave true, setting to false setups are currently unsupported
|
||||
# If false, AllowUnJoined should be enabled on bungee, spigot servers will handle that
|
||||
# Recommeneded to leave enabled, setups with this disabled are currently unsupported
|
||||
BungeeManageTotals: true
|
||||
|
||||
# Support for redis
|
||||
# experimental
|
||||
RedisSupport: false
|
||||
|
||||
# Tell servers to broadcast
|
||||
# Set DisableBroadcast to true on spigot servers (BungeeSettings.yml) as well
|
||||
Broadcast: true
|
||||
|
||||
# Geyser settings
|
||||
# This may or may not work
|
||||
# Does not work on velocity currently
|
||||
GeyserSupport: false
|
||||
GeyserPrefix: '.'
|
||||
|
||||
# Time votes will be cached on proxy
|
||||
# -1 means no time limit
|
||||
# Time in days
|
||||
VoteCacheTime: -1
|
||||
|
||||
VoteParty:
|
||||
# If enabled, will trigger vote party reward
|
||||
# in BungeeSettings.yml under BungeeVotePartyReward
|
||||
@@ -77,17 +136,42 @@ VoteParty:
|
||||
Broadcast: '&aVote party has been reached!'
|
||||
|
||||
|
||||
# ----------------------------
|
||||
##########################################
|
||||
# PLUGINMESSAGING Settings
|
||||
# ----------------------------
|
||||
##########################################
|
||||
|
||||
# Applies to PLUGINMESSAGING only
|
||||
# Votes will be forwarded when specific player is online
|
||||
WaitForUserOnline: false
|
||||
|
||||
# ----------------------------
|
||||
# SOCKET Settings
|
||||
# ONLY for SOCKET method
|
||||
# ----------------------------
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
|
||||
##########################################
|
||||
# Multi-proxy setup
|
||||
# This is still a WIP, use with caution
|
||||
# Primary server needs votifier and config option enabled
|
||||
# Set socket host on each proxy and primary server set sub proxies
|
||||
# All servers should be on pluginmessaging or sockets setup
|
||||
##########################################
|
||||
|
||||
# Support for redis
|
||||
# experimental
|
||||
MultiProxySupport: false
|
||||
|
||||
# Enable on primary proxy server with votifier
|
||||
PrimaryServer: false
|
||||
|
||||
# If enabled, player will only get 1 reward on a server on the network
|
||||
# Must be enabled on all proxies for this to work
|
||||
# Must also disable sendtoallservers
|
||||
MultiProxyOneGlobalReward: false
|
||||
|
||||
# Set this for each proxy
|
||||
MultiProxySocketHost:
|
||||
Host: 0.0.0.0
|
||||
Port: 1234
|
||||
|
||||
# Set other sub proxies here
|
||||
MultiProxyServers:
|
||||
secondproxy:
|
||||
Host: 0.0.0.0
|
||||
Port: 1235
|
||||
@@ -1,5 +1,5 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
version: "${project.version}"
|
||||
main: com.bencodez.votingplugin.VotingPluginMain
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
@@ -9,18 +9,17 @@ softdepend:
|
||||
- Votifier
|
||||
- VotifierPlus
|
||||
- NuVotifier
|
||||
- CMI
|
||||
- Vault
|
||||
- PlaceholderAPI
|
||||
- ProtocolLib
|
||||
- MVdWPlaceholderAPI
|
||||
- AuthMe
|
||||
- SuperVanish
|
||||
- PremiumVanishs
|
||||
- DiscordSRV
|
||||
- PremiumVanish
|
||||
loadbefore:
|
||||
- MCPerks
|
||||
api-version: 1.13
|
||||
folia-supported: true
|
||||
libraries:
|
||||
- org.openjdk.nashorn:nashorn-core:15.3
|
||||
commands:
|
||||
@@ -57,9 +56,6 @@ commands:
|
||||
votereward:
|
||||
description: Open VoteReward GUI
|
||||
aliases: vreward
|
||||
vote?:
|
||||
description: View Help
|
||||
aliases: v?
|
||||
voteparty:
|
||||
description: A command
|
||||
aliases: vparty
|
||||
|
||||
+152
-40
@@ -1,13 +1,11 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>votingplugin</artifactId>
|
||||
<version>6.9</version>
|
||||
<artifactId>${version.art}</artifactId>
|
||||
<version>6.14</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>
|
||||
<build.number>NOTSET</build.number>
|
||||
@@ -61,7 +59,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
@@ -90,7 +88,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.4.3</version>
|
||||
<version>3.5.0</version>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
@@ -164,7 +162,7 @@
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
@@ -194,7 +192,6 @@
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>maven-central</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public</url>
|
||||
@@ -212,33 +209,31 @@
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<id>papermc</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.limework</groupId>
|
||||
<artifactId>redisbungee</artifactId>
|
||||
<version>0.6.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<version>1.18.28</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<version>1.20-R0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -256,36 +251,56 @@
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>1.1.5</version>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-velocity</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<version>3.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.11.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<properties>
|
||||
<build.profile.id>prod</build.profile.id>
|
||||
</properties>
|
||||
<id>normal</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<properties>
|
||||
<build.profile.id>normal</build.profile.id>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.bencodez</groupId>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>normal-folia</id>
|
||||
<properties>
|
||||
<build.profile.id>normal</build.profile.id>
|
||||
<version.art>votingplugin-folia</version.art>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore-folia</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -293,6 +308,9 @@
|
||||
<profile>
|
||||
<id>prod2</id>
|
||||
<properties>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>prod2</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
@@ -312,10 +330,23 @@
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<id>deploy-snapshot</id>
|
||||
<properties>
|
||||
<build.profile.id>dev</build.profile.id>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>deploy-snapshot</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
@@ -324,12 +355,93 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.13</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>deploy</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<serverId>nexus</serverId>
|
||||
<nexusUrl>https://nexus.bencodez.com/nexus/</nexusUrl>
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>javadoc</id>
|
||||
<properties>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>javadoc</build.profile.id>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
<outputDirectory>${project.basedir}/target/apidocs</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy</id>
|
||||
<properties>
|
||||
<version.art>votingplugin</version.art>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<build.profile.id>deploy</build.profile.id>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
@@ -353,7 +465,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<version>3.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
@@ -370,7 +482,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.0.0-M1</version>
|
||||
<version>3.1.1</version>
|
||||
<configuration>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
@@ -378,7 +490,7 @@
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.5.1</version>
|
||||
<version>1.6.13</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-deploy</id>
|
||||
@@ -394,7 +506,7 @@
|
||||
<skipStaging>true</skipStaging>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<!--<plugin>
|
||||
<groupId>com.github.github</groupId>
|
||||
<artifactId>site-maven-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
@@ -420,7 +532,7 @@
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@Deprecated
|
||||
@@ -10,7 +10,7 @@ public class User {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public User(Player p) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
user = VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
}
|
||||
|
||||
public void addPoints(int points) {
|
||||
|
||||
@@ -1,27 +1,38 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValue;
|
||||
import com.bencodez.advancedcore.api.user.usercache.value.DataValueBoolean;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.config.MysqlConfigSpigot;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalDataHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -38,30 +49,206 @@ public class BungeeHandler implements Listener {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyCurrent = 0;
|
||||
private int bungeeVotePartyCurrent = -2;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyRequired = 0;
|
||||
private int bungeeVotePartyRequired = -2;
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private GlobalDataHandler globalDataHandler;
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
public BungeeHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
socketHandler.closeConnection();
|
||||
clientHandler.stopConnection();
|
||||
if (socketHandler != null) {
|
||||
socketHandler.closeConnection();
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDateChange(DateChangedEvent event) {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("timeupdate", plugin.getServerDataFile().getPrevMonth() + "//"
|
||||
+ plugin.getServerDataFile().getPrevDay() + "//" + plugin.getServerDataFile().getPrevWeekDay());
|
||||
/*
|
||||
* @EventHandler public void onDateChange(DateChangedEvent event) { if
|
||||
* (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
* plugin.getPluginMessaging().sendPluginMessage("timeupdate",
|
||||
* plugin.getServerDataFile().getPrevMonth() + "//" +
|
||||
* plugin.getServerDataFile().getPrevDay() + "//" +
|
||||
* plugin.getServerDataFile().getPrevWeekDay()); } }
|
||||
*/
|
||||
|
||||
public void checkGlobalData() {
|
||||
HashMap<String, DataValue> data = globalDataHandler.getExact(plugin.getBungeeSettings().getServer());
|
||||
// plugin.debug(data.toString());
|
||||
|
||||
if (data.containsKey("ForceUpdate")) {
|
||||
boolean b = checkGlobalDataTimeValue(data.get("ForceUpdate"));
|
||||
if (b) {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "ForceUpdate", false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean forceUpdate = false;
|
||||
|
||||
if (checkGlobalDataTime(TimeType.MONTH, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.WEEK, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.DAY, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(true));
|
||||
dataToSet.put("Processing", new DataValueBoolean(false));
|
||||
globalDataHandler.setData(plugin.getBungeeSettings().getServer(), dataToSet);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
|
||||
public boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
|
||||
boolean isProcessing = false;
|
||||
if (data.containsKey(type.toString())) {
|
||||
|
||||
DataValue value = data.get(type.toString());
|
||||
boolean b = checkGlobalDataTimeValue(value);
|
||||
if (b) {
|
||||
long lastUpdated = Long.valueOf(data.get("LastUpdated").getString()).longValue();
|
||||
plugin.debug("LastUpdated: " + lastUpdated);
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastUpdated > 1000 * 60 * 60
|
||||
* 1) {
|
||||
plugin.getLogger().warning("Ignore bungee time change since it was more than 1 hour ago");
|
||||
return false;
|
||||
}
|
||||
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "Processing", true);
|
||||
isProcessing = true;
|
||||
|
||||
plugin.debug("Detected time change from bungee: " + type.toString());
|
||||
plugin.getTimeChecker().forceChanged(type, false, true, true);
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
}
|
||||
}
|
||||
return isProcessing;
|
||||
}
|
||||
|
||||
public void loadGlobalMysql() {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
if (timer != null) {
|
||||
timer.shutdown();
|
||||
try {
|
||||
timer.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
timer.shutdownNow();
|
||||
}
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkGlobalData();
|
||||
}
|
||||
}, 60, 10, TimeUnit.SECONDS);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
|
||||
}
|
||||
}, 1, 60, TimeUnit.MINUTES);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
|
||||
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
plugin.getTimeChecker().setProcessingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,6 +259,8 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
plugin.getLogger().info("Using BungeeMethod: " + method.toString());
|
||||
|
||||
loadGlobalMysql();
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
@@ -97,7 +286,7 @@ public class BungeeHandler implements Listener {
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
@@ -107,10 +296,12 @@ public class BungeeHandler implements Listener {
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
@@ -119,24 +310,41 @@ public class BungeeHandler implements Listener {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
@@ -169,12 +377,14 @@ public class BungeeHandler implements Listener {
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
plugin.debug(
|
||||
"pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
@@ -191,25 +401,42 @@ public class BungeeHandler implements Listener {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (Boolean.valueOf(args.get(4))
|
||||
|| plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast);
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
@@ -228,27 +455,36 @@ public class BungeeHandler implements Listener {
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(player));
|
||||
user.clearCache();
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(player));
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
if (args.size() > 2) {
|
||||
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
|
||||
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("BungeeTimeChange") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(2);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
args.get(1));
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
@@ -266,7 +502,7 @@ public class BungeeHandler implements Listener {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String votes = args.get(2);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid),
|
||||
args.get(1));
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
@@ -285,6 +521,16 @@ public class BungeeHandler implements Listener {
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
@@ -308,7 +554,13 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
socketHandler = new SocketHandler(plugin.getVersion(), plugin.getBungeeSettings().getSpigotServerHost(),
|
||||
plugin.getBungeeSettings().getSpigotServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug());
|
||||
plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
plugin.getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevote") {
|
||||
|
||||
@@ -319,12 +571,12 @@ public class BungeeHandler implements Listener {
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
@@ -335,6 +587,14 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeTimeChange") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevoteonline") {
|
||||
|
||||
@Override
|
||||
@@ -344,12 +604,12 @@ public class BungeeHandler implements Listener {
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
@@ -367,7 +627,7 @@ public class BungeeHandler implements Listener {
|
||||
if (data.length > 2) {
|
||||
String votes = data[0];
|
||||
String p = data[1];
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
@@ -380,7 +640,7 @@ public class BungeeHandler implements Listener {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[3];
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
@@ -396,8 +656,8 @@ public class BungeeHandler implements Listener {
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[3];
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
String p = data[2];
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
|
||||
@@ -33,7 +33,7 @@ public class VotingPluginHooks {
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return UserManager.getInstance();
|
||||
return getMainClass().getVotingPluginUserManager();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,9 +16,10 @@ import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
@@ -52,8 +53,11 @@ import com.bencodez.advancedcore.api.rewards.injected.RewardInjectInt;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectValidator;
|
||||
import com.bencodez.advancedcore.api.skull.SkullHandler;
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.yml.YMLConfig;
|
||||
import com.bencodez.advancedcore.logger.Logger;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.broadcast.BroadcastHandler;
|
||||
import com.bencodez.votingplugin.commands.CommandLoader;
|
||||
import com.bencodez.votingplugin.commands.executers.CommandAdminVote;
|
||||
@@ -78,8 +82,11 @@ import com.bencodez.votingplugin.listeners.VotingPluginUpdateEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.placeholders.MVdWPlaceholders;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceHolders;
|
||||
import com.bencodez.votingplugin.placeholders.VotingPluginExpansion;
|
||||
import com.bencodez.votingplugin.signs.Signs;
|
||||
import com.bencodez.votingplugin.specialrewards.SpecialRewards;
|
||||
import com.bencodez.votingplugin.test.VoteTester;
|
||||
import com.bencodez.votingplugin.timequeue.TimeQueueHandler;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterHandler;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -143,6 +150,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Getter
|
||||
private PlaceHolders placeholders;
|
||||
|
||||
@Getter
|
||||
private VoteTester voteTester;
|
||||
|
||||
@Getter
|
||||
private String profile = "";
|
||||
|
||||
@@ -209,19 +219,19 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
private boolean ymlError = false;
|
||||
|
||||
@Getter
|
||||
private Timer voteTimer = new Timer();
|
||||
private ScheduledExecutorService voteTimer;
|
||||
|
||||
@Getter
|
||||
private UserManager votingPluginUserManager;
|
||||
|
||||
private void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
|
||||
public void addDirectlyDefinedRewards(DirectlyDefinedReward directlyDefinedReward) {
|
||||
getRewardHandler().addDirectlyDefined(directlyDefinedReward);
|
||||
}
|
||||
|
||||
public void basicBungeeUpdate() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
VotingPluginUser user = getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.cache();
|
||||
user.offVote();
|
||||
user.checkOfflineRewards();
|
||||
}
|
||||
@@ -253,7 +263,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
if (ymlError) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -287,7 +297,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
* @return the user
|
||||
*/
|
||||
public VotingPluginUser getUser(UUID uuid) {
|
||||
return UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
return getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
}
|
||||
|
||||
private YamlConfiguration getVersionFile() {
|
||||
@@ -429,6 +439,29 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
});
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("AlmostAllSites") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
getSpecialRewardsConfig().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return getSpecialRewardsConfig().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getSpecialRewardsConfig().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
getSpecialRewardsConfig().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
// FirstVote
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("FirstVote") {
|
||||
|
||||
@@ -718,6 +751,29 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteSites." + site.getKey() + ".CoolDownEndRewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
getConfigVoteSites().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return getConfigVoteSites().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
getConfigVoteSites().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// vote streaks
|
||||
@@ -874,36 +930,35 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
getBungeeSettings().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
getRewardHandler().checkDirectlyDefined();
|
||||
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
getTimer().schedule(new TimerTask() {
|
||||
getTimer().scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null) {
|
||||
update();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 1000, 1000 * 60 * configFile.getDelayBetweenUpdates());
|
||||
}, 1000, 1000 * 60 * configFile.getDelayBetweenUpdates(), TimeUnit.MILLISECONDS);
|
||||
|
||||
getTimer().schedule(new TimerTask() {
|
||||
getTimer().scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && configFile.isExtraBackgroundUpdate()) {
|
||||
basicBungeeUpdate();
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 1000, 1000 * 30);
|
||||
}, 1000, 1000 * 30, TimeUnit.MILLISECONDS);
|
||||
|
||||
}
|
||||
}, 40L);
|
||||
@@ -954,22 +1009,45 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
* Metrics.
|
||||
*/
|
||||
private void metrics() {
|
||||
new VotingPluginMetrics().load(this);
|
||||
new VotingPluginMetrics().load(plugin);
|
||||
}
|
||||
|
||||
private void loadVoteTimer() {
|
||||
voteTimer = Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
|
||||
@Getter
|
||||
private TimeQueueHandler timeQueueHandler;
|
||||
|
||||
private void loadBungeeHandler() {
|
||||
bungeeHandler = new BungeeHandler(this);
|
||||
bungeeHandler.load();
|
||||
|
||||
if (getOptions().getServer().equalsIgnoreCase("PleaseSet")) {
|
||||
getLogger().warning("Bungeecoord is true and server name is not set, bungeecoord features may not work");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostLoad() {
|
||||
loadVersionFile();
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
|
||||
voteTester = new VoteTester(plugin);
|
||||
|
||||
loadVoteTimer();
|
||||
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
bungeeHandler = new BungeeHandler(this);
|
||||
bungeeHandler.load();
|
||||
loadBungeeHandler();
|
||||
}
|
||||
|
||||
if (getOptions().getServer().equalsIgnoreCase("PleaseSet")) {
|
||||
getLogger()
|
||||
.warning("Bungeecoord is true and server name is not set, bungeecoord features may not work");
|
||||
}
|
||||
if (!bungeeSettings.isUseBungeecoord() || !bungeeSettings.isGloblalDataEnabled()) {
|
||||
this.timeQueueHandler = new TimeQueueHandler(this);
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new VotingPluginExpansion(this).register();
|
||||
getLogger().info("Loading PlaceholderAPI expansion");
|
||||
}
|
||||
|
||||
registerCommands();
|
||||
@@ -986,7 +1064,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
coolDownCheck.checkEnabled();
|
||||
coolDownCheck.load();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -996,7 +1074,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
topVoterHandler = new TopVoterHandler(this);
|
||||
lastMonthTopVoter = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1019,7 +1097,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
topVoterHandler.register();
|
||||
|
||||
metrics();
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
metrics();
|
||||
}
|
||||
});
|
||||
|
||||
// javascript api
|
||||
getJavascriptEngineRequests().add(new JavascriptPlaceholderRequest("User") {
|
||||
@@ -1030,11 +1114,13 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
});
|
||||
getJavascriptEngine().put("VotingPluginHooks", VotingPluginHooks.getInstance());
|
||||
getJavascriptEngine().put("VotingPlugin", this);
|
||||
|
||||
loadTimer();
|
||||
|
||||
// placeholderapi loading
|
||||
placeholders = new PlaceHolders(this);
|
||||
getServerData().updatePlaceholders();
|
||||
placeholders.load();
|
||||
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("MVdWPlaceholderAPI")) {
|
||||
@@ -1048,11 +1134,12 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
@Override
|
||||
public String onRewardRequest(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
|
||||
int num, HashMap<String, String> placeholders) {
|
||||
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
|
||||
vpUser.addPoints(num);
|
||||
return null;
|
||||
VotingPluginUser vpUser = getVotingPluginUserManager().getVotingPluginUser(user);
|
||||
String str = "" + vpUser.addPoints(num);
|
||||
debug("Setting points to " + str);
|
||||
return str;
|
||||
}
|
||||
}.synchronize().addEditButton(
|
||||
}.synchronize().asPlaceholder("newpoints").addEditButton(
|
||||
new EditGUIButton(new ItemBuilder(Material.PAPER), new EditGUIValueNumber("Points", null) {
|
||||
|
||||
@Override
|
||||
@@ -1080,7 +1167,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
StringParser.getInstance().replacePlaceHolder(section.getString("Message", ""),
|
||||
placeholders),
|
||||
section.getString("Color", "BLUE"), section.getString("Style", "SOLID"),
|
||||
(double) UserManager.getInstance().getVotingPluginUser(user).getSitesVotedOn()
|
||||
(double) getVotingPluginUserManager().getVotingPluginUser(user).getSitesVotedOn()
|
||||
/ plugin.getVoteSites().size(),
|
||||
section.getInt("Delay", 30));
|
||||
}
|
||||
@@ -1093,7 +1180,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
@Override
|
||||
public String getValue(Reward reward, com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
|
||||
VotingPluginUser vUser = UserManager.getInstance().getVotingPluginUser(user);
|
||||
VotingPluginUser vUser = getVotingPluginUserManager().getVotingPluginUser(user);
|
||||
return "" + vUser.getTotal(top);
|
||||
}
|
||||
});
|
||||
@@ -1136,7 +1223,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
if (!issues) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -1174,7 +1261,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
loadVoteSites();
|
||||
|
||||
votingPluginUserManager = UserManager.getInstance();
|
||||
votingPluginUserManager = new UserManager(this);
|
||||
votingPluginUserManager.addCachingKeys();
|
||||
|
||||
setJenkinsSite("bencodez.com");
|
||||
@@ -1189,8 +1276,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onUnLoad() {
|
||||
getSigns().storeSigns();
|
||||
HandlerList.unregisterAll(plugin);
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
try {
|
||||
getBungeeHandler().close();
|
||||
@@ -1198,6 +1283,18 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
debug(e);
|
||||
}
|
||||
}
|
||||
voteTimer.shutdown();
|
||||
try {
|
||||
voteTimer.awaitTermination(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
voteTimer.shutdownNow();
|
||||
if (timeQueueHandler != null) {
|
||||
timeQueueHandler.save();
|
||||
}
|
||||
getSigns().storeSigns();
|
||||
HandlerList.unregisterAll(plugin);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
@@ -1225,7 +1322,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
Permission perm = Bukkit.getPluginManager().getPermission("VotingPlugin.Player");
|
||||
if (perm != null) {
|
||||
if (configFile.getGiveDefaultPermission()) {
|
||||
if (configFile.isGiveDefaultPermission()) {
|
||||
perm.setDefault(PermissionDefault.TRUE);
|
||||
getLogger().info("Giving VotingPlugin.Player permission by default, can be disabled in the config");
|
||||
} else {
|
||||
@@ -1254,6 +1351,10 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
pm.registerEvents(new PlayerInteract(this), this);
|
||||
}
|
||||
|
||||
if (timeQueueHandler != null) {
|
||||
pm.registerEvents(timeQueueHandler, plugin);
|
||||
}
|
||||
|
||||
pm.registerEvents(new VotingPluginUpdateEvent(this), this);
|
||||
/*
|
||||
* if (!NMSManager.getInstance().isVersion("1.12")) { pm.registerEvents(new
|
||||
@@ -1279,8 +1380,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
|
||||
private void reloadPlugin(boolean userStorage) {
|
||||
setUpdate(true);
|
||||
|
||||
configFile.reloadData();
|
||||
configFile.loadValues();
|
||||
|
||||
@@ -1291,37 +1390,52 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
gui.reloadData();
|
||||
|
||||
bungeeSettings.reloadData();
|
||||
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
if (getBungeeHandler() == null) {
|
||||
loadBungeeHandler();
|
||||
}
|
||||
if (userStorage) {
|
||||
getBungeeHandler().loadGlobalMysql();
|
||||
}
|
||||
}
|
||||
checkYMLError();
|
||||
|
||||
if (broadcastHandler != null) {
|
||||
broadcastHandler.schelude(getConfigFile().getFormatAlternateBroadcastDelay());
|
||||
broadcastHandler.schedule(getConfigFile().getFormatAlternateBroadcastDelay());
|
||||
}
|
||||
|
||||
updateAdvancedCoreHook();
|
||||
plugin.loadVoteSites();
|
||||
loadDirectlyDefined();
|
||||
|
||||
reloadAdvancedCore(userStorage);
|
||||
getOptions().setServer(bungeeSettings.getServer());
|
||||
if (userStorage) {
|
||||
placeholders.load();
|
||||
placeholders.reload();
|
||||
}
|
||||
|
||||
voteReminding.loadRemindChecking();
|
||||
coolDownCheck.checkEnabled();
|
||||
loadDirectlyDefined();
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
});
|
||||
setUpdate(true);
|
||||
}
|
||||
|
||||
private void setupFiles() {
|
||||
configFile = new Config(this);
|
||||
configFile.setup();
|
||||
|
||||
if (configFile.isAutoConfigUpdating()) {
|
||||
/*try {
|
||||
ConfigUpdater.update(plugin, "Config.yml", configFile.getdFile(),
|
||||
Arrays.asList("VoteReminding", "MySQL", "CustomCommands", "CustomPlaceholderReturns"));
|
||||
configFile.reloadData();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
}
|
||||
|
||||
configVoteSites = new ConfigVoteSites(this);
|
||||
configVoteSites.setup();
|
||||
|
||||
@@ -1341,6 +1455,9 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Loaded Files");
|
||||
}
|
||||
|
||||
@Getter
|
||||
private long lastBackgroundTaskTimeTaken = -1;
|
||||
|
||||
public void update() {
|
||||
if (update || configFile.isAlwaysUpdate()) {
|
||||
if (!updateStarted && plugin != null) {
|
||||
@@ -1355,7 +1472,6 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
plugin.debug("Starting background task, current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
int dataLoadLimit = getConfigFile().getPlayerDataLoadLimit();
|
||||
try {
|
||||
boolean extraBackgroundUpdate = configFile.isExtraBackgroundUpdate();
|
||||
long startTime = System.currentTimeMillis();
|
||||
@@ -1374,72 +1490,77 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
}
|
||||
}
|
||||
boolean topVoterIgnorePermissionUse = plugin.getConfigFile()
|
||||
.getTopVoterIgnorePermission();
|
||||
.isTopVoterIgnorePermission();
|
||||
ArrayList<String> blackList = plugin.getConfigFile().getBlackList();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
// ArrayList<String> uuids = getVotingPluginUserManager().getAllUUIDs();
|
||||
int currentDay = LocalDateTime.now().getDayOfMonth();
|
||||
int currentDataLoad = 0;
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished getting player data in " + time1 + " seconds, " + cols.size()
|
||||
+ " users, " + plugin.getStorageType().toString());
|
||||
time1 = System.currentTimeMillis();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (!user.isBanned() && !blackList.contains(user.getPlayerName())) {
|
||||
|
||||
if (!topVoterIgnorePermissionUse || !user.isTopVoterIgnore()) {
|
||||
for (TopVoter top : topVotersToCheck) {
|
||||
int total = user.getTotal(top);
|
||||
if (total > 0) {
|
||||
tempTopVoter.get(top).put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance()
|
||||
.getYearFromMili(time))) {
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (Entry<VoteSite, Long> entry : user.getLastVotes().entrySet()) {
|
||||
if (entry.getKey().isEnabled() && !entry.getKey().isHidden()) {
|
||||
long time = entry.getValue();
|
||||
if ((currentDay == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils
|
||||
.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils
|
||||
.getInstance().getYearFromMili(time))) {
|
||||
|
||||
times.put(entry.getKey(), LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
times.put(entry.getKey(),
|
||||
LocalDateTime.ofInstant(Instant.ofEpochMilli(time),
|
||||
ZoneId.systemDefault()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
voteToday.put(user.getTopVoterPlayer(), times);
|
||||
}
|
||||
}
|
||||
if (!extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
plugin.getPlaceholders().onUpdate(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
if (dataLoadLimit > 0) {
|
||||
currentDataLoad++;
|
||||
if (currentDataLoad >= dataLoadLimit) {
|
||||
currentDataLoad -= dataLoadLimit;
|
||||
Thread.sleep(1000);
|
||||
if (extraBackgroundUpdate) {
|
||||
if (user.isOnline()) {
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
if (plugin != null) {
|
||||
if (!plugin.getPlaceholders().getCacheLevel().onlineOnly()
|
||||
|| user.isOnline()) {
|
||||
plugin.getPlaceholders().onUpdate(user, false);
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + uuids.size()
|
||||
+ " users, " + plugin.getStorageType().toString() + ", data load limit: "
|
||||
+ dataLoadLimit);
|
||||
time1 = System.currentTimeMillis();
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
topVoterHandler.updateTopVoters(tempTopVoter);
|
||||
placeholders.onUpdate();
|
||||
@@ -1447,15 +1568,22 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
serverData.updateValues();
|
||||
getSigns().updateSigns();
|
||||
|
||||
checkFirstTimeLoaded();
|
||||
|
||||
plugin.getUserManager().getDataManager().clearNonNeededCachedUsers();
|
||||
plugin.extraDebug("Current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
|
||||
update = false;
|
||||
|
||||
tempTopVoter = null;
|
||||
|
||||
time1 = ((System.currentTimeMillis() - time1) / 1000);
|
||||
long totalTime = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
lastBackgroundTaskTimeTaken = totalTime;
|
||||
plugin.debug("Background task finished. Final processing took " + time1
|
||||
+ " seconds. Total time: " + totalTime + " seconds");
|
||||
plugin.extraDebug("Current cached users: "
|
||||
+ plugin.getUserManager().getDataManager().getUserDataCache().keySet().size());
|
||||
checkFirstTimeLoaded();
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (plugin != null) {
|
||||
plugin.getLogger().info("Looks like something went wrong");
|
||||
@@ -1475,6 +1603,7 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
|
||||
public void checkFirstTimeLoaded() {
|
||||
if (!firstTimeLoaded) {
|
||||
|
||||
if (getGui().isChestVoteTopUseSkull()) {
|
||||
int maxToLoad = 200;
|
||||
for (TopVoter top : topVoter.keySet()) {
|
||||
@@ -1495,7 +1624,23 @@ public class VotingPluginMain extends AdvancedCorePlugin {
|
||||
public void updateAdvancedCoreHook() {
|
||||
getJavascriptEngine().put("VotingPlugin", this);
|
||||
allowDownloadingFromSpigot(15358);
|
||||
setConfigData(configFile.getData());
|
||||
setConfigData(new YMLConfig(this, configFile.getData()) {
|
||||
|
||||
@Override
|
||||
public void setValue(String path, Object value) {
|
||||
configFile.setValue(path, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveData() {
|
||||
configFile.saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
configFile.createSection(key);
|
||||
}
|
||||
});
|
||||
if (bungeeSettings.isUseBungeecoord()) {
|
||||
getOptions().setPerServerRewards(getBungeeSettings().isPerServerRewards());
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.bencodez.votingplugin;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
public class VotingPluginMetrics {
|
||||
|
||||
@@ -66,13 +65,20 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (!plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
return "False";
|
||||
} else {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("placeholder_cache_level", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return plugin.getPlaceholders().getCacheLevel().toString();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_milestone", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -177,39 +183,30 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size();
|
||||
if (total < 1000) {
|
||||
return "<1000";
|
||||
int total = plugin.getUserManager().getAllUUIDs().size();
|
||||
if (total > 800000) {
|
||||
return ">800000";
|
||||
} else if (total > 700000) {
|
||||
return "700000-800000";
|
||||
} else if (total > 600000) {
|
||||
return "600000-700000";
|
||||
} else if (total > 500000) {
|
||||
return "500000-600000";
|
||||
} else if (total > 400000) {
|
||||
return "400000-500000";
|
||||
} else if (total > 300000) {
|
||||
return "300000-400000";
|
||||
} else if (total > 200000) {
|
||||
return "200000-300000";
|
||||
} else if (total > 100000) {
|
||||
return "100000-200000";
|
||||
} else if (total > 10000) {
|
||||
return ">10000";
|
||||
} else {
|
||||
return "1000-10000";
|
||||
return ">10000-100000";
|
||||
}
|
||||
return "<10000";
|
||||
}
|
||||
}));
|
||||
|
||||
int users = UserManager.getInstance().getAllUUIDs().size();
|
||||
if (users > 1000) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("number_of_users_in_thousands", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
|
||||
return "" + total;
|
||||
}
|
||||
}));
|
||||
}
|
||||
if (users > 10000) {
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetrics.SimplePie("number_of_users_in_thousands_plus_10", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size() / 1000;
|
||||
return "" + total;
|
||||
}
|
||||
}));
|
||||
}
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -228,28 +225,28 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getVoteRemindingEnabled();
|
||||
return "" + plugin.getConfigFile().isVoteRemindingEnabled();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterMonthly();
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterMonthly();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterWeekly();
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterWeekly();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterDaily();
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterDaily();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeemethod", new Callable<String>() {
|
||||
@@ -300,8 +297,33 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getBungeeSettings().isTriggerVotifierEvent();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("globaldata_enabled", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isGloblalDataEnabled();
|
||||
}
|
||||
}));
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("globaldata_usemainmysql", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isGloblalDataUseMainMySQL();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("persitecooldownevents", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isPerSiteCoolDownEvents();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("geyserprefixsupport", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -335,6 +357,14 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("background_task_time_taken", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getLastBackgroundTaskTimeTaken();
|
||||
}
|
||||
}));
|
||||
|
||||
if (!plugin.getBuildNumber().equals("NOTSET")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("dev_build_number", new Callable<String>() {
|
||||
|
||||
|
||||
@@ -2,9 +2,10 @@ package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -12,16 +13,15 @@ import org.bukkit.entity.Player;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
public class BroadcastHandler {
|
||||
private VotingPluginMain plugin;
|
||||
private Timer timer;
|
||||
private ScheduledExecutorService timer;
|
||||
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
public BroadcastHandler(VotingPluginMain plugin, int delay) {
|
||||
this.plugin = plugin;
|
||||
schelude(delay);
|
||||
schedule(delay);
|
||||
}
|
||||
|
||||
public void check() {
|
||||
@@ -32,12 +32,20 @@ public class BroadcastHandler {
|
||||
}
|
||||
String bc = StringParser.getInstance()
|
||||
.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
|
||||
String playersText = "";
|
||||
while (!votedPlayers.isEmpty()) {
|
||||
playersText += votedPlayers.remove();
|
||||
if (!votedPlayers.isEmpty()) {
|
||||
playersText += ", ";
|
||||
}
|
||||
}
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("numberofplayers", "" + size);
|
||||
placeholders.put("players", playersText);
|
||||
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
@@ -50,19 +58,19 @@ public class BroadcastHandler {
|
||||
votedPlayers.add(player);
|
||||
}
|
||||
|
||||
public void schelude(int delay) {
|
||||
public void schedule(int delay) {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer = new Timer();
|
||||
timer.shutdownNow();
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
} else {
|
||||
timer = new Timer();
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
timer.schedule(new TimerTask() {
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
check();
|
||||
}
|
||||
}, 1000 * 60, 1000 * 60 * delay);
|
||||
}, 60, 60 * delay, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
@@ -29,12 +29,32 @@ public class Config {
|
||||
return getData().getStringList("BlockedServers");
|
||||
}
|
||||
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getData().getStringList("WhiteListedServers");
|
||||
}
|
||||
|
||||
public boolean getBroadcast() {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public boolean getRedisSupport() {
|
||||
return getData().getBoolean("RedisSupport", false);
|
||||
public boolean getGeyserSupport() {
|
||||
return getData().getBoolean("GeyserSupport", false);
|
||||
}
|
||||
|
||||
public String getGeyserPrefix() {
|
||||
return getData().getString("GeyserPrefix", ".");
|
||||
}
|
||||
|
||||
public boolean getOnlineMode() {
|
||||
return getData().getBoolean("OnlineMode", true);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getData().getBoolean("GlobalData.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getData().getBoolean("GlobalData.UseMainMySQL", true);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
@@ -57,6 +77,34 @@ public class Config {
|
||||
return getData().getBoolean("Debug", false);
|
||||
}
|
||||
|
||||
public boolean getMultiProxySupport() {
|
||||
return getData().getBoolean("MultiProxySupport", false);
|
||||
}
|
||||
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return getData().getInt("MultiProxySocketHost.Port", 1297);
|
||||
}
|
||||
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return getData().getString("MultiProxySocketHost.Host", "");
|
||||
}
|
||||
|
||||
public boolean getMultiProxyOneGlobalReward() {
|
||||
return getData().getBoolean("MultiProxyOneGlobalReward", false);
|
||||
}
|
||||
|
||||
public Configuration getMultiProxyServersConfiguration(String s) {
|
||||
return getData().getSection("MultiProxyServers." + s);
|
||||
}
|
||||
|
||||
public Collection<String> getMultiProxyServers() {
|
||||
return getData().getSection("MultiProxyServers").getKeys();
|
||||
}
|
||||
|
||||
public boolean getPrimaryServer() {
|
||||
return getData().getBoolean("PrimaryServer", false);
|
||||
}
|
||||
|
||||
public String getFallBack() {
|
||||
return getData().getString("FallBackServer", "");
|
||||
}
|
||||
@@ -97,6 +145,10 @@ public class Config {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
|
||||
}
|
||||
|
||||
public int getVoteCacheTime() {
|
||||
return getData().getInt("VoteCacheTime", -1);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class NonVotedPlayersCache {
|
||||
@@ -53,7 +54,8 @@ public class NonVotedPlayersCache {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File yamlFile = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
@@ -62,9 +64,24 @@ public class NonVotedPlayersCache {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldnonvotedplayerscache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -84,8 +101,8 @@ public class NonVotedPlayersCache {
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI;
|
||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerChangedServerNetworkEvent;
|
||||
import com.imaginarycode.minecraft.redisbungee.events.PlayerJoinedNetworkEvent;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class RedisBungee implements Listener {
|
||||
@Getter
|
||||
private boolean enabled;
|
||||
private VotingPluginBungee plugin;
|
||||
|
||||
public RedisBungee(VotingPluginBungee plugin) {
|
||||
this.plugin = plugin;
|
||||
if (plugin.getConfig().getRedisSupport()) {
|
||||
plugin.getProxy().getPluginManager().registerListener(plugin, this);
|
||||
plugin.getLogger().info("Loaded expiremental redis support");
|
||||
enabled = true;
|
||||
} else {
|
||||
enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerJoinedNetworkEvent(PlayerJoinedNetworkEvent event) {
|
||||
plugin.login(plugin.getProxy().getPlayer(event.getUuid()));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerChangedServerNetworkEventt(PlayerChangedServerNetworkEvent event) {
|
||||
plugin.login(plugin.getProxy().getPlayer(event.getUuid()));
|
||||
}
|
||||
|
||||
public boolean isOnline(ProxiedPlayer p) {
|
||||
return RedisBungeeAPI.getRedisBungeeApi().isPlayerOnline(p.getUniqueId());
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
plugin.getProxy().getPluginManager().unregisterListener(this);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public abstract class TimeHandle {
|
||||
@Getter
|
||||
@Setter
|
||||
private String month;
|
||||
@Getter
|
||||
@Setter
|
||||
private int day;
|
||||
@Getter
|
||||
@Setter
|
||||
private int week;
|
||||
|
||||
public TimeHandle(String month, int day, int week) {
|
||||
this.month = month;
|
||||
this.day = day;
|
||||
this.week = week;
|
||||
}
|
||||
|
||||
public abstract void save();
|
||||
}
|
||||
@@ -4,9 +4,12 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.JsonConfiguration;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class VoteCache {
|
||||
@@ -52,6 +55,13 @@ public class VoteCache {
|
||||
section.set("Text", voteData.getText());
|
||||
}
|
||||
|
||||
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
|
||||
Configuration section = getData().getSection("TimedVoteCache." + num);
|
||||
section.set("Name", voteTimedQueue.getName());
|
||||
section.set("Service", voteTimedQueue.getService());
|
||||
section.set("Time", voteTimedQueue.getTime());
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
Configuration section = getData().getSection("OnlineCache." + player + "." + num);
|
||||
section.set("Name", voteData.getPlayerName());
|
||||
@@ -84,6 +94,14 @@ public class VoteCache {
|
||||
return getData().getSection("VoteCache").getKeys();
|
||||
}
|
||||
|
||||
public Configuration getTimedVoteCache(String key) {
|
||||
return getData().getSection("TimedVoteCache." + key);
|
||||
}
|
||||
|
||||
public Collection<String> getTimedVoteCache() {
|
||||
return getData().getSection("TimedVoteCache").getKeys();
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getData().getSection("VoteCache." + server).getKeys();
|
||||
}
|
||||
@@ -97,7 +115,9 @@ public class VoteCache {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
File yamlFile = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
@@ -106,9 +126,23 @@ public class VoteCache {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (yamlFile.exists()) {
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
yamlFile.renameTo(new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "oldvotecache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
data = ConfigurationProvider.getProvider(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -116,8 +150,8 @@ public class VoteCache {
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
|
||||
public void onVote(VotifierEvent event) {
|
||||
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
Vote vote = event.getVote();
|
||||
@@ -24,11 +25,13 @@ public class VoteEventBungee implements net.md_5.bungee.api.plugin.Listener {
|
||||
|
||||
if (serviceSite.isEmpty()) {
|
||||
serviceSite = "Empty";
|
||||
vote.setServiceName(serviceSite);
|
||||
}
|
||||
|
||||
plugin.vote(vote.getUsername(), serviceSite, true);
|
||||
plugin.vote(vote.getUsername(), serviceSite, true, true, 0, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,7 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@@ -18,20 +20,26 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
bungee.reload(false);
|
||||
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee"));
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
bungee.reload(true);
|
||||
sender.sendMessage(new TextComponent("&aReloading VotingPluginBungee with MySQL"));
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee with MySQL"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
bungee.vote(user, site, false);
|
||||
bungee.vote(user, site, false, true, 0, null, null);
|
||||
sender.sendMessage(new TextComponent("Sending vote"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("forcetimechange")) {
|
||||
if (args.length >= 2) {
|
||||
bungee.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
|
||||
sender.sendMessage(new TextComponent("Triggering time change: " + args[1]));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
@@ -46,17 +54,56 @@ public class VotingPluginBungeeCommand extends Command {
|
||||
new TextComponent("&aNot using socket/pluginmessage method, command unavailable"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("multiproxystatus")) {
|
||||
bungee.sendMultiProxyServerMessage("Status");
|
||||
sender.sendMessage(new TextComponent("&aSending status message"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
TextComponent[] msg = new TextComponent[4];
|
||||
TextComponent[] msg = new TextComponent[7];
|
||||
msg[0] = new TextComponent("&avotingpluginbungee reload - Reload plugin");
|
||||
msg[1] = new TextComponent("&avotingpluginbungee reloadmysql - Reload plugin including mysql");
|
||||
msg[2] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
|
||||
msg[3] = new TextComponent("&avotingpluginbungee status - Check socket connection status");
|
||||
msg[4] = new TextComponent("&avotingpluginbungee forcetimechange (timetype) - Force a time change");
|
||||
msg[5] = new TextComponent("&avotingpluginbungee voteparty force - Force a vote party");
|
||||
msg[6] = new TextComponent(
|
||||
"&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes");
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("voteparty")) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("Force")) {
|
||||
bungee.setCurrentVotePartyVotes(bungee.getCurrentVotePartyVotesRequired());
|
||||
bungee.checkVoteParty();
|
||||
sender.sendMessage(new TextComponent("Vote party forced"));
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[1].equalsIgnoreCase("SetVoteCount")) {
|
||||
if (isInt(args[2])) {
|
||||
bungee.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
|
||||
sender.sendMessage(new TextComponent("Set current vote party votes to " + args[2]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("&cYou do not have permission to do this!"));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
if (st == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,12 +25,24 @@ public class Config extends VelocityYMLFile {
|
||||
return getStringList(getNode("BlockedServers"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getStringList(getNode("WhiteListedServers"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getBroadcast() {
|
||||
return getBoolean(getNode("Broadcast"), false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
public boolean getOnlineMode() {
|
||||
return getBoolean(getNode("OnlineMode"), true);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataEnabled() {
|
||||
return getBoolean(getNode("GlobalData", "Enabled"), false);
|
||||
}
|
||||
|
||||
public boolean getGlobalDataUseMainMySQL() {
|
||||
return getBoolean(getNode("GlobalData", "UseMainMySQL"), true);
|
||||
}
|
||||
|
||||
public boolean getBungeeManageTotals() {
|
||||
@@ -41,10 +53,18 @@ public class Config extends VelocityYMLFile {
|
||||
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
public int getBungeePort() {
|
||||
return getInt(getNode("BungeeServer", "Port"), 1297);
|
||||
}
|
||||
|
||||
|
||||
public int getVoteCacheTime() {
|
||||
return getInt(getNode("VoteCacheTime"), -1);
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return getBoolean(getNode("Debug"), false);
|
||||
}
|
||||
@@ -108,4 +128,41 @@ public class Config extends VelocityYMLFile {
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
}
|
||||
|
||||
public boolean getMultiProxySupport() {
|
||||
return getBoolean(getNode("MultiProxySupport"), false);
|
||||
}
|
||||
|
||||
public boolean getMultiProxyOneGlobalReward() {
|
||||
return getBoolean(getNode("MultiProxyOneGlobalReward"), false);
|
||||
}
|
||||
|
||||
public boolean getGeyserSupport() {
|
||||
return getBoolean(getNode("GeyserSupport"), false);
|
||||
}
|
||||
|
||||
public boolean getPrimaryServer() {
|
||||
return getBoolean(getNode("PrimaryServer"), false);
|
||||
}
|
||||
|
||||
public String getGeyserPrefix() {
|
||||
return getString(getNode("GeyserPrefix"), "*");
|
||||
}
|
||||
|
||||
public ConfigurationNode getMultiProxyServers(String s) {
|
||||
return getNode("MultiProxyServers", s);
|
||||
}
|
||||
|
||||
public @NonNull Collection<? extends ConfigurationNode> getMultiProxyServers() {
|
||||
return getNode("MultiProxyServers").getChildrenMap().values();
|
||||
}
|
||||
|
||||
public String getMultiProxySocketHostHost() {
|
||||
return getString(getNode("MultiProxySocketHost", "Host"), "");
|
||||
}
|
||||
|
||||
public int getMultiProxySocketHostPort() {
|
||||
return getInt(getNode("MultiProxySocketHost", "Port"), 1297);
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -2,10 +2,10 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityJSONFile;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
public class NonVotedPlayersCache extends VelocityYMLFile {
|
||||
public class NonVotedPlayersCache extends VelocityJSONFile {
|
||||
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
|
||||
@@ -3,12 +3,13 @@ package com.bencodez.votingplugin.bungee.velocity;
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityJSONFile;
|
||||
import com.bencodez.votingplugin.bungee.OfflineBungeeVote;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class VoteCache extends VelocityYMLFile {
|
||||
public class VoteCache extends VelocityJSONFile {
|
||||
|
||||
public VoteCache(File file) {
|
||||
super(file);
|
||||
@@ -49,6 +50,13 @@ public class VoteCache extends VelocityYMLFile {
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
}
|
||||
|
||||
public void addTimedVote(int num, VoteTimeQueue voteTimedQueue) {
|
||||
String[] path = new String[] { "TimedVoteCache", "" + num };
|
||||
getNode(path, "Name").setValue(voteTimedQueue.getName());
|
||||
getNode(path, "Service").setValue(voteTimedQueue.getService());
|
||||
getNode(path, "Time").setValue(voteTimedQueue.getTime());
|
||||
}
|
||||
|
||||
public void addVoteOnline(String player, int num, OfflineBungeeVote voteData) {
|
||||
String[] path = new String[] { "OnlineCache", player, "" + num };
|
||||
|
||||
@@ -70,6 +78,10 @@ public class VoteCache extends VelocityYMLFile {
|
||||
return getKeys(getNode("OnlineCache", name));
|
||||
}
|
||||
|
||||
public ConfigurationNode getTimedVoteCache(String name) {
|
||||
return getNode("TimedVoteCache", name);
|
||||
}
|
||||
|
||||
public ConfigurationNode getOnlineVotes(String name, String num) {
|
||||
return getNode("OnlineCache", name, num);
|
||||
}
|
||||
@@ -82,6 +94,10 @@ public class VoteCache extends VelocityYMLFile {
|
||||
return getKeys(getNode("VoteCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getTimedVoteCache() {
|
||||
return getKeys(getNode("TimedVoteCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getKeys(getNode("OnlineCache", server));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.vexsoftware.votifier.velocity.event.VotifierEvent;
|
||||
|
||||
public class VoteEventVelocity {
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
public VoteEventVelocity(VotingPluginVelocity plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onVotifierEvent(VotifierEvent event) {
|
||||
final String serviceSiteVote = event.getVote().getServiceName();
|
||||
final String name = event.getVote().getUsername();
|
||||
plugin.getTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String serviceSite = serviceSiteVote;
|
||||
plugin.getLogger().info("Vote received " + name + " from service site " + serviceSite);
|
||||
if (serviceSite.isEmpty()) {
|
||||
serviceSite = "Empty";
|
||||
}
|
||||
|
||||
plugin.vote(name, serviceSite, true, false, 0, null, null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
+696
-184
File diff suppressed because it is too large.
Load diff
+48
-3
@@ -1,5 +1,6 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
@@ -33,10 +34,16 @@ public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
plugin.vote(user, site, false);
|
||||
plugin.vote(user, site, false, true, 0, null, null);
|
||||
source.sendMessage(Component.text("Sending vote").color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("forcetimechange")) {
|
||||
if (args.length >= 2) {
|
||||
plugin.getBungeeTimeChecker().forceChanged(TimeType.getTimeType(args[1]));
|
||||
source.sendMessage(Component.text("Triggering time change: " + args[1]).color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (plugin.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
source.sendMessage(
|
||||
@@ -53,17 +60,55 @@ public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
.color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("multiproxystatus")) {
|
||||
plugin.sendMultiProxyServerMessage("Status");
|
||||
source.sendMessage(Component.text("Sending status message").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
String[] msg = new String[4];
|
||||
String[] msg = new String[7];
|
||||
msg[0] = "votingpluginbungee reload - Reload plugin";
|
||||
msg[1] = "votingpluginbungee reloadmysql - Reload plugin including mysql";
|
||||
msg[2] = "votingpluginbungee vote (player) (servicesite) - Send bungee vote";
|
||||
msg[3] = "votingpluginbungee status - Check socket connection status";
|
||||
msg[4] = "&avotingpluginbungee forcetimechange (timetype) - Force a time change";
|
||||
msg[5] = "&avotingpluginbungee voteparty force - Force a vote party";
|
||||
msg[6] = "&avotingpluginbungee voteparty setvotecount (number) - Set current vote party votes";
|
||||
for (String m : msg) {
|
||||
source.sendMessage(Component.text(m).color(NamedTextColor.AQUA));
|
||||
}
|
||||
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("voteparty")) {
|
||||
if (args.length > 1) {
|
||||
if (args[1].equalsIgnoreCase("Force")) {
|
||||
plugin.setCurrentVotePartyVotes(plugin.getCurrentVotePartyVotesRequired());
|
||||
plugin.checkVoteParty();
|
||||
source.sendMessage(Component.text("Vote party forced").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[1].equalsIgnoreCase("SetVoteCount")) {
|
||||
if (isInt(args[2])) {
|
||||
plugin.setCurrentVotePartyVotes(Integer.parseInt(args[2]));
|
||||
source.sendMessage(Component.text("Set current vote party votes to " + args[2])
|
||||
.color(NamedTextColor.AQUA));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
if (st == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +1,11 @@
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -36,7 +36,7 @@ public class CommandAdminVote implements CommandExecutor {
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,12 @@ package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
@@ -91,9 +91,9 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -61,7 +61,7 @@ public class CommandVote implements CommandExecutor {
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ import com.bencodez.advancedcore.api.valuerequest.InputMethod;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
import com.bencodez.advancedcore.api.yml.editor.ConfigEditor;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteBungeeSettings;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteMilestones;
|
||||
@@ -65,6 +65,7 @@ public class AdminGUI {
|
||||
plugin.getConfigVoteSites().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
openAdminGUIVoteSiteSite(player, plugin.getVoteSite(value, true));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -130,6 +131,15 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AlmostAllSites reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("AlmostAllSites"));
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.STONE, 1).setName("&cEdit AnySiteRewards")) {
|
||||
|
||||
@Override
|
||||
@@ -157,11 +167,40 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml")) {
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder("GRASS_BLOCK").setName("&cEdit BungeeSettings.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteBungeeSettings(plugin, clickEvent.getPlayer()).open();
|
||||
new ConfigEditor(plugin, plugin.getBungeeSettings()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder("GRASS_BLOCK").setName("&cEdit Config.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ConfigEditor(plugin, plugin.getConfigFile(), plugin.getOptions().getYmlConfig(),
|
||||
plugin.getOptions().getClass()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder(Material.CHEST).setName("&cEdit GUI.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ConfigEditor(plugin, plugin.getGui()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder("GRASS_BLOCK").setName("&cEdit SpecialRewards.yml").addLoreLine("&aCurrently WIP")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ConfigEditor(plugin, plugin.getSpecialRewardsConfig()).open(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -173,6 +212,17 @@ public class AdminGUI {
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(
|
||||
new ItemBuilder(Material.STONE, 1).setName("&cBackground task time").addLoreLine("&aClick to see")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().sendMessage("Last background task time: " + plugin.getLastBackgroundTaskTimeTaken());
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
@@ -241,7 +291,13 @@ public class AdminGUI {
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
@@ -369,6 +425,29 @@ public class AdminGUI {
|
||||
});
|
||||
}
|
||||
|
||||
if (voteSite.getSiteData().isList("CoolDownEndRewards")) {
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueList("CoolDownEndRewards",
|
||||
voteSite.getSiteData().getStringList("CoolDownEndRewards")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player p, ArrayList<String> rewards) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().set(voteSite.getKey(), "CoolDownEndRewards", rewards);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cCoolDownEndRewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(), plugin.getRewardHandler()
|
||||
.getDirectlyDefined("VoteSites." + voteSite.getKey() + ".CoolDownEndRewards"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
-147
@@ -1,147 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class AdminVoteBungeeSettings extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteBungeeSettings(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Edit BungeeSettings");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.BungeeSettings");
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("UseBungeecord", plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueString("BungeeMethod", plugin.getBungeeSettings().getBungeeMethod()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}).addOptions("PLUGINMESSAGING", "SOCKETS", "MYSQL"));
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueBoolean("BungeeDebug", plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("BungeeBroadcast", plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}.addLore("Triggers a broadcast for the entire network, most cases it is best for this to be false")));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("BungeeBroadcastAlways", plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}.addLore("Whether or not to broadcast on cached votes").addLore("PLUGINMESSAGING ONLY")));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerRewards", plugin.getBungeeSettings().isPerServerRewards()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerMilestones", plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("PerServerPoints", plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(
|
||||
new EditGUIValueBoolean("TriggerVotifierEvent", plugin.getBungeeSettings().isTriggerVotifierEvent()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("Server", plugin.getBungeeSettings().getServer()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}.addLore("Server name as stated in proxy")));
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getBungeeSettings().getData().set(path, value);
|
||||
plugin.getBungeeSettings().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
|
||||
+12
-12
@@ -38,14 +38,14 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "VotingPlugin_" + identifier + " - " + placeholder.getDescription();
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "VotingPlugin_" + identifier + "";
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -56,14 +56,14 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "VotingPlugin_" + identifier + " - " + placeholder.getDescription();
|
||||
msg = "votingplugin_" + identifier + " - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "VotingPlugin_" + identifier + "";
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
@@ -82,26 +82,26 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cPlaceholders:");
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("VotingPlugin_" + identifier + " - " + placeholder.getDescription());
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("VotingPlugin_" + identifier + "");
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("VotingPlugin_" + identifier + " - " + placeholder.getDescription());
|
||||
msg.add("votingplugin_" + identifier + " - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("VotingPlugin_" + identifier + "");
|
||||
msg.add("votingplugin_" + identifier + "");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-8
@@ -14,7 +14,6 @@ import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
@@ -40,7 +39,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
@@ -54,7 +53,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
@@ -75,23 +74,23 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
msg.add("&cPlaceholders:");
|
||||
VotingPluginUser placeholderUser = user;
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
placeholderUser = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
placeholderUser = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(placeholderUser, identifier));
|
||||
}
|
||||
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
|
||||
msg.add("VotingPlugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
msg.add("votingplugin_" + identifier + " = " + placeholder.placeholderRequest(identifier));
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
+10
-10
@@ -52,7 +52,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
|
||||
// to add
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("Enabled", plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
|
||||
new EditGUIValueBoolean("Enabled", plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -70,7 +70,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.LADDER, 1), new EditGUIValueNumber(
|
||||
"IncreaseVotesRquired", plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired()) {
|
||||
"IncreaseVotesRquired", plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
@@ -106,7 +106,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("GiveAllPlayers",
|
||||
plugin.getSpecialRewardsConfig().getVotePartyGiveAllPlayers()) {
|
||||
plugin.getSpecialRewardsConfig().isVotePartyGiveAllPlayers()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -124,7 +124,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("ResetEachDay", plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
|
||||
new EditGUIValueBoolean("ResetEachDay", plugin.getSpecialRewardsConfig().isVotePartyResetEachDay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -133,7 +133,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("ResetWeekly", plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {
|
||||
new EditGUIValueBoolean("ResetWeekly", plugin.getSpecialRewardsConfig().isVotePartyResetWeekly()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -142,7 +142,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("ResetMonthly", plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {
|
||||
new EditGUIValueBoolean("ResetMonthly", plugin.getSpecialRewardsConfig().isVotePartyResetMonthly()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -151,7 +151,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("OnlyOncePerDay",
|
||||
plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
|
||||
plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -169,7 +169,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountFakeVotes",
|
||||
plugin.getSpecialRewardsConfig().getVotePartyCountFakeVotes()) {
|
||||
plugin.getSpecialRewardsConfig().isVotePartyCountFakeVotes()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -178,7 +178,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueBoolean("CountOfflineVotes",
|
||||
plugin.getSpecialRewardsConfig().getVotePartyCountOfflineVotes()) {
|
||||
plugin.getSpecialRewardsConfig().isVotePartyCountOfflineVotes()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean name) {
|
||||
@@ -196,7 +196,7 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueList("Commands", plugin.getSpecialRewardsConfig().getVotePartyCommands()) {
|
||||
new EditGUIValueList("Commands", plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, ArrayList<String> value) {
|
||||
|
||||
+28
-1
@@ -1,6 +1,8 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.voteshop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -85,7 +87,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
|
||||
// display item
|
||||
ConfigurationSection displayItemData = plugin.getGui().getChestShopIdentifierSection(identifier);
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.valueOf(displayItemData.getString("Material")), 1),
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(displayItemData.getString("Material")).setAmount(1),
|
||||
new EditGUIValueString("Material", displayItemData.getString("Material")) {
|
||||
|
||||
@Override
|
||||
@@ -109,6 +111,31 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
setPathData(getKey(), value);
|
||||
}
|
||||
}));
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(player.getInventory().getItemInMainHand().clone()).addLoreLine("&cClick to add")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ItemBuilder item = new ItemBuilder(clickEvent.getPlayer().getInventory().getItemInMainHand().clone());
|
||||
Map<String, Object> map = item.getConfiguration(false);
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
setPathData(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(player.getInventory().getItemInMainHand().clone())
|
||||
.addLoreLine("&cClick to add with exact data")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ItemBuilder item = new ItemBuilder(clickEvent.getPlayer().getInventory().getItemInMainHand().clone());
|
||||
Map<String, Object> map = item.getConfiguration(true);
|
||||
for (Entry<String, Object> entry : map.entrySet()) {
|
||||
setPathData("ItemStack." + entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.DISPENSER, 1).setName("&cRewards")) {
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -91,6 +92,22 @@ public class VoteBest extends GUIHandler {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
String guiPath = "VoteBest";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,14 @@ import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteGUI extends GUIHandler {
|
||||
@@ -42,15 +43,15 @@ public class VoteGUI extends GUIHandler {
|
||||
|
||||
String str = plugin.getConfigFile().getVoteTopDefault();
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(slot, "url")) {
|
||||
lore = new String[] { "&aClick me" };
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "next")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteNext(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "last")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteLast(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "total")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteTotal(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "top")) {
|
||||
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterMonthly(1);
|
||||
@@ -120,7 +121,7 @@ public class VoteGUI extends GUIHandler {
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (this.user == null) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
@@ -136,11 +137,12 @@ public class VoteGUI extends GUIHandler {
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
|
||||
for (String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
for (final String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
ItemBuilder builder = getItemSlot(slot, player);
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 1000, 1000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@@ -158,35 +160,15 @@ public class VoteGUI extends GUIHandler {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("best")) {
|
||||
new VoteBest(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("streak")) {
|
||||
new VoteStreak(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, slot);
|
||||
}
|
||||
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
|
||||
plugin.getRewardHandler().giveReward(UserManager.getInstance().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui()
|
||||
.getChestVoteGUISlotRewardsPath(slot, event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(plugin.getVotingPluginUserManager().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
event.getButton().getLastRewardsPath(player)),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
}
|
||||
@@ -194,16 +176,33 @@ public class VoteGUI extends GUIHandler {
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
ItemBuilder item = getItemSlot(slot, player);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
item.addPlaceholder("points", "" + user.getPoints());
|
||||
item.addPlaceholder("player", user.getPlayerName());
|
||||
item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
item.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
return item;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
String guiPath = "VoteGUI";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class VoteHelp extends GUIHandler {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
String colorStr = plugin.getConfigFile().getFormatCommandsVoteHelpHoverColor();
|
||||
ChatColor hoverColor = null;
|
||||
@@ -68,7 +68,7 @@ public class VoteHelp extends GUIHandler {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (!requirePerms || cmdHandle.hasPerm(sender)) {
|
||||
|
||||
@@ -9,10 +9,12 @@ import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -63,12 +65,28 @@ public class VoteLast extends GUIHandler {
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastGUILine(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
public void onClick(ClickEvent event) {
|
||||
if (plugin.getGui().isChestVoteLastClickableLinks()) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.sendMessage(
|
||||
StringParser.getInstance()
|
||||
.replacePlaceHolder(
|
||||
StringParser.getInstance().replacePlaceHolder(
|
||||
StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getGui()
|
||||
.getChestVoteURLURLText(),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"sitename", site.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -80,7 +98,23 @@ public class VoteLast extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteLastBackButton()) {
|
||||
String guiPath = "VoteLast";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteLastBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,12 @@ import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -87,9 +89,15 @@ public class VoteNext extends GUIHandler {
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!site.isHidden()) {
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(siteNameDisplay)
|
||||
.setLore(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time", user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
@@ -106,7 +114,23 @@ public class VoteNext extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteNextBackButton()) {
|
||||
String guiPath = "VoteNext";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteNextBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
|
||||
@@ -13,9 +13,9 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteShop extends GUIHandler {
|
||||
@@ -45,7 +45,7 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (!plugin.getGui().getChestVoteShopEnabled()) {
|
||||
if (!plugin.getGui().isChestVoteShopEnabled()) {
|
||||
player.sendMessage(StringParser.getInstance().colorize(plugin.getGui().getChestVoteShopDisabled()));
|
||||
return;
|
||||
}
|
||||
@@ -53,8 +53,13 @@ public class VoteShop extends GUIHandler {
|
||||
if (this.user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
/*
|
||||
* if (!plugin.getConfigFile().isExtraVoteShopCheck()) { user.cacheAsync(); }
|
||||
*/
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
@@ -90,16 +95,18 @@ public class VoteShop extends GUIHandler {
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.clearCache();
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
if (plugin.getConfigFile().isExtraVoteShopCheck()) {
|
||||
user.cache();
|
||||
}
|
||||
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
}
|
||||
// if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
// event.closeInventory();
|
||||
// }
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
boolean limitPass = true;
|
||||
@@ -116,9 +123,12 @@ public class VoteShop extends GUIHandler {
|
||||
plugin.getGui().getChestShopIdentifierIdentifierName(identifier));
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
if (user.removePoints(points, true)) {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/"
|
||||
+ user.getUUID() + " bought " + identifier + " for " + points);
|
||||
if (plugin.getConfigFile().isTrackShopPurchases()) {
|
||||
plugin.getServerData().addVoteShopPurchase(identifier);
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
@@ -142,6 +152,10 @@ public class VoteShop extends GUIHandler {
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, identifier);
|
||||
if (plugin.getGui().isChestVoteShopReopenGUIOnPurchase()) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, "shop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,15 +168,28 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
user.sendMessage(plugin.getConfigFile().getFormatShopNotPurchasable());
|
||||
}
|
||||
|
||||
}.dontClose().addData("identifier", identifier).addData("Limit", limit));
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteShopBackButton()) {
|
||||
for (final String str : plugin.getGui().getChestGUIVoteShopExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIVoteShopExtraItems(str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteShopExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteShopBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
|
||||
@@ -53,16 +53,19 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
if (user.removePoints(points, true)) {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought "
|
||||
+ identifier + " for " + points);
|
||||
if (plugin.getConfigFile().isTrackShopPurchases()) {
|
||||
plugin.getServerData().addVoteShopPurchase(identifier);
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -119,7 +120,23 @@ public class VoteStreak extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteStreakBackButton()) {
|
||||
String guiPath = "VoteStreak";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteStreakBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteToday extends GUIHandler {
|
||||
@@ -109,15 +109,31 @@ public class VoteToday extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
new VoteGUI(plugin, player, user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteToday";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
if (plugin.getGui().getChestVoteTodayBackButton()) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTodayBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
|
||||
@@ -2,11 +2,15 @@ package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Queue;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@@ -17,6 +21,7 @@ import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -78,6 +83,15 @@ public class VoteTopVoter extends GUIHandler {
|
||||
.getTopVoter(top).clone();
|
||||
users = topVotes.entrySet();
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<Integer>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
playerSlots.addAll(customizationPlayerSlots);
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", topVoter);
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
@@ -86,6 +100,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
@@ -96,44 +111,97 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
BInventoryButton button = new BInventoryButton(playerItem
|
||||
.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (plugin.getGui().getChestVoteTopOpenMainGUIOnClick()) {
|
||||
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
} else {
|
||||
getInv().forceClose(clickEvent.getPlayer());
|
||||
}
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey());
|
||||
|
||||
if (customzationEnabled && !playerSlots.isEmpty()) {
|
||||
button.setSlot(playerSlots.remove());
|
||||
}
|
||||
|
||||
inv.setCloseInv(plugin.getGui().isChestVoteTopCloseGUIOnClick());
|
||||
|
||||
inv.addButton(button);
|
||||
pos++;
|
||||
}
|
||||
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
TopVoter newTops = top;
|
||||
ArrayList<String> tops = plugin.getGui().getChestVoteTopSwitchItemTopVoters();
|
||||
if (!tops.isEmpty()) {
|
||||
for (String name : tops) {
|
||||
newTops.getSwitchItems().add(TopVoter.getTopVoter(name));
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
final TopVoter cur = newTops;
|
||||
if (!customzationEnabled) {
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
if (customzationEnabled) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user)
|
||||
.setSlot(customization.getInt("BackButtonSlot", 0)));
|
||||
} else {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
}
|
||||
|
||||
String guiPath = "VoteTop.Customization";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + ".Rewards").setGiveOffline(false)
|
||||
.send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (customization == null || !customzationEnabled || !customization.getBoolean("RemoveBottomBar")) {
|
||||
inv.setPages(true);
|
||||
}
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ import org.bukkit.entity.Player;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -65,7 +67,7 @@ public class VoteTotal extends GUIHandler {
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()),
|
||||
1000, 1000) {
|
||||
@@ -84,7 +86,23 @@ public class VoteTotal extends GUIHandler {
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTotalBackButton()) {
|
||||
String guiPath = "VoteTotal";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTotalBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
@@ -41,11 +40,11 @@ public class VoteURL extends GUIHandler {
|
||||
this.user = user;
|
||||
this.json = json;
|
||||
if (user == null && player instanceof Player) {
|
||||
this.user = UserManager.getInstance().getVotingPluginUser((Player) player);
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) player);
|
||||
}
|
||||
if (player != null && user != null && player.getName().equals(user.getPlayerName())) {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -58,7 +57,7 @@ public class VoteURL extends GUIHandler {
|
||||
if (title != null) {
|
||||
sites.addAll(title);
|
||||
}
|
||||
if (plugin.getConfigFile().getFormatCommandsVoteAutoInputSites()) {
|
||||
if (plugin.getConfigFile().isFormatCommandsVoteAutoInputSites()) {
|
||||
int counter = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
@@ -133,6 +132,11 @@ public class VoteURL extends GUIHandler {
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
if (plugin.getGui().isBookVoteURLBookGUIManual()) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUITopLayout());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
int i = 1;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
|
||||
site.getDisplayName());
|
||||
@@ -142,12 +146,12 @@ public class VoteURL extends GUIHandler {
|
||||
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
|
||||
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
|
||||
}
|
||||
String url = StringParser.getInstance().replacePlaceHolder(site.getVoteURLJsonStrip(), "player",
|
||||
user.getPlayerName());
|
||||
String url = StringParser.getInstance().replacePlaceHolder(StringParser.getInstance()
|
||||
.replacePlaceHolder(site.getVoteURLJsonStrip(), "player", user.getPlayerName()), "num", "" + i);
|
||||
layout.replaceTextComponent("[UrlText]", BookUtil.TextBuilder.of(text).color(color)
|
||||
.onClick(BookUtil.ClickAction.openUrl(url)).onHover(BookUtil.HoverAction.showText(url)).build());
|
||||
book.addLayout(layout);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
book.open(player);
|
||||
@@ -162,14 +166,14 @@ public class VoteURL extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
// normal GUI
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLName());
|
||||
if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
if (plugin.getGui().isChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builderAll, 5000, 5000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builderAll, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
|
||||
json = true;
|
||||
user.sendMessage(getChat(player));
|
||||
}
|
||||
@@ -190,13 +194,13 @@ public class VoteURL extends GUIHandler {
|
||||
startSlot++;
|
||||
}
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 5000, 5000) {
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance()
|
||||
.replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteURLURLText(), "voteurl", voteSite.getVoteURL()),
|
||||
@@ -221,14 +225,15 @@ public class VoteURL extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(), "CHEST.VoteURL.ExtraItems." + str + ".Rewards")
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteURL.ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteURLBackButton()) {
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class VoteURLVoteSite extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin,
|
||||
new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site)),
|
||||
1000, 1000) {
|
||||
|
||||
@@ -94,7 +94,7 @@ public class VoteURLVoteSite extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteURLBackButton()) {
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
@@ -81,6 +83,18 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private boolean disableBroadcast = false;
|
||||
|
||||
@ConfigDataBoolean(path = "GlobalData.UseMainMySQL")
|
||||
@Getter
|
||||
private boolean globlalDataUseMainMySQL = true;
|
||||
|
||||
@ConfigDataBoolean(path = "GlobalData.Enabled")
|
||||
@Getter
|
||||
private boolean globlalDataEnabled = false;
|
||||
|
||||
@ConfigDataListString(path = "BungeeVotePartyGlobalCommands")
|
||||
@Getter
|
||||
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<String>();
|
||||
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
}
|
||||
|
||||
@@ -12,9 +12,11 @@ import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataKeys;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceholderCacheLevel;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -33,6 +35,18 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AddTotalsOffline")
|
||||
@Getter
|
||||
private boolean addTotalsOffline = true;
|
||||
|
||||
@ConfigDataBoolean(path = "PerSiteCoolDownEvents")
|
||||
@Getter
|
||||
private boolean perSiteCoolDownEvents = false;
|
||||
|
||||
@ConfigDataBoolean(path = "QueueVotesDuringTimeChange")
|
||||
@Getter
|
||||
private boolean queueVotesDuringTimeChange = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
@@ -41,18 +55,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean preloadSkulls = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCachePlaceholders")
|
||||
@Getter
|
||||
private boolean autoCachePlaceholders = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
@ConfigDataInt(path = "PlayerDataLoadLimit")
|
||||
@Getter
|
||||
private int playerDataLoadLimit = -1;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
@@ -65,14 +71,18 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean alwaysCloseInventory = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraVoteShopCheck")
|
||||
@Getter
|
||||
private boolean extraVoteShopCheck = true;
|
||||
|
||||
@ConfigDataBoolean(path = "TrackShopPurchases")
|
||||
@Getter
|
||||
private boolean trackShopPurchases = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysUpdate")
|
||||
@Getter
|
||||
private boolean alwaysUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysWaitForCachePlaceholders")
|
||||
@Getter
|
||||
private boolean alwaysWaitForCachePlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
@@ -89,10 +99,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private int delayBetweenUpdates = 3;
|
||||
|
||||
@ConfigDataInt(path = "DelayLoginEvent")
|
||||
@Getter
|
||||
private int delayLoginEvent = 0;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableAdvancedTab")
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
@@ -165,6 +171,26 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLastVoted = "%times% ago";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NotEnoughPoints")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsNotEnoughPoints = "&cNot enough points";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NotJoinedServer")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsNotJoinedServer = "&c%player% has not joined the server";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.NumberLowerThanZero")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsNumberLowerThanZero = "&cNumber of points needs to be greater than 0";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.TransferFrom")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsTransferFrom = "&c%transfer% points given to %touser%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.GivePoints.TransferTo")
|
||||
@Getter
|
||||
private String formatCommandsVoteGivePointsTransferTo = "&cYou received %transfer points from %fromuser%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLine;
|
||||
@@ -173,6 +199,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String formatCommandsVoteLastNeverVoted;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.Last.IncludeSeconds")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteLastIncludeSeconds = true;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastTimeFormat;
|
||||
@@ -261,6 +291,14 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean preventRepeatMilestones = false;
|
||||
|
||||
@ConfigDataBoolean(path = "OfflineVotesLimit.Enabled")
|
||||
@Getter
|
||||
private boolean offlineVotesLimitEnabled = false;
|
||||
|
||||
@ConfigDataInt(path = "OfflineVotesLimit.Amount")
|
||||
@Getter
|
||||
private int offlineVotesLimitAmount = 5;
|
||||
|
||||
@ConfigDataBoolean(path = "UpdateWithPlayersOnlineOnly")
|
||||
@Getter
|
||||
private boolean updateWithPlayersOnlineOnly = false;
|
||||
@@ -303,149 +341,101 @@ public class Config extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public Set<String> getCustomCommands() {
|
||||
Set<String> str = getData().getConfigurationSection("CustomCommands").getKeys(false);
|
||||
@ConfigDataKeys(path = "CustomCommands")
|
||||
@Getter
|
||||
private Set<String> customCommands = new HashSet<String>();
|
||||
|
||||
@ConfigDataKeys(path = "CustomPlaceholderReturns")
|
||||
@Getter
|
||||
private Set<String> customPlaceholderReturns = new HashSet<String>();
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns(String placeholder) {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<String>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
|
||||
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
|
||||
}
|
||||
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broad cast msg.
|
||||
*
|
||||
* @return the broad cast msg
|
||||
*/
|
||||
public String getFormatBroadCastMsg() {
|
||||
return getData().getString("Format.BroadcastMsg",
|
||||
"&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%");
|
||||
@ConfigDataString(path = "Format.BroadcastMsg")
|
||||
@Getter
|
||||
private String formatBroadCastMsg = "&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%";
|
||||
|
||||
@ConfigDataBoolean(path = "Format.BroadcastWhenOnline")
|
||||
@Getter
|
||||
private boolean formatBroadcastWhenOnline = false;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.AutoInputSites")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteAutoInputSites = true;
|
||||
|
||||
@ConfigDataListString(path = "Format.Commands.Vote.Best.Lines")
|
||||
@Getter
|
||||
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<String>();
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Best.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteBestTitle = "&3&l%player% Best Votes";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Help.HoverColor")
|
||||
@Getter
|
||||
private String formatCommandsVoteHelpHoverColor = "AQUA";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Help.Line")
|
||||
@Getter
|
||||
private String formatCommandsVoteHelpLine = "&6%Command% - &6%HelpMessage%";
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.Help.RequirePermission")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteHelpRequirePermission = false;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Help.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteHelpTitle = "&6Voting Player Help";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastTitle = "&3&l%player% Last Vote Times:";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.CanVote")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoCanVote = "Go Vote!";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.Error")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoError = "";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.TimeUntilVote")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoTime = "&cCould not caculate time until next vote!";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Info.VoteDelayDaily")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextInfoVoteDelayDaily = "%hours% Hours and %minutes% Minutes";
|
||||
|
||||
@ConfigDataString(path = "PlaceholderCacheLevel", options = { "AUTO", "SPECIFIC", "NONE" })
|
||||
@Getter
|
||||
private String placeholderCacheLevelString = "AUTO";
|
||||
|
||||
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
|
||||
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broadcast when online.
|
||||
*
|
||||
* @return the broadcast when online
|
||||
*/
|
||||
public boolean getFormatBroadcastWhenOnline() {
|
||||
return getData().getBoolean("Format.BroadcastWhenOnline");
|
||||
}
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Layout")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextLayout = "&3%SiteName%: &6%info%";
|
||||
|
||||
/**
|
||||
* Gets the commands vote auto input sites.
|
||||
*
|
||||
* @return the commands vote auto input sites
|
||||
*/
|
||||
public boolean getFormatCommandsVoteAutoInputSites() {
|
||||
return getData().getBoolean("Format.Commands.Vote.AutoInputSites");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteBestLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Best.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteBestTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Best.Title", "&3&l%player% Best Votes");
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteHelpHoverColor() {
|
||||
return getData().getString("Format.Commands.Vote.Help.HoverColor", "AQUA");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help line.
|
||||
*
|
||||
* @return the commands vote help line
|
||||
*/
|
||||
public String getFormatCommandsVoteHelpLine() {
|
||||
return getData().getString("Format.Commands.Vote.Help.Line", "&6%Command% - &6%HelpMessage%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help require permission.
|
||||
*
|
||||
* @return the commands vote help require permission
|
||||
*/
|
||||
public boolean getFormatCommandsVoteHelpRequirePermission() {
|
||||
return getData().getBoolean("Format.Commands.Vote.Help.RequirePermission");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help title.
|
||||
*
|
||||
* @return the commands vote help title
|
||||
*/
|
||||
public String getFormatCommandsVoteHelpTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Help.Title", "&6Voting Player Help");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote last title.
|
||||
*
|
||||
* @return the commands vote last title
|
||||
*/
|
||||
public String getFormatCommandsVoteLastTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Last.Title", "&3&l%player% Last Vote Times:");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next info can vote.
|
||||
*
|
||||
* @return the commands vote next info can vote
|
||||
*/
|
||||
public String getFormatCommandsVoteNextInfoCanVote() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.CanVote", "Go Vote!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next info error.
|
||||
*
|
||||
* @return the commands vote next info error
|
||||
*/
|
||||
public String getFormatCommandsVoteNextInfoError() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.Error", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next info time.
|
||||
*
|
||||
* @return the commands vote next info time
|
||||
*/
|
||||
public String getFormatCommandsVoteNextInfoTime() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.TimeUntilVote",
|
||||
"&cCould not caculate time until next vote!");
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteNextInfoVoteDelayDaily() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.VoteDelayDaily",
|
||||
"%hours% Hours and %minutes% Minutes");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next layout.
|
||||
*
|
||||
* @return the commands vote next layout
|
||||
*/
|
||||
public String getFormatCommandsVoteNextLayout() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Layout", "&3%SiteName%: &6%info%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next title.
|
||||
*
|
||||
* @return the commands vote next title
|
||||
*/
|
||||
public String getFormatCommandsVoteNextTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Title", "&3&l%player% Next Votes:");
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextTitle = "&3&l%player% Next Votes:";
|
||||
|
||||
/**
|
||||
* Gets the commands vote party.
|
||||
@@ -465,9 +455,9 @@ public class Config extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteStreakTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Streak.Title", "&3&l%player% Vote Streak");
|
||||
}
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Streak.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteStreakTitle = "&3&l%player% Vote Streak";
|
||||
|
||||
/**
|
||||
* Gets the commands vote text.
|
||||
@@ -510,167 +500,103 @@ public class Config extends YMLFile {
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote URLS.
|
||||
*
|
||||
* @return the commands vote URLS
|
||||
*/
|
||||
public String getFormatCommandsVoteURLS() {
|
||||
return getData().getString("Format.Commands.Vote.Sites", "&4%num%: &c&l%SiteName% - &c%url%");
|
||||
}
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Sites")
|
||||
@Getter
|
||||
private String formatCommandsVoteURLS = "&4%num%: &c&l%SiteName% - &c%url%";
|
||||
|
||||
/**
|
||||
* Gets the command vote points.
|
||||
*
|
||||
* @return the command vote points
|
||||
*/
|
||||
public String getFormatCommandVotePoints() {
|
||||
return getData().getString("Format.Commands.Vote.Points", "&a%Player% currently has &a&l%Points%&a Points!");
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Points")
|
||||
@Getter
|
||||
private String formatCommandsVotePoints = "&a%Player% currently has &a&l%Points%&a Points!";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Top.Line")
|
||||
@Getter
|
||||
private String formatCommandsVoteTopLine = "&c%num%: &6%player%, %votes%";
|
||||
|
||||
/**
|
||||
* Gets the command vote top line.
|
||||
*
|
||||
* @return the command vote top line
|
||||
*/
|
||||
public String getFormatCommandVoteTopLine() {
|
||||
return getData().getString("Format.Commands.Vote.Top.Line", "&c%num%: &6%player%, %votes%");
|
||||
}
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Top.Title")
|
||||
@Getter
|
||||
private String formatCommandVoteTopTitle = "&3Top %Top% Voters %page%/%maxpages%";
|
||||
|
||||
/**
|
||||
* Gets the command vote top title.
|
||||
*
|
||||
* @return the command vote top title
|
||||
*/
|
||||
public String getFormatCommandVoteTopTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Top.Title", "&3Top %Top% Voters %page%/%maxpages%");
|
||||
@ConfigDataString(path = "Format.NextPage")
|
||||
@Getter
|
||||
private String formatNextPage = "&aNext Page";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.NoPerms")
|
||||
@Getter
|
||||
private String formatNoPerms = "&cYou do not have enough permission!";
|
||||
|
||||
public String getFormatNextPage() {
|
||||
return getData().getString("Format.NextPage", "&aNext Page");
|
||||
}
|
||||
@ConfigDataString(path = "Format.NotNumber")
|
||||
@Getter
|
||||
private String formatNotNumber = "&cError on &6%arg%&c, number expected!";
|
||||
|
||||
/**
|
||||
* Gets the format no perms.
|
||||
*
|
||||
* @return the format no perms
|
||||
*/
|
||||
public String getFormatNoPerms() {
|
||||
return getData().getString("Format.NoPerms", "&cYou do not have enough permission!");
|
||||
}
|
||||
@ConfigDataString(path = "Format.PrevPage")
|
||||
@Getter
|
||||
private String formatPrevPage = "&aPrevious Page";
|
||||
|
||||
public String getFormatNotNumber() {
|
||||
return getData().getString("Format.NotNumber", "&cError on &6%arg%&c, number expected!");
|
||||
}
|
||||
@ConfigDataString(path = "Format.ShopFailed")
|
||||
@Getter
|
||||
private String formatShopFailedMsg = "&cYou do not have %Points% points to purhcase this!";
|
||||
|
||||
public String getFormatPrevPage() {
|
||||
return getData().getString("Format.PrevPage", "&aPrevious Page");
|
||||
}
|
||||
@ConfigDataString(path = "Format.ShopNotPurchasable")
|
||||
@Getter
|
||||
private String formatShopNotPurchasable = "&cThis item is not buyable!";
|
||||
|
||||
public String getFormatShopFailedMsg() {
|
||||
String msg = getData().getString("Format.ShopFailed", "&cYou do not have %Points% points to purhcase this!");
|
||||
@ConfigDataString(path = "Format.ShopPurchase")
|
||||
@Getter
|
||||
private String formatShopPurchaseMsg = "&aYou bought the %Identifier% for %Points% Points!";
|
||||
|
||||
return msg;
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line1")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine1 = "TopVoter: %SiteName%";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line2")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine2 = "#%position%";
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line3")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine3 = "%player%";
|
||||
@ConfigDataString(path = "Format.Signs.TopVoterSign.Line4")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignLine4 = "%votes% Votes";
|
||||
|
||||
public String getFormatShopPurchaseMsg() {
|
||||
return getData().getString("Format.ShopPurchase", "&aYou bought the %Identifier% for %Points% Points!");
|
||||
@ConfigDataString(path = "Format.Signs.RightClickMessage")
|
||||
@Getter
|
||||
private String formatSignTopVoterSignRightClickMessage = "&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cin &c&l%SiteName%";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.TimeFormat")
|
||||
@Getter
|
||||
private String formatTimeFormat = "EEE, d MMM yyyy HH:mm";
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 1.
|
||||
*
|
||||
* @return the sign top voter sign line 1
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine1() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line1", "TopVoter: %SiteName%");
|
||||
@ConfigDataString(path = "Format.TopVoter.AllTime")
|
||||
@Getter
|
||||
private String formatTopVoterAllTime = "AllTime";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.TopVoter.Daily")
|
||||
@Getter
|
||||
private String formatTopVoterDaily = "Daily";
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 2.
|
||||
*
|
||||
* @return the sign top voter sign line 2
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine2() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line2", "#%position%");
|
||||
}
|
||||
@ConfigDataString(path = "Format.TopVoter.Monthly")
|
||||
@Getter
|
||||
private String formatTopVoterMonthly = "Monthly";
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 3.
|
||||
*
|
||||
* @return the sign top voter sign line 3
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine3() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line3", "%player%");
|
||||
@ConfigDataString(path = "Format.TopVoterAwardMsg")
|
||||
@Getter
|
||||
private String formatTopVoterRewardMsg = "&aYou came in %place% in top voters of the month! Here is an award!";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.TopVoter.Weekly")
|
||||
@Getter
|
||||
private String formatTopVoterWeekly = "Weekly";
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 4.
|
||||
*
|
||||
* @return the sign top voter sign line 4
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine4() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line4", "%votes% Votes");
|
||||
@ConfigDataString(path = "Format.UserNotExist")
|
||||
@Getter
|
||||
private String formatUserNotExist = "&cUser does not exist: %player%";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "Format.InvalidCommand.Vote")
|
||||
@Getter
|
||||
private String formatInvalidCommandVote = "&4No valid arguments, see /vote help!";
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign right click message.
|
||||
*
|
||||
* @return the sign top voter sign right click message
|
||||
*/
|
||||
public String getFormatSignTopVoterSignRightClickMessage() {
|
||||
return getData().getString("Format.Signs.RightClickMessage",
|
||||
"&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cin &c&l%SiteName%");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time format.
|
||||
*
|
||||
* @return the time format
|
||||
*/
|
||||
public String getFormatTimeFormat() {
|
||||
return getData().getString("Format.TimeFormat", "EEE, d MMM yyyy HH:mm");
|
||||
|
||||
}
|
||||
|
||||
public String getFormatTopVoterAllTime() {
|
||||
return getData().getString("Format.TopVoter.AllTime", "AllTime");
|
||||
}
|
||||
|
||||
public String getFormatTopVoterDaily() {
|
||||
return getData().getString("Format.TopVoter.Daily", "Daily");
|
||||
}
|
||||
|
||||
public String getFormatTopVoterMonthly() {
|
||||
return getData().getString("Format.TopVoter.Monthly", "Monthly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the top voter reward msg.
|
||||
*
|
||||
* @return the top voter reward msg
|
||||
*/
|
||||
public String getFormatTopVoterRewardMsg() {
|
||||
return getData().getString("Format.TopVoterAwardMsg",
|
||||
"&aYou came in %place% in top voters of the month! Here is an award!");
|
||||
|
||||
}
|
||||
|
||||
public String getFormatTopVoterWeekly() {
|
||||
return getData().getString("Format.TopVoter.Weekly", "Weekly");
|
||||
}
|
||||
|
||||
public String getFormatUserNotExist() {
|
||||
return getData().getString("Format.UserNotExist", "&cUser does not exist: %player%");
|
||||
}
|
||||
@ConfigDataString(path = "Format.InvalidCommand.AdminVote")
|
||||
@Getter
|
||||
private String formatInvalidCommandAdminVote = "&4No valid arguments, see /adminvote help!";
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
@@ -682,133 +608,96 @@ public class Config extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getGiveDefaultPermission() {
|
||||
return getData().getBoolean("GiveDefaultPermission", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "GiveDefaultPermission")
|
||||
@Getter
|
||||
private boolean giveDefaultPermission = true;
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getLoadTopVoterAllTime();
|
||||
return isLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return getLoadTopVoterDaily();
|
||||
return isLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return getLoadTopVoterMonthly();
|
||||
return isLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return getLoadTopVoterWeekly();
|
||||
return isLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoterAllTime() {
|
||||
return getData().getBoolean("LoadTopVoter.AllTime", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.AllTime")
|
||||
@Getter
|
||||
private boolean loadTopVoterAllTime = true;
|
||||
|
||||
public boolean getLoadTopVoterDaily() {
|
||||
return getData().getBoolean("LoadTopVoter.Daily", false);
|
||||
}
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.Monthly")
|
||||
@Getter
|
||||
private boolean loadTopVoterMonthly = true;
|
||||
|
||||
public boolean getLoadTopVoterMonthly() {
|
||||
return getData().getBoolean("LoadTopVoter.Monthly", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.Daily")
|
||||
@Getter
|
||||
private boolean loadTopVoterDaily = false;
|
||||
|
||||
public boolean getLoadTopVoterWeekly() {
|
||||
return getData().getBoolean("LoadTopVoter.Weekly", false);
|
||||
}
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.Weekly")
|
||||
@Getter
|
||||
private boolean loadTopVoterWeekly = false;
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
@ConfigDataInt(path = "PointsOnVote")
|
||||
@Getter
|
||||
private int pointsOnVote = 1;
|
||||
|
||||
public int getPurgeMin() {
|
||||
return getData().getInt("PurgeMin", 90);
|
||||
}
|
||||
@ConfigDataInt(path = "PurgeMin")
|
||||
@Getter
|
||||
private int purgeMin = 90;
|
||||
|
||||
public boolean getPurgeOldData() {
|
||||
return getData().getBoolean("PurgeOldData");
|
||||
}
|
||||
@ConfigDataBoolean(path = "PurgeOldData")
|
||||
@Getter
|
||||
private boolean purgeOldData = false;
|
||||
|
||||
/**
|
||||
* Gets the request API default method.
|
||||
*
|
||||
* @return the request API default method
|
||||
*/
|
||||
public String getRequestAPIDefaultMethod() {
|
||||
return getData().getString("RequestAPI.DefaultMethod", "Anvil");
|
||||
}
|
||||
@ConfigDataString(path = "RequestAPI.DefaultMethod")
|
||||
@Getter
|
||||
private String requestAPIDefaultMethod = "ANVIL";
|
||||
|
||||
/**
|
||||
* Gets the request API disabled methods.
|
||||
*
|
||||
* @return the request API disabled methods
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getRequestAPIDisabledMethods() {
|
||||
return (ArrayList<String>) getData().getList("RequestAPI.DisabledMethods", new ArrayList<String>());
|
||||
}
|
||||
@ConfigDataListString(path = "RequestAPI.DisabledMethods")
|
||||
@Getter
|
||||
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
* Gets the store top voters daily.
|
||||
*
|
||||
* @return the store top voters daily
|
||||
*/
|
||||
public boolean getStoreTopVotersDaily() {
|
||||
return getData().getBoolean("StoreTopVoters.Daily");
|
||||
}
|
||||
@ConfigDataBoolean(path = "StoreTopVoters.Daily")
|
||||
@Getter
|
||||
private boolean storeTopVotersDaily = false;
|
||||
|
||||
/**
|
||||
* Gets the store top voters weekly.
|
||||
*
|
||||
* @return the store top voters weekly
|
||||
*/
|
||||
public boolean getStoreTopVotersWeekly() {
|
||||
return getData().getBoolean("StoreTopVoters.Weekly");
|
||||
}
|
||||
@ConfigDataBoolean(path = "StoreTopVoters.Weekly")
|
||||
@Getter
|
||||
private boolean storeTopVotersWeekly = false;
|
||||
|
||||
public boolean getTopVoterAwardsTies() {
|
||||
return getData().getBoolean("TopVoterAwardsTies", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "TopVoterAwardsTies")
|
||||
@Getter
|
||||
private boolean topVoterAwardsTies = true;
|
||||
|
||||
public boolean getTopVoterIgnorePermission() {
|
||||
return getData().getBoolean("TopVoterIgnorePermission");
|
||||
}
|
||||
@ConfigDataBoolean(path = "TopVoterIgnorePermission")
|
||||
@Getter
|
||||
private boolean topVoterIgnorePermission = false;
|
||||
|
||||
/**
|
||||
* Gets the enabled.
|
||||
*
|
||||
* @return the enabled
|
||||
*/
|
||||
public boolean getVoteRemindingEnabled() {
|
||||
return getData().getBoolean("VoteReminding.Enabled");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteReminding.Enabled")
|
||||
@Getter
|
||||
private boolean voteRemindingEnabled = true;
|
||||
|
||||
/**
|
||||
* Gets the remind delay.
|
||||
*
|
||||
* @return the remind delay
|
||||
*/
|
||||
public int getVoteRemindingRemindDelay() {
|
||||
return getData().getInt("VoteReminding.RemindDelay", 30);
|
||||
}
|
||||
@ConfigDataInt(path = "VoteReminding.RemindDelay")
|
||||
@Getter
|
||||
private int voteRemindingRemindDelay = 30;
|
||||
|
||||
/**
|
||||
* Gets the remind on login.
|
||||
*
|
||||
* @return the remind on login
|
||||
*/
|
||||
public boolean getVoteRemindingRemindOnLogin() {
|
||||
return getData().getBoolean("VoteReminding.RemindOnLogin");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteReminding.RemindOnLogin")
|
||||
@Getter
|
||||
private boolean voteRemindingRemindOnLogin = false;
|
||||
|
||||
/**
|
||||
* Gets the remind only once.
|
||||
*
|
||||
* @return the remind only once
|
||||
*/
|
||||
public boolean getVoteRemindingRemindOnlyOnce() {
|
||||
return getData().getBoolean("VoteReminding.RemindOnlyOnce");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteReminding.RemindOnlyOnce")
|
||||
@Getter
|
||||
private boolean voteRemindingRemindOnlyOnce = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoConfigUpdating")
|
||||
@Getter
|
||||
private boolean autoConfigUpdating = false;
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
@@ -819,9 +708,9 @@ public class Config extends YMLFile {
|
||||
return "VoteReminding.Rewards";
|
||||
}
|
||||
|
||||
public String getVoteTopDefault() {
|
||||
return getData().getString("VoteTopDefault", "Monthly");
|
||||
}
|
||||
@ConfigDataString(path = "VoteTopDefault")
|
||||
@Getter
|
||||
private String voteTopDefault = "Monthly";
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.DirectlyDefinedReward;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
@@ -53,6 +54,53 @@ public class ConfigVoteSites extends YMLFile {
|
||||
|
||||
plugin.loadVoteSites();
|
||||
|
||||
plugin.addDirectlyDefinedRewards(new DirectlyDefinedReward("VoteSites." + siteName + ".Rewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
plugin.getConfigVoteSites().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return plugin.getConfigVoteSites().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
plugin.getConfigVoteSites().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
plugin.getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.addDirectlyDefinedRewards(
|
||||
new DirectlyDefinedReward("VoteSites." + siteName + ".CoolDownEndRewards") {
|
||||
|
||||
@Override
|
||||
public void createSection(String key) {
|
||||
plugin.getConfigVoteSites().createSection(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigurationSection getFileData() {
|
||||
return plugin.getConfigVoteSites().getData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
plugin.getConfigVoteSites().saveData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setData(String path, Object value) {
|
||||
plugin.getConfigVoteSites().setValue(path, value);
|
||||
}
|
||||
});
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission("VotingPlugin.Admin.GenerateServiceSite") || p.isOp()) {
|
||||
p.sendMessage(StringParser.getInstance().colorize("&cGenerating votesite for service site "
|
||||
@@ -130,12 +178,12 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @param siteName the site name
|
||||
* @return the vote delay
|
||||
*/
|
||||
public int getVoteDelay(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelay", 24);
|
||||
public double getVoteDelay(String siteName) {
|
||||
return getData(siteName).getDouble("VoteDelay", 24);
|
||||
}
|
||||
|
||||
public int getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayMin", 0);
|
||||
public double getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getDouble("VoteDelayMin", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +247,9 @@ public class ConfigVoteSites extends YMLFile {
|
||||
if (!siteCheck(site)) {
|
||||
plugin.getLogger().warning("Failed to load site " + site + ", see above");
|
||||
} else {
|
||||
voteSites.add(new VoteSite(plugin, site));
|
||||
VoteSite voteSite = new VoteSite(plugin, site);
|
||||
plugin.debug(voteSite.loadingDebug());
|
||||
voteSites.add(voteSite);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -393,7 +443,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @param siteName the site name
|
||||
* @param voteDelay the vote delay
|
||||
*/
|
||||
public void setVoteDelay(String siteName, int voteDelay) {
|
||||
public void setVoteDelay(String siteName, double voteDelay) {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataConfigurationSection;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataKeys;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
@@ -33,6 +35,10 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private String bookVoteURLBookGUICanVoteColor = "GREEN";
|
||||
|
||||
@ConfigDataBoolean(path = "BOOK.VoteURLBookGUI.Manual")
|
||||
@Getter
|
||||
private boolean bookVoteURLBookGUIManual = false;
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.CanVoteText")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUICanVoteText = "Click me";
|
||||
@@ -42,6 +48,10 @@ public class GUI extends YMLFile {
|
||||
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils.getInstance()
|
||||
.convert(new String[] { "&c%Sitename%", "[UrlText]" });
|
||||
|
||||
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.TopLayout")
|
||||
@Getter
|
||||
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<String>();
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.Title")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUITitle = "&cVoteURL";
|
||||
@@ -146,6 +156,10 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private boolean lastMonthGUI = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteLast.ClickableLinks")
|
||||
@Getter
|
||||
private boolean chestVoteLastClickableLinks = true;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
@@ -169,9 +183,9 @@ public class GUI extends YMLFile {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public ConfigurationSection getCHESTBackButton() {
|
||||
return getData().getConfigurationSection("CHEST.BackButton");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
|
||||
@Getter
|
||||
private ConfigurationSection CHESTBackButton;
|
||||
|
||||
public int getChestShopIdentifierCost(String identifier) {
|
||||
return getData().getInt("CHEST.Shop." + identifier + ".Cost");
|
||||
@@ -187,7 +201,6 @@ public class GUI extends YMLFile {
|
||||
|
||||
public String getChestShopIdentifierRewardsPath(String identifier) {
|
||||
return "CHEST.Shop." + identifier + ".Rewards";
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getChestShopIdentifiers() {
|
||||
@@ -202,25 +215,25 @@ public class GUI extends YMLFile {
|
||||
return getData().getConfigurationSection("CHEST.Shop." + identifier);
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteBestDayBestItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteBest.DayBest.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.DayBest.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteBestDayBestItem;
|
||||
|
||||
public ConfigurationSection getChestVoteBestMonthBestItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteBest.MonthBest.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.MonthBest.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteBestMonthBestItem;
|
||||
|
||||
public String getChestVoteBestName() {
|
||||
return getData().getString("CHEST.VoteBest.Name", "VoteBest: %player%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteBest.Name")
|
||||
@Getter
|
||||
private String chestVoteBestName = "VoteBest: %player%";
|
||||
|
||||
public ConfigurationSection getChestVoteBestWeekBestItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteBest.WeekBest.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.WeekBest.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteBestWeekBestItem;
|
||||
|
||||
public String getChestVoteGUIName() {
|
||||
return getData().getString("CHEST.VoteGUIName", "&cVoteGUI: &c&l%player%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteGUIName")
|
||||
@Getter
|
||||
private String chestVoteGUIName = "&cVoteGUI: &c&l%player%";
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
@@ -244,27 +257,22 @@ public class GUI extends YMLFile {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot) {
|
||||
return "CHEST.VoteGUI." + slot + ".Rewards";
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slots.
|
||||
*
|
||||
* @return the vote GUI slots
|
||||
*/
|
||||
public Set<String> getChestVoteGUISlots() {
|
||||
try {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
@ConfigDataKeys(path = "CHEST.VoteGUI")
|
||||
@Getter
|
||||
private Set<String> chestVoteGUISlots = new HashSet<String>();
|
||||
|
||||
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.Customization")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTopCustomization;
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
@@ -275,45 +283,57 @@ public class GUI extends YMLFile {
|
||||
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
public boolean getChestVoteLastBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteLast.BackButton");
|
||||
@ConfigDataBoolean(path = "CHEST.VoteLast.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteLastBackButton = false;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteLast.Line")
|
||||
@Getter
|
||||
private String chestVoteLastLine = "&6%timeSince%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteLast.Name")
|
||||
@Getter
|
||||
private String chestVoteLastName = "VoteLast: %player%";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteNext.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteNextBackButton = false;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteNext.Name")
|
||||
@Getter
|
||||
private String chestVoteNextName = "VoteNext: %player%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteNext.Line")
|
||||
@Getter
|
||||
private String chestVoteNextLine = "%time%";
|
||||
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
public String getChestVoteLastLine() {
|
||||
return getData().getString("CHEST.VoteLast.Line", "&6%timeSince%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteRewardName")
|
||||
@Getter
|
||||
private String chestVoteRewardName = "VoteReward";
|
||||
|
||||
public String getChestVoteLastName() {
|
||||
return getData().getString("CHEST.VoteLast.Name", "VoteLast: %player%");
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopBackButton")
|
||||
@Getter
|
||||
private boolean chestVoteShopBackButton = true;
|
||||
|
||||
public boolean getChestVoteNextBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteNext.BackButton");
|
||||
}
|
||||
|
||||
public String getChestVoteNextName() {
|
||||
return getData().getString("CHEST.VoteNext.Name", "VoteNext: %player%");
|
||||
}
|
||||
|
||||
public String getChestVoteRewardName() {
|
||||
return getData().getString("CHEST.VoteRewardName", "VoteReward");
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteShopBackButton", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopReopenGUIOnPurchase")
|
||||
@Getter
|
||||
private boolean chestVoteShopReopenGUIOnPurchase = true;
|
||||
|
||||
public boolean getChestVoteShopCloseGUI(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".CloseGUI", true);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopEnabled() {
|
||||
return getData().getBoolean("CHEST.VoteShopEnabled", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopEnabled")
|
||||
@Getter
|
||||
private boolean chestVoteShopEnabled = true;
|
||||
|
||||
public String getChestVoteShopName() {
|
||||
return getData().getString("CHEST.VoteShopName", "VoteShop");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteShopName")
|
||||
@Getter
|
||||
private String chestVoteShopName = "VoteShop";
|
||||
|
||||
public boolean getChestVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".NotBuyable", false);
|
||||
@@ -340,85 +360,93 @@ public class GUI extends YMLFile {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Weekly", false);
|
||||
}
|
||||
|
||||
public boolean getChestVoteStreakBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteStreak.BackButton");
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteStreak.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteStreakBackButton = false;
|
||||
|
||||
public ConfigurationSection getChestVoteStreakCurrentDayStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentDayStreak.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentDayStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakCurrentDayStreakItem;
|
||||
|
||||
public ConfigurationSection getChestVoteStreakCurrentMonthStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentMonthStreak.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentMonthStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakCurrentMonthStreakItem;
|
||||
|
||||
public ConfigurationSection getChestVoteStreakCurrentWeekStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentWeekStreak.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.CurrentWeekStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakCurrentWeekStreakItem;
|
||||
|
||||
public ConfigurationSection getChestVoteStreakHighestDayStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.HighestDayStreak.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestDayStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakHighestDayStreakItem;
|
||||
|
||||
public ConfigurationSection getChestVoteStreakHighestMonthStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.HighestMonthStreak.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestMonthStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakHighestMonthStreakItem;
|
||||
|
||||
public ConfigurationSection getChestVoteStreakHighestWeekStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.HighestWeekStreak.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteStreak.HighestWeekStreak.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteStreakHighestWeekStreakItem;
|
||||
|
||||
public String getChestVoteStreakName() {
|
||||
return getData().getString("CHEST.VoteStreak.Name", "VoteStreak");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteStreak.Name")
|
||||
@Getter
|
||||
private String chestVoteStreakName = "VoteStreak";
|
||||
|
||||
public boolean getChestVoteTodayBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteToday.BackButton");
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteToday.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteTodayBackButton = false;
|
||||
|
||||
public String getChestVoteTodayName() {
|
||||
return getData().getString("CHEST.VoteToday.Name", "VoteToday");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteToday.Name")
|
||||
@Getter
|
||||
private String chestVoteTodayName = "VoteToday";
|
||||
|
||||
public boolean getChestVoteTopBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteTop.BackButton");
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteTopBackButton = false;
|
||||
|
||||
public String getChestVoteTopItemLore() {
|
||||
return getData().getString("CHEST.VoteTop.Item.Lore", "&3&lVotes: &3%votes%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteTop.Item.Lore")
|
||||
@Getter
|
||||
private String chestVoteTopItemLore = "&3&lVotes: &3%votes%";
|
||||
|
||||
public String getChestVoteTopItemName() {
|
||||
return getData().getString("CHEST.VoteTop.Item.Name", "&3&l%position%: &3%player%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteTop.Item.Name")
|
||||
@Getter
|
||||
private String chestVoteTopItemName = "&3&l%position%: &3%player%";
|
||||
|
||||
public String getChestVoteTopName() {
|
||||
return getData().getString("CHEST.VoteTop.Name", "VoteTop %topvoter%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteTop.Name")
|
||||
@Getter
|
||||
private String chestVoteTopName = "VoteTop %topvoter%";
|
||||
|
||||
public boolean getChestVoteTopOpenMainGUIOnClick() {
|
||||
return getData().getBoolean("CHEST.VoteTop.OpenMainGUIOnClick", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.OpenMainGUIOnClick")
|
||||
@Getter
|
||||
private boolean chestVoteTopOpenMainGUIOnClick = true;
|
||||
|
||||
public int getChestVoteTopSize() {
|
||||
return getData().getInt("CHEST.VoteTop.Size", 27);
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.CloseGUIOnClick")
|
||||
@Getter
|
||||
private boolean chestVoteTopCloseGUIOnClick = true;
|
||||
|
||||
public ConfigurationSection getChestVoteTopSwitchItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTop.SwitchItem");
|
||||
}
|
||||
@ConfigDataInt(path = "CHEST.VoteTop.Size")
|
||||
@Getter
|
||||
private int chestVoteTopSize = 27;
|
||||
|
||||
public ConfigurationSection getChestVoteTotalAllTimeTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.AllTimeTotal.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.SwitchItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTopSwitchItem;
|
||||
|
||||
public boolean getChestVoteTotalBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteTotal.BackButton");
|
||||
}
|
||||
@ConfigDataListString(path = "CHEST.VoteTop.SwitchItem.TopVoters")
|
||||
@Getter
|
||||
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<String>();
|
||||
|
||||
public ConfigurationSection getChestVoteTotalDayTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.DayTotal.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.AllTimeTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalAllTimeTotalItem;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTotal.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteTotalBackButton = false;
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.DayTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalDayTotalItem;
|
||||
|
||||
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
@@ -436,117 +464,104 @@ public class GUI extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalMonthTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.MonthTotal.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.MonthTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalMonthTotalItem;
|
||||
|
||||
public String getChestVoteTotalName() {
|
||||
return getData().getString("CHEST.VoteTotal.Name", "VoteTotal: %player%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteTotal.Name")
|
||||
@Getter
|
||||
private String chestVoteTotalName = "VoteTotal: %player%";
|
||||
|
||||
public ConfigurationSection getChestVoteTotalWeekTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.WeekTotal.Item");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.WeekTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalWeekTotalItem;
|
||||
|
||||
public int getChestVoteURLAllUrlsButtonSlot() {
|
||||
return getData().getInt("CHEST.VoteURL.AllUrlsButton.Slot", -1);
|
||||
}
|
||||
@ConfigDataInt(path = "CHEST.VoteURL.AllUrlsButton.Slot")
|
||||
@Getter
|
||||
private int chestVoteURLAllUrlsButtonSlot = -1;
|
||||
|
||||
public int getChestVoteURLAllUrlsButtonStartSlot() {
|
||||
return getData().getInt("CHEST.VoteURL.StartSlot", -1);
|
||||
}
|
||||
@ConfigDataInt(path = "CHEST.VoteURL.StartSlot")
|
||||
@Getter
|
||||
private int chestVoteURLAllUrlsButtonStartSlot = -1;
|
||||
|
||||
public ConfigurationSection getChestVoteURLAlreadyVotedAllUrlsButtonItemSection() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem");
|
||||
} else {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AlreadyVotedItem");
|
||||
}
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem", secondPath = "CHEST.VoteURL.AlreadyVotedItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLAlreadyVotedAllUrlsButtonItemSection;
|
||||
|
||||
public ConfigurationSection getChestVoteURLAlreadyVotedItemSection() {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AlreadyVotedItem");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AlreadyVotedItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLAlreadyVotedItemSection;
|
||||
|
||||
public boolean getChestVoteURLBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteURL.BackButton");
|
||||
}
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteURLBackButton = false;
|
||||
|
||||
public ConfigurationSection getChestVoteURLCanVoteAllUrlsButtonItemSection() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.AllUrlsButton.CanVoteItem")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AllUrlsButton.CanVoteItem");
|
||||
} else {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.CanVoteItem");
|
||||
}
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.AllUrlsButton.CanVoteItem", secondPath = "CHEST.VoteURL.CanVoteItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLCanVoteAllUrlsButtonItemSection;
|
||||
|
||||
public ConfigurationSection getChestVoteURLCanVoteItemSection() {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.CanVoteItem");
|
||||
}
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteURL.CanVoteItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteURLCanVoteItemSection;
|
||||
|
||||
public Set<String> getChestVoteURLExtraItems() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
@ConfigDataKeys(path = "CHEST.VoteURL.ExtraItems")
|
||||
@Getter
|
||||
private Set<String> chestVoteURLExtraItems = new HashSet<String>();
|
||||
|
||||
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL site name.
|
||||
*
|
||||
* @return the vote URL site name
|
||||
*/
|
||||
public String getChestVoteURLGUISiteName() {
|
||||
return getData().getString("CHEST.VoteURL.SiteName", "&c%Name%");
|
||||
public Set<String> getChestGUIExtraItems(String gui) {
|
||||
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public String getChestVoteURLGUISiteNameCanVote() {
|
||||
return getData().getString("CHEST.VoteURL.SiteNameCanVote", "&a%Name%");
|
||||
public ConfigurationSection getChestGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteShopExtraItems." + item);
|
||||
}
|
||||
|
||||
public String getChestVoteURLName() {
|
||||
return getData().getString("CHEST.VoteURL.Name", "&cVoteURL");
|
||||
@ConfigDataKeys(path = "CHEST.VoteShopExtraItems")
|
||||
@Getter
|
||||
private Set<String> chestGUIVoteShopExtraItems = new HashSet<String>();
|
||||
|
||||
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL next vote.
|
||||
*
|
||||
* @return the vote URL next vote
|
||||
*/
|
||||
public String getChestVoteURLNextVote() {
|
||||
return getData().getString("CHEST.VoteURL.NextVote", "&cCan Vote In: %Info%");
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SiteName")
|
||||
@Getter
|
||||
private String chestVoteURLGUISiteName = "&c%Name%";
|
||||
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SiteNameCanVote")
|
||||
@Getter
|
||||
private String chestVoteURLGUISiteNameCanVote = "&a%Name%";
|
||||
|
||||
/**
|
||||
* Gets the vote URL see URL.
|
||||
*
|
||||
* @return the vote URL see URL
|
||||
*/
|
||||
public String getChestVoteURLSeeURL() {
|
||||
return getData().getString("CHEST.VoteURL.SeeURL", "&cClick to see URL");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteURL.Name")
|
||||
@Getter
|
||||
private String chestVoteURLName = "&cVoteURL";
|
||||
|
||||
public String getChestVoteURLSiteName() {
|
||||
return getData().getString("CHEST.VoteURLSite.Name", "VoteSite %site%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteURL.NextVote")
|
||||
@Getter
|
||||
private String chestVoteURLNextVote = "&cCan Vote In: %Info%";
|
||||
|
||||
public String getChestVoteURLURLText() {
|
||||
return getData().getString("CHEST.VoteURL.URLText", "%VoteUrl%");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SeeURL")
|
||||
@Getter
|
||||
private String chestVoteURLSeeURL = "&cClick to see URL";
|
||||
|
||||
/**
|
||||
* Gets the vote URL view all urls button enabled.
|
||||
*
|
||||
* @return the vote URL view all urls button enabled
|
||||
*/
|
||||
public boolean getChestVoteURLViewAllUrlsButtonEnabled() {
|
||||
return getData().getBoolean("CHEST.VoteURL.ViewAllUrlsButtonEnabled");
|
||||
}
|
||||
@ConfigDataString(path = "CHEST.VoteURLSite.Name")
|
||||
@Getter
|
||||
private String chestVoteURLSiteName = "VoteSite %site%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.URLText")
|
||||
@Getter
|
||||
private String chestVoteURLURLText = "%VoteUrl%";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.ViewAllUrlsButtonEnabled")
|
||||
@Getter
|
||||
private boolean chestVoteURLViewAllUrlsButtonEnabled = false;
|
||||
|
||||
public boolean isChestVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
|
||||
|
||||
@@ -3,12 +3,17 @@ package com.bencodez.votingplugin.config;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataDouble;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataKeys;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
@@ -19,6 +24,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private String allSitesRewardPath = "AllSites";
|
||||
|
||||
@Getter
|
||||
private String almostAllSitesRewardPath = "AlmostAllSites";
|
||||
|
||||
@Getter
|
||||
private String anySiteRewardsPath = "AnySiteRewards";
|
||||
|
||||
@@ -59,6 +67,10 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<String>();
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
|
||||
@@ -91,29 +103,18 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return "Cumulative." + cumulative + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative votes.
|
||||
*
|
||||
* @return the cumulative votes
|
||||
*/
|
||||
public Set<String> getCumulativeVotes() {
|
||||
try {
|
||||
Set<String> set = getData().getConfigurationSection("Cumulative").getKeys(false);
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<String>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
public List<Integer> getCumulativeBlackList(int cumulative) {
|
||||
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative votes in same day.
|
||||
*
|
||||
* @param cumulative the cumulative
|
||||
* @return the cumulative votes in same day
|
||||
*/
|
||||
public boolean getCumulativeRecurring(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
|
||||
}
|
||||
|
||||
@ConfigDataKeys(path = "Cumulative")
|
||||
@Getter
|
||||
private Set<String> cumulativeVotes = new HashSet<String>();
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameDay(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
|
||||
@@ -147,19 +148,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily possible reward places.
|
||||
*
|
||||
* @return the daily possible reward places
|
||||
*/
|
||||
public Set<String> getDailyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("DailyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
|
||||
}
|
||||
}
|
||||
@ConfigDataKeys(path = "DailyAwards")
|
||||
@Getter
|
||||
private Set<String> dailyPossibleRewardPlaces = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
@@ -181,22 +172,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return "MileStones." + milestones + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone votes.
|
||||
*
|
||||
* @return the milestone votes
|
||||
*/
|
||||
public Set<String> getMilestoneVotes() {
|
||||
try {
|
||||
Set<String> set = getData().getConfigurationSection("MileStones").getKeys(false);
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<String>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
@ConfigDataKeys(path = "MileStones")
|
||||
@Getter
|
||||
private Set<String> milestoneVotes = new HashSet<String>();
|
||||
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
@@ -215,77 +193,64 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getResetMilestonesMonthly() {
|
||||
return getData().getBoolean("ResetMilestonesMonthly");
|
||||
}
|
||||
@ConfigDataBoolean(path = "ResetMilestonesMonthly")
|
||||
@Getter
|
||||
private boolean resetMilestonesMonthly = false;
|
||||
@ConfigDataString(path = "VoteParty.Broadcast")
|
||||
@Getter
|
||||
private String votePartyBroadcast = "";
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
@ConfigDataListString(path = "VoteParty.GlobalCommands", secondPath = "VoteParty.Commands")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalCommands = new ArrayList<String>();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotePartyCommands() {
|
||||
return (ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>());
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.CountFakeVotes")
|
||||
@Getter
|
||||
private boolean votePartyCountFakeVotes = true;
|
||||
|
||||
public boolean getVotePartyCountFakeVotes() {
|
||||
return getData().getBoolean("VoteParty.CountFakeVotes", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.CountOfflineVotes")
|
||||
@Getter
|
||||
private boolean votePartyCountOfflineVotes = true;
|
||||
|
||||
public boolean getVotePartyCountOfflineVotes() {
|
||||
return getData().getBoolean("VoteParty.CountOfflineVotes", true);
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.Enabled")
|
||||
@Getter
|
||||
private boolean votePartyEnabled = false;
|
||||
|
||||
/**
|
||||
* Gets the vote party enabled.
|
||||
*
|
||||
* @return the vote party enabled
|
||||
*/
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.GiveAllPlayers")
|
||||
@Getter
|
||||
private boolean votePartyGiveAllPlayers = false;
|
||||
|
||||
/**
|
||||
* Gets the vote party give all players.
|
||||
*
|
||||
* @return the vote party give all players
|
||||
*/
|
||||
public boolean getVotePartyGiveAllPlayers() {
|
||||
return getData().getBoolean("VoteParty.GiveAllPlayers");
|
||||
}
|
||||
@ConfigDataInt(path = "VoteParty.IncreaseVotesRquired")
|
||||
@Getter
|
||||
private int votePartyIncreaseVotesRequired = 0;
|
||||
|
||||
public int getVotePartyIncreaseVotesRquired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
|
||||
@Getter
|
||||
private boolean votePartyOnlyOncePerDay = false;
|
||||
|
||||
public boolean getVotePartyOnlyOncePerDay() {
|
||||
return getData().getBoolean("VoteParty.OnlyOncePerDay");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerWeek")
|
||||
@Getter
|
||||
private boolean votePartyOnlyOncePerWeek = false;
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetEachDay")
|
||||
@Getter
|
||||
private boolean votePartyResetEachDay = false;
|
||||
|
||||
public boolean getVotePartyResetMontly() {
|
||||
return getData().getBoolean("VoteParty.ResetMonthly");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetMonthly = false;
|
||||
|
||||
public boolean getVotePartyResetWeekly() {
|
||||
return getData().getBoolean("VoteParty.ResetWeekly");
|
||||
}
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetWeekly")
|
||||
@Getter
|
||||
private boolean votePartyResetWeekly = false;
|
||||
|
||||
public int getVotePartyUserVotesRequired() {
|
||||
return getData().getInt("VoteParty.UserVotesRequired");
|
||||
}
|
||||
@ConfigDataInt(path = "VoteParty.UserVotesRequired")
|
||||
@Getter
|
||||
private int votePartyUserVotesRequired = 0;
|
||||
|
||||
/**
|
||||
* Gets the vote party votes required.
|
||||
*
|
||||
* @return the vote party votes required
|
||||
*/
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired");
|
||||
}
|
||||
@ConfigDataInt(path = "VoteParty.VotesRequired")
|
||||
@Getter
|
||||
private int votePartyVotesRequired = 0;
|
||||
|
||||
public boolean getVoteStreakRewardEnabled(String type, String s) {
|
||||
return getData().getBoolean("VoteStreak." + type + "." + s + ".Enabled");
|
||||
@@ -311,18 +276,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly possible reward places.
|
||||
*
|
||||
* @return the weekly possible reward places
|
||||
*/
|
||||
public Set<String> getWeeklyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("WeeklyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
@ConfigDataKeys(path = "WeeklyAwards")
|
||||
@Getter
|
||||
private Set<String> weeklyPossibleRewardPlaces = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package com.bencodez.votingplugin.cooldown;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -15,20 +16,24 @@ import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private Set<UUID> uuids = new HashSet<UUID>();
|
||||
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = new Timer();
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
private Timer timer;
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
private boolean cooldownCheckEnabled = false;
|
||||
|
||||
@@ -45,12 +50,18 @@ public class CoolDownCheck implements Listener {
|
||||
check(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user) {
|
||||
public void checkPerSite(UUID uuid) {
|
||||
checkPerSite(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
UUID uuid = UUID.fromString(user.getUUID());
|
||||
if (!uuids.contains(uuid)) {
|
||||
schedule(user);
|
||||
}
|
||||
schedule(user);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +71,55 @@ public class CoolDownCheck implements Listener {
|
||||
user.setCoolDownCheck(false);
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
uuids.remove(UUID.fromString(user.getUUID()));
|
||||
allSiteTasks.remove(user.getJavaUUID());
|
||||
} else if (!coolDownCheck) {
|
||||
schedule(user);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void checkPerSite(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
boolean changed = false;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (user.canVoteSite(site)) {
|
||||
if (!coolDownChecks.containsKey(site) || !coolDownChecks.get(site).booleanValue()) {
|
||||
coolDownChecks.put(site, Boolean.TRUE);
|
||||
changed = true;
|
||||
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
user.setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
}
|
||||
|
||||
schedulePerSite(user);
|
||||
|
||||
}
|
||||
|
||||
public void schedulePerSite(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeFirstSiteAvailable();
|
||||
if (time > 0) {
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time);
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
checkPerSite(uuid);
|
||||
}
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
perSiteTasks.put(uuid, scheduledFuture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,39 +128,47 @@ public class CoolDownCheck implements Listener {
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
uuids.add(uuid);
|
||||
timer.schedule(new TimerTask() {
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
check(uuid);
|
||||
}
|
||||
}, time * 1000 + 1500);
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (cooldownCheckEnabled) {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
checkPerSite(user);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@@ -112,4 +176,12 @@ public class CoolDownCheck implements Listener {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward", new RewardOptions());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
|
||||
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName()).addPlaceholder("url",
|
||||
event.getSite().getVoteURL(false)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.bencodez.votingplugin.data;
|
||||
|
||||
import java.time.temporal.WeekFields;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -12,6 +14,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -27,12 +30,39 @@ public class ServerData {
|
||||
|
||||
public void addAutoCachedPlaceholder(String placeholder) {
|
||||
List<String> p = getAutoCachedPlaceholder();
|
||||
if (!p.contains(placeholder)) {
|
||||
|
||||
if (!ArrayUtils.getInstance().containsIgnoreCase(p, placeholder)) {
|
||||
p.add(placeholder);
|
||||
setAutoCachedPlaceholder(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void updatePlaceholders() {
|
||||
boolean data = getData().getBoolean("AutoCacheUpdated", false);
|
||||
if (!data) {
|
||||
List<String> placeholders = getAutoCachedPlaceholder();
|
||||
for (int i = 0; i < placeholders.size(); i++) {
|
||||
placeholders.set(i, placeholders.get(i).toLowerCase());
|
||||
}
|
||||
setAutoCachedPlaceholder(placeholders);
|
||||
getData().set("AutoCacheUpdated", true);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
|
||||
public void addVoteShopPurchase(String ident) {
|
||||
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
|
||||
}
|
||||
|
||||
public void setVoteShopPurchases(String ident, int amount) {
|
||||
getData().set("VoteShopPurchases." + ident, amount);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getVoteShopPurchases(String ident) {
|
||||
return getData().getInt("VoteShopPurchases." + ident);
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
@@ -157,7 +187,16 @@ public class ServerData {
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
if (num == plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameWeek() {
|
||||
int num = getData().getInt("LastVotePartyWeek", -1);
|
||||
if (num == plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear())
|
||||
&& num != -1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -264,6 +303,12 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void updateLastVotePartyWeek() {
|
||||
getData().set("LastVotePartyWeek",
|
||||
plugin.getTimeChecker().getTime().get(WeekFields.of(Locale.getDefault()).weekOfYear()));
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
@@ -288,4 +333,28 @@ public class ServerData {
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
|
||||
public void addTimeVoted(int num, VoteTimeQueue vote) {
|
||||
getData().set("TimedVoteCache." + num + ".Name", vote.getName());
|
||||
getData().set("TimedVoteCache." + num + ".Service", vote.getService());
|
||||
getData().set("TimedVoteCache." + num + ".Time", vote.getTime());
|
||||
saveData();
|
||||
}
|
||||
|
||||
public Set<String> getTimedVoteCacheKeys() {
|
||||
if (getData().isConfigurationSection("TimedVoteCache")) {
|
||||
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
|
||||
} else {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getTimedVoteCacheSection(String num) {
|
||||
return getData().getConfigurationSection("TimedVoteCache." + num);
|
||||
}
|
||||
|
||||
public void clearTimedVoteCache() {
|
||||
getData().set("TimedVoteCache", null);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -55,17 +55,22 @@ public class PlayerPostVoteEvent extends Event {
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long voteTime = 0;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee) {
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee, long voteTime) {
|
||||
super(true);
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
this.realVote = realVote;
|
||||
this.forceBungee = forceBungee;
|
||||
this.voteTime = voteTime;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -80,6 +80,10 @@ public class PlayerVoteEvent extends Event {
|
||||
@Setter
|
||||
private boolean broadcast = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int voteNumber = 1;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
this.player = voteUsername;
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteSiteCoolDownEndEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite site;
|
||||
|
||||
public PlayerVoteSiteCoolDownEndEvent(VotingPluginUser user, VoteSite site) {
|
||||
super(true);
|
||||
player = user;
|
||||
this.site = site;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ package com.bencodez.votingplugin.events;
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK;
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK, ALMOSTALLSITES;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -8,6 +7,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class BlockBreak implements Listener {
|
||||
if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign s = (Sign) event.getBlock().getState();
|
||||
final Location loc = s.getLocation();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
@@ -10,7 +9,7 @@ import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
public class BungeeVotifierEvent {
|
||||
public void send(VotingPluginMain plugin, PlayerVoteEvent event) {
|
||||
plugin.debug("Triggering vote event");
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -12,7 +12,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -52,7 +51,7 @@ public class PlayerInteract implements Listener {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
UserManager.getInstance().getVotingPluginUser(player)
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(player)
|
||||
.sendMessage(sign.getRightClickMessage());
|
||||
|
||||
if (!sign.isSkullSet()) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -11,7 +9,6 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import com.bencodez.advancedcore.listeners.AdvancedCoreLoginEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -33,7 +30,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
}
|
||||
|
||||
private void login(Player player) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
if (player.isOp() && plugin.isYmlError()) {
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
|
||||
}
|
||||
@@ -49,9 +46,12 @@ public class PlayerJoinEvent implements Listener {
|
||||
|
||||
user.loginRewards();
|
||||
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()
|
||||
&& plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("Login", user.getPlayerName(), user.getUUID());
|
||||
plugin.getPluginMessaging().sendPluginMessage("Login", user.getPlayerName(), user.getUUID(),
|
||||
plugin.getBungeeSettings().getServer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,18 +66,7 @@ public class PlayerJoinEvent implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
int delay = plugin.getConfigFile().getDelayLoginEvent();
|
||||
if (delay <= 0) {
|
||||
login(event.getPlayer());
|
||||
} else {
|
||||
plugin.getLoginTimer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
login(event.getPlayer());
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
login(event.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
@@ -85,17 +74,18 @@ public class PlayerJoinEvent implements Listener {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
plugin.getLoginTimer().schedule(new TimerTask() {
|
||||
plugin.getLoginTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
plugin.getPlaceholders().onLogout(user);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,18 +5,19 @@ import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.events.PlayerPostVoteEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -25,8 +26,6 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
*/
|
||||
public class PlayerVoteListener implements Listener {
|
||||
|
||||
private static Object object = new Object();
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
@@ -46,22 +45,24 @@ public class PlayerVoteListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onplayerVote(PlayerVoteEvent event) {
|
||||
if (!plugin.isEnabled()) {
|
||||
plugin.getLogger().warning("Plugin disabled, ignoring vote");
|
||||
return;
|
||||
}
|
||||
String playerName = event.getPlayer();
|
||||
plugin.debug("Processing PlayerVoteEvent: " + playerName + "/" + event.getServiceSite());
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
if (!plugin.getConfigFile().isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
if (event.isBungee() && plugin.getBungeeSettings().isRemoveInvalidUsers()) {
|
||||
UserManager.getInstance().getVotingPluginUser(playerName).remove();
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(playerName).remove();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (playerName.isEmpty()) {
|
||||
plugin.getLogger().warning("Empty player name for vote");
|
||||
plugin.getLogger().warning("Empty player name from vote, ignoring");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,7 +105,13 @@ public class PlayerVoteListener implements Listener {
|
||||
if (event.getVotingPluginUser() != null) {
|
||||
user = event.getVotingPluginUser();
|
||||
} else {
|
||||
user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
Player p = Bukkit.getPlayerExact(playerName);
|
||||
if (p != null) {
|
||||
// player online
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
@@ -112,118 +119,128 @@ public class PlayerVoteListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
if (!plugin.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
// reupdate cache
|
||||
user.clearCache();
|
||||
user.cache();
|
||||
final String uuid = user.getUUID();
|
||||
|
||||
user.updateName(true);
|
||||
// reupdate cache
|
||||
user.cache();
|
||||
|
||||
// vote party
|
||||
plugin.getVoteParty().vote(user, event.isRealVote(), event.isForceBungee());
|
||||
user.updateName(true);
|
||||
|
||||
if (event.isBroadcast() && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
// broadcast vote if enabled in config
|
||||
if (plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& (plugin.getBungeeSettings().isBungeeBroadcast() || !event.isBungee())) {
|
||||
if (!plugin.getConfigFile().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
// vote party
|
||||
plugin.getVoteParty().vote(user, event.isRealVote(), event.isForceBungee());
|
||||
|
||||
if (event.isBroadcast() && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
// broadcast vote if enabled in config
|
||||
if (plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& (plugin.getBungeeSettings().isBungeeBroadcast() || !event.isBungee())) {
|
||||
if (!plugin.getConfigFile().isFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getBroadcastHandler() != null) {
|
||||
plugin.getBroadcastHandler().onVote(playerName);
|
||||
if (plugin.getBroadcastHandler() != null) {
|
||||
plugin.getBroadcastHandler().onVote(playerName);
|
||||
}
|
||||
|
||||
long voteTime = 0;
|
||||
// update last vote time
|
||||
if (event.getTime() != 0) {
|
||||
user.setTime(voteSite, event.getTime());
|
||||
voteTime = event.getTime();
|
||||
} else {
|
||||
user.setTime(voteSite);
|
||||
voteTime = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
}
|
||||
|
||||
// try logging to file
|
||||
if (plugin.getConfigFile().isLogVotesToFile()) {
|
||||
try {
|
||||
plugin.logVote(LocalDateTime.now().atZone(ZoneId.systemDefault()).toLocalDateTime(), playerName,
|
||||
voteSite.getKey());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
if (event.getTime() != 0) {
|
||||
user.setTime(voteSite, event.getTime());
|
||||
} else {
|
||||
user.setTime(voteSite);
|
||||
// check first vote rewards
|
||||
plugin.getSpecialRewards().checkFirstVote(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkFirstVoteToday(user, event.isForceBungee());
|
||||
|
||||
if (user.isReminded() && plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
if (((user.isOnline() || voteSite.isGiveOffline()) && plugin.getOptions().isProcessRewards())
|
||||
|| event.isBungee()) {
|
||||
boolean online = true;
|
||||
if (event.isBungee()) {
|
||||
online = event.isWasOnline();
|
||||
}
|
||||
plugin.getCoolDownCheck().vote(user);
|
||||
|
||||
// try logging to file
|
||||
if (plugin.getConfigFile().isLogVotesToFile()) {
|
||||
try {
|
||||
plugin.logVote(LocalDateTime.now().atZone(ZoneId.systemDefault()).toLocalDateTime(), playerName,
|
||||
voteSite.getKey());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// check first vote rewards
|
||||
plugin.getSpecialRewards().checkFirstVote(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkFirstVoteToday(user, event.isForceBungee());
|
||||
|
||||
if (user.isReminded() && plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
if (((user.isOnline() || voteSite.isGiveOffline()) && plugin.getOptions().isProcessRewards())
|
||||
|| event.isBungee()) {
|
||||
boolean online = true;
|
||||
if (event.isBungee()) {
|
||||
online = event.isWasOnline();
|
||||
}
|
||||
user.playerVote(voteSite, online, false, event.isForceBungee());
|
||||
user.playerVote(voteSite, online, false, event.isForceBungee());
|
||||
if (event.getVoteNumber() == 1) {
|
||||
user.sendVoteEffects(online);
|
||||
if (plugin.getConfigFile().isCloseInventoryOnVote()) {
|
||||
user.closeInv();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
if (plugin.getConfigFile().isCloseInventoryOnVote()) {
|
||||
user.closeInv();
|
||||
}
|
||||
} else {
|
||||
if (!plugin.getConfigFile().isOfflineVotesLimitEnabled()
|
||||
|| user.getNumberOfOfflineVotes(voteSite) <= plugin.getConfigFile().getOfflineVotesLimitAmount()) {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
plugin.debug(
|
||||
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
|
||||
} else {
|
||||
plugin.debug("Not setting offline vote, offline vote limit reached");
|
||||
}
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if ((plugin.getConfigFile().isCountFakeVotes() || event.isRealVote()) && event.isAddTotals()) {
|
||||
if (plugin.getConfigFile().isAddTotals()) {
|
||||
// add to total votes
|
||||
if ((plugin.getConfigFile().isCountFakeVotes() || event.isRealVote()) && event.isAddTotals()) {
|
||||
if (plugin.getConfigFile().isAddTotals()) {
|
||||
if (plugin.getConfigFile().isAddTotalsOffline() || user.isOnline()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
user.checkDayVoteStreak(event.isForceBungee());
|
||||
|
||||
user.checkDayVoteStreak(event.isForceBungee());
|
||||
// other rewards
|
||||
plugin.getSpecialRewards().checkAllSites(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkAlmostAllSites(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkCumualativeVotes(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkMilestone(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
plugin.getCoolDownCheck().vote(user, voteSite);
|
||||
|
||||
// other rewards
|
||||
plugin.getSpecialRewards().checkAllSites(user, event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkCumualativeVotes(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
plugin.getSpecialRewards().checkMilestone(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
|
||||
final String uuid = user.getUUID();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteUpdate", uuid);
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
plugin.getPluginMessaging().sendPluginMessage("VoteUpdate", uuid);
|
||||
}
|
||||
}, 40);
|
||||
}
|
||||
}
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
}, 40);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
|
||||
event.isForceBungee());
|
||||
event.isForceBungee(), voteTime);
|
||||
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
|
||||
|
||||
if (!user.isOnline()) {
|
||||
user.clearCache();
|
||||
}
|
||||
plugin.setUpdate(true);
|
||||
|
||||
plugin.extraDebug("Finished vote processing: " + playerName + "/" + uuid);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -47,7 +47,7 @@ public class SignChange implements Listener {
|
||||
plugin.getServerData().addSign(event.getBlock().getLocation(), event.getLine(2),
|
||||
Integer.parseInt(event.getLine(1)));
|
||||
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&aAdded sign!"));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -65,53 +64,66 @@ public class VotiferEvent implements Listener {
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
plugin.debug("IP: " + IP);
|
||||
|
||||
plugin.getVoteTimer().schedule(new TimerTask() {
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServerData().addServiceSite(voteSite);
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getBungeeSettings().isVotifierBypass()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
|
||||
plugin.getLogger().severe(
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
|
||||
return;
|
||||
}
|
||||
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite);
|
||||
try {
|
||||
plugin.getServerData().addServiceSite(voteSite);
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord() && !plugin.getBungeeSettings().isVotifierBypass()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.SOCKETS))) {
|
||||
plugin.getLogger().severe(
|
||||
"Ignoring vote from votifier since pluginmessaging or socket bungee method is enabled, this means you aren't setup correctly for those methods, please check: https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups");
|
||||
return;
|
||||
}
|
||||
String voteSiteNameStr = plugin.getVoteSiteName(false, voteSite);
|
||||
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
|
||||
boolean createSite = false;
|
||||
if (sites != null) {
|
||||
if (!ArrayUtils.getInstance().containsIgnoreCase(sites, voteSiteNameStr)) {
|
||||
ArrayList<String> sites = plugin.getConfigVoteSites().getVoteSitesNames(false);
|
||||
boolean createSite = false;
|
||||
if (sites != null) {
|
||||
if (!ArrayUtils.getInstance().containsIgnoreCase(sites, voteSiteNameStr)) {
|
||||
createSite = true;
|
||||
}
|
||||
} else {
|
||||
createSite = true;
|
||||
}
|
||||
} else {
|
||||
createSite = true;
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
|
||||
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr
|
||||
+ "' does not exist, attempting to generaterate...");
|
||||
plugin.getConfigVoteSites().generateVoteSite(voteSiteNameStr);
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites() && createSite) {
|
||||
plugin.getLogger().warning("VoteSite with service site '" + voteSiteNameStr
|
||||
+ "' does not exist, attempting to generate...");
|
||||
plugin.getConfigVoteSites().generateVoteSite(voteSiteNameStr);
|
||||
|
||||
plugin.getLogger().info("Current known service sites: "
|
||||
+ ArrayUtils.getInstance().makeStringList(plugin.getServerData().getServiceSites()));
|
||||
}
|
||||
plugin.getLogger().info("Current known service sites: "
|
||||
+ ArrayUtils.getInstance().makeStringList(plugin.getServerData().getServiceSites()));
|
||||
}
|
||||
|
||||
String voteSiteName = plugin.getVoteSiteName(true, voteSite);
|
||||
if (plugin.getTimeChecker().isActiveProcessing()
|
||||
&& plugin.getConfigFile().isQueueVotesDuringTimeChange()) {
|
||||
// time change in progress
|
||||
plugin.debug("Adding vote to time queue " + voteUsername + "/" + voteSite);
|
||||
plugin.getTimeQueueHandler().addVote(voteUsername, voteSite);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName, true), voteUsername,
|
||||
voteSite, true);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
return;
|
||||
}
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
String voteSiteName = plugin.getVoteSiteName(true, voteSite);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName, true),
|
||||
voteUsername, voteSite, true);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().severe("Error occured during vote processing");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}, 0);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -138,7 +137,7 @@ public class VoteSite {
|
||||
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
@@ -172,7 +171,8 @@ public class VoteSite {
|
||||
}
|
||||
|
||||
public String getVoteURL(boolean json) {
|
||||
if (!plugin.getConfigFile().isFormatCommandsVoteForceLinks() || !json) {
|
||||
if (!plugin.getConfigFile().isFormatCommandsVoteForceLinks() || !json
|
||||
|| StringParser.getInstance().containsJson(voteURL)) {
|
||||
return voteURL;
|
||||
} else {
|
||||
if (!voteURL.startsWith("http")) {
|
||||
@@ -239,4 +239,19 @@ public class VoteSite {
|
||||
return ArrayUtils.getInstance().containsIgnoreCase(plugin.getServerData().getServiceSites(), getServiceSite());
|
||||
}
|
||||
|
||||
public String loadingDebug() {
|
||||
String str = "Loading votesite key: " + key;
|
||||
str += ", Displayname: " + displayName;
|
||||
str += ", VoteDelay: " + getVoteDelay();
|
||||
str += ", VoteDelayMin: " + getVoteDelayMin();
|
||||
str += ", VoteDelayDaily: " + isVoteDelayDaily();
|
||||
str += ", IsWaitUntilVoteDelay: " + isWaitUntilVoteDelay();
|
||||
str += ", ServiceSite: " + getServiceSite();
|
||||
str += ", TimeOffSet:" + getTimeOffSet();
|
||||
str += ", Url: " + getVoteURL();
|
||||
str += ", IgnoreCanVote: " + isIgnoreCanVote();
|
||||
str += ", Hidden: " + isHidden();
|
||||
return str;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import org.bukkit.Bukkit;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import be.maximvdw.placeholderapi.PlaceholderAPI;
|
||||
@@ -41,11 +40,11 @@ public class MVdWPlaceholders {
|
||||
|
||||
@Override
|
||||
public String onPlaceholderReplace(PlaceholderReplaceEvent event) {
|
||||
VotingPluginUser user = UserManager.getInstance()
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(event.getOfflinePlayer());
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()
|
||||
&& user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
return place.placeholderRequest(user,
|
||||
event.getPlaceholder().substring("VotingPlugin_".length()));
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.placeholder.CalculatingPlaceholder;
|
||||
import com.bencodez.advancedcore.api.placeholder.NonPlayerPlaceHolder;
|
||||
import com.bencodez.advancedcore.api.placeholder.PlaceHolder;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
@@ -26,7 +27,6 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -47,17 +47,67 @@ public class PlaceHolders {
|
||||
|
||||
public PlaceHolders(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
cacheLevel = plugin.getConfigFile().getPlaceholderCacheLevel();
|
||||
onUpdate();
|
||||
if (!cacheLevel.equals(PlaceholderCacheLevel.NONE)) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
onUpdate(plugin.getVotingPluginUserManager().getVotingPluginUser(player), player.isOnline());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
|
||||
private ConcurrentLinkedQueue<String> placeholdersToSetCacheOn = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
@Getter
|
||||
private PlaceholderCacheLevel cacheLevel;
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
return getPlaceHolder(p, identifier, true);
|
||||
}
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier, boolean javascript) {
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier1, boolean javascript) {
|
||||
boolean forceProcess = false;
|
||||
boolean useCache = true;
|
||||
String identifier = identifier1.toLowerCase();
|
||||
boolean custom = false;
|
||||
if (identifier.endsWith("_process")) {
|
||||
forceProcess = true;
|
||||
identifier = identifier.replaceAll("_process", "");
|
||||
}
|
||||
if (identifier.endsWith("_nocache")) {
|
||||
useCache = false;
|
||||
identifier = identifier.replaceAll("_nocache", "");
|
||||
}
|
||||
if (getCacheLevel().equals(PlaceholderCacheLevel.NONE)) {
|
||||
useCache = false;
|
||||
}
|
||||
|
||||
if (identifier.startsWith("custom_")) {
|
||||
custom = true;
|
||||
identifier = identifier.replaceAll("custom_", "");
|
||||
}
|
||||
|
||||
if (custom && plugin.getConfigFile().getCustomPlaceholderReturns().contains(identifier)) {
|
||||
String str = getPlaceholderValue(p, identifier, javascript, true, useCache);
|
||||
String returnStr = plugin.getConfigFile().getCustomPlaceholderReturns(identifier, str);
|
||||
if (!returnStr.isEmpty()) {
|
||||
return returnStr;
|
||||
}
|
||||
return str;
|
||||
} else {
|
||||
return getPlaceholderValue(p, identifier, javascript, forceProcess, useCache);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getPlaceholderValue(OfflinePlayer p, String identifier, boolean javascript, boolean forceProcess,
|
||||
boolean useCache) {
|
||||
if (plugin.getConfigFile().isUseJavascriptPlaceholders() && javascript && p != null) {
|
||||
identifier = StringParser.getInstance().replaceJavascript(p, identifier);
|
||||
}
|
||||
@@ -76,37 +126,109 @@ public class PlaceHolders {
|
||||
if (p == null) {
|
||||
return "no player";
|
||||
}
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (!cachedPlaceholders.contains(identifier)) {
|
||||
if (Bukkit.isPrimaryThread() || plugin.getConfigFile().isAlwaysWaitForCachePlaceholders()) {
|
||||
user.setWaitForCache(false);
|
||||
if (!user.isCached()) {
|
||||
user.loadCache();
|
||||
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (useCache) {
|
||||
if (!cachedPlaceholders.contains(identifier)) {
|
||||
// not cached placeholder
|
||||
if (!forceProcess) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(identifier)) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return "..";
|
||||
}
|
||||
}
|
||||
return "..";
|
||||
return "Not a valid placeholder";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders()) {
|
||||
if (user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
try {
|
||||
if (placeholder.matches(identifier)) {
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
if (placeholder instanceof CalculatingPlaceholder<?>) {
|
||||
if (useCache) {
|
||||
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
if (cPlaceholder.getCacheData().containsKey(user.getJavaUUID())) {
|
||||
return cPlaceholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
return cache.get(p.getUniqueId());
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
|
||||
if (forceProcess) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
} else {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return ".";
|
||||
}
|
||||
} else {
|
||||
return "....";
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
if (useCache) {
|
||||
if (placeholder.isUsesCache() && placeholder.isCached(identifier)) {
|
||||
ConcurrentHashMap<UUID, String> cache = placeholder.getCache().get(identifier);
|
||||
if (cache.containsKey(p.getUniqueId())) {
|
||||
return cache.get(p.getUniqueId());
|
||||
} else if (!forceProcess) {
|
||||
schedulePlaceholderCheck(user);
|
||||
return "...";
|
||||
}
|
||||
}
|
||||
|
||||
if (forceProcess) {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
} else {
|
||||
if (getCacheLevel().shouldCache()) {
|
||||
if (!placeholdersToSetCacheOn.contains(identifier)
|
||||
&& !cachedPlaceholders.contains(identifier)) {
|
||||
placeholdersToSetCacheOn.add(identifier);
|
||||
schedulePlaceholderCheck(user);
|
||||
}
|
||||
}
|
||||
return ".";
|
||||
}
|
||||
} else {
|
||||
return placeholder.placeholderRequest(user, identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -172,6 +294,47 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("User milestonecount").updateDataKey("MilestoneCount"));
|
||||
|
||||
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
for (String vote : mVotes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
|
||||
final int num = Integer.parseInt(vote);
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("milestone_numberofvotesuntil_" + num) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int toGo = num - user.getMilestoneCount();
|
||||
if (toGo >= 0) {
|
||||
return "" + toGo;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
}.withDescription("Get number of votes until milestone").updateDataKey("MilestoneCount"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("nextmilestone_votes_required") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
return "" + user.getNextAvailableMileStone();
|
||||
}
|
||||
}.withDescription("Get number of votes required for next available milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("nextmilestone_votes_until") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int toGo = user.getNextAvailableMileStone() - user.getMilestoneCount();
|
||||
if (toGo >= 0) {
|
||||
return "" + toGo;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
}.withDescription("Get number of votes until next available milestone").updateDataKey("MilestoneCount"));
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
if (plugin.getGui().getChestShopIdentifierLimit(identifier) > 0) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("VoteShopLimit_" + identifier) {
|
||||
@@ -329,12 +492,25 @@ public class PlaceHolders {
|
||||
}.withDescription("How long until user can vote on anysite").updateDataKey("LastVotes"));
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Next_" + voteSite.getKey()) {
|
||||
placeholders.add(new CalculatingPlaceholder<VotingPluginUser>("Next_" + voteSite.getKey()) {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
if (getCacheData().containsKey(user.getJavaUUID())) {
|
||||
String data = getCacheData().get(user.getJavaUUID());
|
||||
if (!data.isEmpty()) {
|
||||
long time = Long.valueOf(data);
|
||||
return user.voteCommandNextInfo(voteSite, time);
|
||||
}
|
||||
}
|
||||
return user.voteCommandNextInfo(voteSite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String placeholderDataRequest(VotingPluginUser user, String identifier) {
|
||||
long time = user.getTime(voteSite);
|
||||
return "" + time;
|
||||
}
|
||||
}.withDescription("How long until user can vote on " + voteSite.getKey()).updateDataKey("LastVotes"));
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("Last_" + voteSite.getKey()) {
|
||||
|
||||
@@ -368,6 +544,18 @@ public class PlaceHolders {
|
||||
}
|
||||
}.withDescription("Get user top voter position"));
|
||||
|
||||
placeholders.add(new PlaceHolder<VotingPluginUser>("EnoughPoints_") {
|
||||
|
||||
@Override
|
||||
public String placeholderRequest(VotingPluginUser user, String identifier) {
|
||||
int number = Integer.parseInt(identifier.split("_")[1]);
|
||||
if (user.getPoints() >= number) {
|
||||
return "true";
|
||||
}
|
||||
return "false";
|
||||
}
|
||||
}.withDescription("Return true/false if player has said points").updateDataKey("Points").useStartsWith());
|
||||
|
||||
nonPlayerPlaceholders.add(new NonPlayerPlaceHolder<VotingPluginUser>("Top_AllVotes_") {
|
||||
|
||||
@Override
|
||||
@@ -597,7 +785,7 @@ public class PlaceHolders {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyCurrent());
|
||||
}
|
||||
return "" + 0;
|
||||
return "-1";
|
||||
}
|
||||
}.withDescription("Current amount of bungee voteparty votes"));
|
||||
|
||||
@@ -609,7 +797,7 @@ public class PlaceHolders {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired()
|
||||
- plugin.getBungeeHandler().getBungeeVotePartyCurrent());
|
||||
}
|
||||
return "" + 0;
|
||||
return "-1";
|
||||
}
|
||||
}.withDescription("Voteparty bungee votes needed"));
|
||||
|
||||
@@ -620,7 +808,7 @@ public class PlaceHolders {
|
||||
if (plugin.getBungeeHandler() != null) {
|
||||
return Integer.toString(plugin.getBungeeHandler().getBungeeVotePartyRequired());
|
||||
}
|
||||
return "" + 0;
|
||||
return "-1";
|
||||
}
|
||||
}.withDescription("Amount of votes needed for bungee voteparty"));
|
||||
|
||||
@@ -712,43 +900,27 @@ public class PlaceHolders {
|
||||
|
||||
Set<String> placeholdersSet = new HashSet<String>();
|
||||
placeholdersSet.addAll(plugin.getConfigFile().getCachedPlaceholders());
|
||||
if (plugin.getConfigFile().isAutoCachePlaceholders()) {
|
||||
if (getCacheLevel().equals(PlaceholderCacheLevel.AUTO)) {
|
||||
placeholdersSet.addAll(plugin.getServerData().getAutoCachedPlaceholder());
|
||||
}
|
||||
|
||||
for (String toCache : placeholdersSet) {
|
||||
if (toCache.startsWith("VotingPlugin")) {
|
||||
toCache = toCache.substring("VotingPlugin_".length());
|
||||
if (toCache.startsWith("votingplugin")) {
|
||||
toCache = toCache.substring("votingplugin_".length());
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUseStartsWith()) {
|
||||
if (toCache.startsWith(placeholder.getIdentifier())) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
} else {
|
||||
if (placeholder.getIdentifier().equalsIgnoreCase(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.extraDebug("Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -757,19 +929,45 @@ public class PlaceHolders {
|
||||
|
||||
@Override
|
||||
public void onChange(AdvancedCoreUser user, String... keys) {
|
||||
VotingPluginUser vpUser = plugin.getVotingPluginUserManager().getVotingPluginUser(user);
|
||||
if (!vpUser.isCached()) {
|
||||
vpUser.dontCache();
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String key : keys) {
|
||||
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
|
||||
VotingPluginUser vpUser = UserManager.getInstance().getVotingPluginUser(user);
|
||||
user.dontCache();
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(),
|
||||
placeholder.placeholderRequest(vpUser, ident));
|
||||
plugin.devDebug("Updated cache for " + vpUser.getUUID() + " on " + key);
|
||||
|
||||
if (placeholder.isCached(placeholder.getIdentifier(), user.getJavaUUID())
|
||||
|| !getCacheLevel().onlineOnly() || user.isOnline()) {
|
||||
if (placeholder instanceof CalculatingPlaceholder<?>) {
|
||||
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String key : keys) {
|
||||
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
String value = placeholder.placeholderRequest(vpUser, ident);
|
||||
cPlaceholder.getCacheData().put(user.getJavaUUID(),
|
||||
cPlaceholder.placeholderDataRequest(vpUser, ident));
|
||||
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
|
||||
plugin.devDebug("Updated calculating placeholder cache for "
|
||||
+ vpUser.getUUID() + " on " + key + " with " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String key : keys) {
|
||||
if (placeholder.getUpdateDataKey().equalsIgnoreCase(key)) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
String value = placeholder.placeholderRequest(vpUser, ident);
|
||||
placeholder.getCache().get(ident).put(vpUser.getJavaUUID(), value);
|
||||
plugin.devDebug("Updated placeholder cache for " + vpUser.getUUID()
|
||||
+ " on " + key + " with " + value);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -779,97 +977,112 @@ public class PlaceHolders {
|
||||
}
|
||||
|
||||
public void onVotePartyUpdate() {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("VoteParty")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { if
|
||||
* (placeholder.getIdentifier().startsWith("VoteParty")) { for (String ident :
|
||||
* placeholder.getCache().keySet()) { placeholder.getCache().put(ident,
|
||||
* placeholder.placeholderRequest(ident)); } } } }
|
||||
*/
|
||||
}
|
||||
|
||||
public void onBungeeVotePartyUpdate() {
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("BungeeVoteParty")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().put(ident, placeholder.placeholderRequest(ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { if
|
||||
* (placeholder.getIdentifier().startsWith("BungeeVoteParty")) { for (String
|
||||
* ident : placeholder.getCache().keySet()) { placeholder.getCache().put(ident,
|
||||
* placeholder.placeholderRequest(ident)); } } } }
|
||||
*/
|
||||
}
|
||||
|
||||
public void onUpdate(VotingPluginUser user) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (!placeholder.getIdentifier().startsWith("Top_") || placeholder.getCache().isEmpty()
|
||||
|| placeholder.getUpdateDataKey().isEmpty()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll();
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
}
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.debug("Auto caching placeholder: " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
for (NonPlayerPlaceHolder<VotingPluginUser> placeholder : nonPlayerPlaceholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
if (ident != null) {
|
||||
String str = placeholder.placeholderRequest(ident);
|
||||
if (str != null) {
|
||||
placeholder.getCache().put(ident, str);
|
||||
}
|
||||
} else {
|
||||
plugin.debug("ident null: " + placeholder.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String uuid : uuids) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
public void onLogout(VotingPluginUser user) {
|
||||
if (plugin.getPlaceholders().getCacheLevel().onlineOnly()) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.getIdentifier().startsWith("Top_")) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
if (ident != null) {
|
||||
placeholder.clearCachePlayer(user.getJavaUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onUpdate(VotingPluginUser user, boolean login) {
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.isUsesCache()) {
|
||||
if (placeholder.isCached(placeholder.getIdentifier(), user.getJavaUUID()) || login) {
|
||||
if (placeholder instanceof CalculatingPlaceholder<?>) {
|
||||
|
||||
CalculatingPlaceholder<VotingPluginUser> cPlaceholder = (CalculatingPlaceholder<VotingPluginUser>) placeholder;
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
cPlaceholder.getCacheData().put(user.getJavaUUID(),
|
||||
cPlaceholder.placeholderDataRequest(user, ident));
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (placeholder.isUsesCache()) {
|
||||
for (String ident : placeholder.getCache().keySet()) {
|
||||
placeholder.getCache().get(ident).put(user.getJavaUUID(),
|
||||
placeholder.placeholderRequest(user, ident));
|
||||
} else {
|
||||
plugin.debug("ident null: " + placeholder.getIdentifier());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkNonCachedPlaceholders() {
|
||||
while (!placeholdersToSetCacheOn.isEmpty()) {
|
||||
String toCache = placeholdersToSetCacheOn.poll().toLowerCase();
|
||||
if (toCache.startsWith("votingplugin")) {
|
||||
toCache = toCache.substring("votingplugin_".length());
|
||||
}
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.matches(toCache)) {
|
||||
* placeholder.setUseCache(true, toCache); cachedPlaceholders.add(toCache);
|
||||
* plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
* plugin.extraDebug("Auto Caching placeholder " + toCache); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : placeholders) {
|
||||
if (placeholder.matches(toCache)) {
|
||||
placeholder.setUseCache(true, toCache);
|
||||
cachedPlaceholders.add(toCache);
|
||||
plugin.getServerData().addAutoCachedPlaceholder(toCache);
|
||||
plugin.extraDebug("Auto Caching placeholder " + toCache);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void schedulePlaceholderCheck(VotingPluginUser user) {
|
||||
plugin.getTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkNonCachedPlaceholders();
|
||||
onUpdate(user, user.isOnline());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void onUpdate() {
|
||||
checkNonCachedPlaceholders();
|
||||
/*
|
||||
* for (NonPlayerPlaceHolder<VotingPluginUser> placeholder :
|
||||
* nonPlayerPlaceholders) { if (placeholder.isUsesCache()) { for (String ident :
|
||||
* placeholder.getCache().keySet()) { if (ident != null) { String str =
|
||||
* placeholder.placeholderRequest(ident); if (str != null) {
|
||||
* placeholder.getCache().put(ident, str); } } else {
|
||||
* plugin.debug("ident null: " + placeholder.getIdentifier()); } } } }
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.bencodez.votingplugin.placeholders;
|
||||
|
||||
public enum PlaceholderCacheLevel {
|
||||
NONE, SPECIFIC, AUTO, AUTOALL, SPECIFICALL;
|
||||
|
||||
public static PlaceholderCacheLevel getCache(String str) {
|
||||
for (PlaceholderCacheLevel v : PlaceholderCacheLevel.values()) {
|
||||
if (v.toString().equalsIgnoreCase(str)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return AUTO;
|
||||
}
|
||||
|
||||
public boolean onlineOnly() {
|
||||
if (this == AUTOALL) {
|
||||
return false;
|
||||
}
|
||||
if (this == SPECIFICALL) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldCache() {
|
||||
switch (this) {
|
||||
case AUTO:
|
||||
return true;
|
||||
case NONE:
|
||||
return false;
|
||||
case SPECIFIC:
|
||||
return false;
|
||||
case SPECIFICALL:
|
||||
return false;
|
||||
case AUTOALL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package com.bencodez.votingplugin.placeholders;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
|
||||
public class VotingPluginExpansion extends PlaceholderExpansion {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public VotingPluginExpansion(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "bencodez";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "votingplugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return "1.6";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(OfflinePlayer p, String indendifier) {
|
||||
return plugin.getPlaceholders().getPlaceHolder(p, indendifier);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.bencodez.votingplugin.signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
@@ -14,6 +13,7 @@ import org.bukkit.block.data.Directional;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -111,7 +111,7 @@ public class SignHandler {
|
||||
* Check valid sign.
|
||||
*/
|
||||
public void checkValidSign() {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -121,7 +121,7 @@ public class SignHandler {
|
||||
setValid(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, getLocation());
|
||||
|
||||
}
|
||||
|
||||
@@ -240,8 +240,9 @@ public class SignHandler {
|
||||
* @param delay the delay
|
||||
*/
|
||||
public void updateSign(int delay) {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
@@ -261,7 +262,7 @@ public class SignHandler {
|
||||
VotingPluginMain.plugin.debug(ex);
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
}, delay, getLocation());
|
||||
}
|
||||
|
||||
public void updateSkulls(Location loc1, Location loc2) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.bencodez.votingplugin.specialrewards;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -48,6 +49,22 @@ public class SpecialRewards {
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public boolean checkAlmostAllSites(VotingPluginUser user, boolean forceBungee) {
|
||||
boolean checkAllVotes = user.checkAlmostAllVotes();
|
||||
if (checkAllVotes) {
|
||||
int currentDay = LocalDateTime.now().getDayOfYear();
|
||||
int day = user.getGottenAlmostAllSitesDay();
|
||||
if (currentDay == day) {
|
||||
checkAllVotes = false;
|
||||
plugin.debug("Not giving almostallsites, already gotten today");
|
||||
} else {
|
||||
user.setGottenAlmostAllSitesDay(currentDay);
|
||||
giveAlmostAllSitesRewards(user, user.isOnline(), forceBungee);
|
||||
}
|
||||
}
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public boolean checkCumualativeVotes(VotingPluginUser user, BungeeMessageData bungeeMessageData,
|
||||
boolean forceBungee) {
|
||||
boolean gotCumulativeAny = false;
|
||||
@@ -86,8 +103,25 @@ public class SpecialRewards {
|
||||
}
|
||||
}
|
||||
|
||||
if (total != 0 && total >= votesRequired) {
|
||||
if ((total % votesRequired) == 0) {
|
||||
List<Integer> blackList = plugin.getSpecialRewardsConfig()
|
||||
.getCumulativeBlackList(votesRequired);
|
||||
boolean blackListed = false;
|
||||
for (Integer num : blackList) {
|
||||
if (num.intValue() == total) {
|
||||
blackListed = true;
|
||||
plugin.extraDebug("Not giving cumulative " + votesRequired + " to "
|
||||
+ user.getPlayerName() + " due to blacklist");
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRecurring(votesRequired)) {
|
||||
if (total != 0 && total >= votesRequired) {
|
||||
if ((total % votesRequired) == 0 && !blackListed) {
|
||||
gotCumulative = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (total == votesRequired) {
|
||||
gotCumulative = true;
|
||||
}
|
||||
}
|
||||
@@ -265,6 +299,18 @@ public class SpecialRewards {
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveAlmostAllSitesRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.ALMOSTALLSITES);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAlmostAllSitesRewardPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveCumulativeVoteReward(VotingPluginUser user, boolean online, int cumulative, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.CUMMULATIVE.setAmount(cumulative));
|
||||
@@ -276,7 +322,7 @@ public class SpecialRewards {
|
||||
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(cumulative)).setServer(forceBungee)
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
}
|
||||
|
||||
public void giveFirstVoteRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
@@ -313,7 +359,7 @@ public class SpecialRewards {
|
||||
}
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMilestoneRewardsPath(milestone)).setOnline(online)
|
||||
.withPlaceHolder("Milestone", "" + milestone).setServer(forceBungee).send(user);
|
||||
.withPlaceHolder("Milestone", "" + milestone).setServer(forceBungee).send(user);
|
||||
}
|
||||
|
||||
public void giveVoteStreakReward(VotingPluginUser user, boolean online, String type, String string, int votes,
|
||||
@@ -327,8 +373,7 @@ public class SpecialRewards {
|
||||
}
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath(type, string)).setOnline(online)
|
||||
.withPlaceHolder("Type", type).setServer(forceBungee).withPlaceHolder("Streak", "" + votes)
|
||||
.send(user);
|
||||
.withPlaceHolder("Type", type).setServer(forceBungee).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +1,156 @@
|
||||
package com.bencodez.votingplugin.test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTester {
|
||||
|
||||
private static VoteTester instance = new VoteTester();
|
||||
|
||||
public static VoteTester getInstance() {
|
||||
return instance;
|
||||
public VoteTester(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public void testRewards(int amount, String name, String rewardName) {
|
||||
long time1 = System.currentTimeMillis();
|
||||
ArrayList<Long> timesPerReward = new ArrayList<Long>();
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
Reward reward = plugin.getRewardHandler().getReward(rewardName);
|
||||
int rewardsGiven = 0;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long start1 = System.currentTimeMillis();
|
||||
if (reward.canGiveReward(user, new RewardOptions())) {
|
||||
rewardsGiven++;
|
||||
plugin.getRewardHandler().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long time1 = System.currentTimeMillis();
|
||||
ArrayList<Long> timesPerReward = new ArrayList<Long>();
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(name);
|
||||
Reward reward = plugin.getRewardHandler().getReward(rewardName);
|
||||
int rewardsGiven = 0;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long start1 = System.currentTimeMillis();
|
||||
if (reward.canGiveReward(user, new RewardOptions())) {
|
||||
rewardsGiven++;
|
||||
plugin.getRewardHandler().giveReward(user, reward,
|
||||
new RewardOptions().setIgnoreRequirements(true));
|
||||
}
|
||||
long start2 = System.currentTimeMillis();
|
||||
timesPerReward.add(start2 - start1);
|
||||
}
|
||||
long time2 = System.currentTimeMillis();
|
||||
long time = time2 - time1;
|
||||
long timeTotal = 0;
|
||||
for (Long t : timesPerReward) {
|
||||
timeTotal += t.longValue();
|
||||
}
|
||||
long timePerRewardAvg = timeTotal / timesPerReward.size();
|
||||
VotingPluginMain.plugin.getLogger()
|
||||
.info("Time to process rewards (" + amount + "): " + time + " ms, average per reward "
|
||||
+ timePerRewardAvg + " ms. " + VotingPluginMain.plugin.getStorageType() + ", "
|
||||
+ plugin.getVotingPluginUserManager().getAllUUIDs().size() + " users. " + rewardsGiven
|
||||
+ " rewards given");
|
||||
}
|
||||
long start2 = System.currentTimeMillis();
|
||||
timesPerReward.add(start2 - start1);
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private String getSaltString() {
|
||||
String SALTCHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
StringBuilder salt = new StringBuilder();
|
||||
Random rnd = new Random();
|
||||
while (salt.length() < 18) { // length of the random string.
|
||||
int index = (int) (rnd.nextFloat() * SALTCHARS.length());
|
||||
salt.append(SALTCHARS.charAt(index));
|
||||
}
|
||||
long time2 = System.currentTimeMillis();
|
||||
long time = time2 - time1;
|
||||
long timeTotal = 0;
|
||||
for (Long t : timesPerReward) {
|
||||
timeTotal += t.longValue();
|
||||
String saltStr = salt.toString();
|
||||
return saltStr;
|
||||
|
||||
}
|
||||
|
||||
public void generatePlayers(int numberOfPlayers) {
|
||||
if (plugin.getOptions().getDebug().isDebug()) {
|
||||
int num = 1;
|
||||
String salt = getSaltString();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < numberOfPlayers; i++) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
if (!plugin.getUserManager().userExist(uuid)) {
|
||||
String playerName = salt + num;
|
||||
if (!plugin.getUserManager().userExist(playerName)) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid,
|
||||
playerName);
|
||||
user.dontCache();
|
||||
user.setPoints(random.nextInt(100));
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
user.setTotal(top, random.nextInt(1000));
|
||||
}
|
||||
user.setMilestoneCount(random.nextInt(100));
|
||||
user.setPlayerName(playerName);
|
||||
user.updateName(true);
|
||||
num++;
|
||||
plugin.debug("Generated user " + uuid.toString() + "/" + playerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
long timePerRewardAvg = timeTotal / timesPerReward.size();
|
||||
VotingPluginMain.plugin.getLogger().info("Time to process rewards (" + amount + "): " + time
|
||||
+ " ms, average per reward " + timePerRewardAvg + " ms. " + VotingPluginMain.plugin.getStorageType()
|
||||
+ ", " + UserManager.getInstance().getAllUUIDs().size() + " users. " + rewardsGiven + " rewards given");
|
||||
}
|
||||
|
||||
public void testVotes(int amount, String name, String site) {
|
||||
long time1 = System.currentTimeMillis();
|
||||
ArrayList<Long> timesPerVote = new ArrayList<Long>();
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
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, false), 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();
|
||||
VotingPluginMain.plugin.getLogger()
|
||||
.info("Time to process votes (" + amount + "): " + time + " ms, average per vote "
|
||||
+ timePerVoteAvg + " ms. " + VotingPluginMain.plugin.getStorageType() + ", "
|
||||
+ plugin.getVotingPluginUserManager().getAllUUIDs().size() + " users. "
|
||||
+ VotingPluginMain.plugin.getVoteSites().size() + " votesites");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void testSpam(int amount, String name, String site) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long start1 = System.currentTimeMillis();
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(site, false), name,
|
||||
plugin.getVoteSiteServiceSite(site), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
long start2 = System.currentTimeMillis();
|
||||
timesPerVote.add(start2 - start1);
|
||||
BukkitScheduler.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(site, false), name,
|
||||
plugin.getVoteSiteServiceSite(site), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
long time2 = System.currentTimeMillis();
|
||||
long time = time2 - time1;
|
||||
long timeTotal = 0;
|
||||
for (Long t : timesPerVote) {
|
||||
timeTotal += t.longValue();
|
||||
}
|
||||
long timePerVoteAvg = timeTotal / timesPerVote.size();
|
||||
VotingPluginMain.plugin.getLogger()
|
||||
.info("Time to process votes (" + amount + "): " + time + " ms, average per vote " + timePerVoteAvg
|
||||
+ " ms. " + VotingPluginMain.plugin.getStorageType() + ", "
|
||||
+ UserManager.getInstance().getAllUUIDs().size() + " users. "
|
||||
+ VotingPluginMain.plugin.getVoteSites().size() + " votesites");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.bencodez.votingplugin.timequeue;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class TimeQueueHandler implements Listener {
|
||||
@Getter
|
||||
private Queue<VoteTimeQueue> timeChangeQueue = new ConcurrentLinkedQueue<VoteTimeQueue>();
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public TimeQueueHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
load();
|
||||
}
|
||||
|
||||
public void processQueue() {
|
||||
while (getTimeChangeQueue().size() > 0) {
|
||||
VoteTimeQueue vote = getTimeChangeQueue().remove();
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(plugin.getVoteSiteName(true, vote.getService()), true), vote.getName(),
|
||||
vote.getService(), true);
|
||||
voteEvent.setTime(voteEvent.getTime());
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addVote(String voteUsername, String voteSiteName) {
|
||||
timeChangeQueue.add(new VoteTimeQueue(voteUsername, voteSiteName,
|
||||
LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void postTimeChange(DateChangedEvent event) {
|
||||
plugin.getVoteTimer().schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
processQueue();
|
||||
}
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
for (String str : plugin.getServerData().getTimedVoteCacheKeys()) {
|
||||
ConfigurationSection data = plugin.getServerData().getTimedVoteCacheSection(str);
|
||||
timeChangeQueue
|
||||
.add(new VoteTimeQueue(data.getString("Name"), data.getString("Service"), data.getLong("Time")));
|
||||
}
|
||||
plugin.getServerData().clearTimedVoteCache();
|
||||
plugin.getVoteTimer().schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
processQueue();
|
||||
}
|
||||
}, 120, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
if (!timeChangeQueue.isEmpty()) {
|
||||
int num = 0;
|
||||
for (VoteTimeQueue vote : timeChangeQueue) {
|
||||
plugin.getServerData().addTimeVoted(num, vote);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
timeChangeQueue.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.bencodez.votingplugin.timequeue;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class VoteTimeQueue {
|
||||
@Getter
|
||||
@Setter
|
||||
private String name;
|
||||
@Getter
|
||||
@Setter
|
||||
private String service;
|
||||
@Getter
|
||||
@Setter
|
||||
private long time;
|
||||
|
||||
public VoteTimeQueue(String name, String service, long time) {
|
||||
this.name = name;
|
||||
this.service = service;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@ package com.bencodez.votingplugin.topvoter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.bencodez.advancedcore.api.time.TimeType;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum TopVoter {
|
||||
AllTime, Monthly, Weekly, Daily;
|
||||
|
||||
@@ -44,6 +47,25 @@ public enum TopVoter {
|
||||
}
|
||||
}
|
||||
|
||||
public String getLastColumnName() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return null;
|
||||
case Daily:
|
||||
return "LastDailyTotal";
|
||||
case Monthly:
|
||||
return "LastMonthTotal";
|
||||
case Weekly:
|
||||
return "LastWeeklyTotal";
|
||||
default:
|
||||
return null;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private ArrayList<TopVoter> switchItems = new ArrayList<TopVoter>();
|
||||
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return VotingPluginMain.plugin.getConfigFile().getFormatTopVoterMonthly();
|
||||
@@ -58,18 +80,23 @@ public enum TopVoter {
|
||||
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
if (switchItems != null && !switchItems.isEmpty()) {
|
||||
list.addAll(switchItems);
|
||||
} else {
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int next = i + 1;
|
||||
@@ -84,17 +111,21 @@ public enum TopVoter {
|
||||
|
||||
public TopVoter prev() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
if (switchItems != null && !switchItems.isEmpty()) {
|
||||
list.addAll(switchItems);
|
||||
} else {
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (VotingPluginMain.plugin.getConfigFile().isLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
}
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
if (list.get(i).equals(this)) {
|
||||
@@ -107,4 +138,17 @@ public enum TopVoter {
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
public static TopVoter of(TimeType type) {
|
||||
switch (type) {
|
||||
case DAY:
|
||||
return Daily;
|
||||
case MONTH:
|
||||
return Monthly;
|
||||
case WEEK:
|
||||
return Weekly;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,10 @@ import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.PreDateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
|
||||
import com.bencodez.advancedcore.api.user.UserStorage;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFileHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class TopVoterHandler implements Listener {
|
||||
@@ -54,7 +54,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<TopVoterPlayer> users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine().replace("%num%", "" + (i + 1))
|
||||
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine().replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%", "" + plugin.getTopVoter(TopVoter.Weekly).get(users.get(i)));
|
||||
msg.add(line);
|
||||
@@ -87,14 +87,27 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getGui().isLastMonthGUI()) {
|
||||
plugin.getLastMonthTopVoter().clear();
|
||||
LinkedHashMap<TopVoterPlayer, Integer> totals = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user.getTopVoterPlayer(), total);
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
int total = user.getLastMonthTotal();
|
||||
if (total > 0) {
|
||||
totals.put(user.getTopVoterPlayer(), total);
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getLastMonthTopVoter().putAll(sortByValues(totals, false));
|
||||
|
||||
@@ -113,39 +126,45 @@ public class TopVoterHandler implements Listener {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
|
||||
if (user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestDailyTotal() < user.getTotal(TopVoter.Daily)) {
|
||||
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().getStoreTopVotersDaily()) {
|
||||
if (plugin.getConfigFile().isStoreTopVotersDaily()) {
|
||||
plugin.getLogger().info("Saving TopVoters Daily");
|
||||
storeTopVoters(TopVoter.Daily);
|
||||
}
|
||||
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Daily.getColumnName(), TopVoter.Daily.getLastColumnName());
|
||||
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(),
|
||||
false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (!user.voteStreakUpdatedToday(LocalDateTime.now().minusDays(1))) {
|
||||
if (user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestDailyTotal() < user.getTotal(TopVoter.Daily)) {
|
||||
user.setHighestDailyTotal(user.getTotal(TopVoter.Daily));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (plugin.getSpecialRewardsConfig().isEnableDailyRewards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(
|
||||
@@ -156,18 +175,20 @@ public class TopVoterHandler implements Listener {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Daily).clone();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().isTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
user.giveDailyTopVoterAward(i, places.get(i));
|
||||
plugin.getLogger().info(
|
||||
"Giving daily top voter reward " + i + " to " + entry.getKey().getPlayerName());
|
||||
}
|
||||
}
|
||||
lastTotal = entry.getValue().intValue();
|
||||
@@ -183,12 +204,22 @@ public class TopVoterHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
resetTotals(TopVoter.Daily);
|
||||
// give time for other servers to catch up
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!bungeeHandleResets()) {
|
||||
resetTotals(TopVoter.Daily);
|
||||
}
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
@@ -201,34 +232,46 @@ public class TopVoterHandler implements Listener {
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
plugin.getLogger().info("Saving TopVoters Monthly");
|
||||
storeTopVoters(TopVoter.Monthly);
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Monthly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
|
||||
LocalDateTime.now().minusDays(1))) {
|
||||
user.addMonthVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Month",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
if (!bungeeHandleResets()) {
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Monthly.getColumnName(),
|
||||
TopVoter.Monthly.getLastColumnName());
|
||||
}
|
||||
if (plugin.getConfigFile().isUseHighestTotals() || plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(),
|
||||
false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Monthly) == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Monthly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementMonth(),
|
||||
LocalDateTime.now().minusDays(1))) {
|
||||
user.addMonthVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Month",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
|
||||
// using new system
|
||||
// user.setLastMonthTotal(user.getTotal(TopVoter.Monthly));
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
|
||||
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestMonthlyTotal() < user.getTotal(TopVoter.Monthly)) {
|
||||
user.setHighestMonthlyTotal(user.getTotal(TopVoter.Monthly));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
user.clearTempCache();
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -242,18 +285,21 @@ public class TopVoterHandler implements Listener {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Monthly).clone();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
|
||||
if (places.containsKey(i)) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().isTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
user.giveMonthlyTopVoterAward(i, places.get(i));
|
||||
plugin.getLogger().info("Giving Monthly top voter reward " + i + " to "
|
||||
+ entry.getKey().getPlayerName());
|
||||
}
|
||||
}
|
||||
lastTotal = entry.getValue().intValue();
|
||||
@@ -264,7 +310,7 @@ public class TopVoterHandler implements Listener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getResetMilestonesMonthly()) {
|
||||
if (plugin.getSpecialRewardsConfig().isResetMilestonesMonthly()) {
|
||||
resetMilestoneCount();
|
||||
resetGottenMilestones();
|
||||
}
|
||||
@@ -274,12 +320,23 @@ public class TopVoterHandler implements Listener {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
resetTotals(TopVoter.Monthly);
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (!bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!bungeeHandleResets()) {
|
||||
resetTotals(TopVoter.Monthly);
|
||||
}
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
}
|
||||
@@ -295,38 +352,46 @@ public class TopVoterHandler implements Listener {
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
synchronized (VotingPluginMain.plugin) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.tempCache();
|
||||
user.getUserData().updateCacheWithTemp();
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Weekly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementWeek(), null)) {
|
||||
user.addWeekVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Week",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
|
||||
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().getStoreTopVotersWeekly()) {
|
||||
if (plugin.getConfigFile().isStoreTopVotersWeekly()) {
|
||||
plugin.getLogger().info("Saving TopVoters Weekly");
|
||||
storeTopVoters(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
plugin.getUserManager().copyColumnData(TopVoter.Weekly.getColumnName(),
|
||||
TopVoter.Weekly.getLastColumnName());
|
||||
if (plugin.getConfigFile().isUseVoteStreaks() || plugin.getConfigFile().isUseHighestTotals()) {
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerData.getKey(),
|
||||
false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
if (plugin.getConfigFile().isUseVoteStreaks()) {
|
||||
if (user.getTotal(TopVoter.Weekly) == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
} else {
|
||||
if (!plugin.getSpecialRewardsConfig().isVoteStreakRequirementUsePercentage()
|
||||
|| user.hasPercentageTotal(TopVoter.Weekly,
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRequirementWeek(), null)) {
|
||||
user.addWeekVoteStreak();
|
||||
plugin.getSpecialRewards().checkVoteStreak(user, "Week",
|
||||
plugin.getBungeeSettings().isUseBungeecoord());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isUseHighestTotals()) {
|
||||
if (user.getHighestWeeklyTotal() < user.getTotal(TopVoter.Weekly)) {
|
||||
user.setHighestWeeklyTotal(user.getTotal(TopVoter.Weekly));
|
||||
}
|
||||
}
|
||||
user.clearTempCache();
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
}
|
||||
|
||||
try {
|
||||
if (plugin.getSpecialRewardsConfig().isEnableWeeklyAwards()) {
|
||||
HashMap<Integer, String> places = handlePlaces(
|
||||
@@ -337,18 +402,20 @@ public class TopVoterHandler implements Listener {
|
||||
LinkedHashMap<TopVoterPlayer, Integer> clone = (LinkedHashMap<TopVoterPlayer, Integer>) plugin
|
||||
.getTopVoter(TopVoter.Weekly).clone();
|
||||
for (Entry<TopVoterPlayer, Integer> entry : clone.entrySet()) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (plugin.getConfigFile().getTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
if (plugin.getConfigFile().isTopVoterAwardsTies()) {
|
||||
if (entry.getValue().intValue() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
VotingPluginUser user = entry.getKey().getUser();
|
||||
user.dontCache();
|
||||
if (!plugin.getConfigFile().isTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
user.giveWeeklyTopVoterAward(i, places.get(i));
|
||||
plugin.getLogger().info("Giving weekly top voter reward " + i + " to "
|
||||
+ entry.getKey().getPlayerName());
|
||||
}
|
||||
}
|
||||
lastTotal = entry.getValue().intValue();
|
||||
@@ -363,12 +430,23 @@ public class TopVoterHandler implements Listener {
|
||||
resetVoteShopLimit(shopIdent);
|
||||
}
|
||||
}
|
||||
resetTotals(TopVoter.Weekly);
|
||||
|
||||
// give time for other servers to catch up
|
||||
if (!plugin.getTopVoterHandler().bungeeHandleResets()) {
|
||||
plugin.debug("Delaying time change 10 seconds for other servers to catchup");
|
||||
try {
|
||||
Thread.sleep(10000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!bungeeHandleResets()) {
|
||||
resetTotals(TopVoter.Weekly);
|
||||
}
|
||||
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
|
||||
long now = ((System.currentTimeMillis() - startTime) / 1000);
|
||||
plugin.getLogger().info("Finished processing day change, took " + now + " seconds");
|
||||
@@ -395,6 +473,16 @@ public class TopVoterHandler implements Listener {
|
||||
plugin.getUserManager().removeAllKeyValues(topVoter.getColumnName(), DataType.INTEGER);
|
||||
}
|
||||
|
||||
public boolean bungeeHandleResets() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public LinkedHashMap<TopVoterPlayer, Integer> sortByValues(LinkedHashMap<TopVoterPlayer, Integer> map,
|
||||
final boolean order) {
|
||||
|
||||
@@ -405,9 +493,17 @@ public class TopVoterHandler implements Listener {
|
||||
@Override
|
||||
public int compare(Entry<TopVoterPlayer, Integer> o1, Entry<TopVoterPlayer, Integer> o2) {
|
||||
if (order) {
|
||||
return o1.getValue().compareTo(o2.getValue());
|
||||
int result = (o1.getValue()).compareTo(o2.getValue());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return o2.getKey().getLastVoteTime().compareTo(o1.getKey().getLastVoteTime());
|
||||
} else {
|
||||
return o2.getValue().compareTo(o1.getValue());
|
||||
int result = (o2.getValue()).compareTo(o1.getValue());
|
||||
if (result != 0) {
|
||||
return result;
|
||||
}
|
||||
return o1.getKey().getLastVoteTime().compareTo(o2.getKey().getLastVoteTime());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -441,8 +537,19 @@ public class TopVoterHandler implements Listener {
|
||||
file.setup();
|
||||
file.header("Saving top voters for " + top.toString() + ", file also contains other top voter info as backup");
|
||||
for (TopVoter cTop : TopVoter.values()) {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int cTotal = 0;
|
||||
try {
|
||||
ArrayList<Integer> nums = plugin.getUserManager().getNumbersInColumn(cTop.getColumnName());
|
||||
for (Integer num : nums) {
|
||||
cTotal += num.intValue();
|
||||
}
|
||||
topVoters.add("Combined total: " + cTotal);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (plugin.getTopVoter().containsKey(cTop)) {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
|
||||
int count = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(cTop).entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
@@ -466,7 +573,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.AllTime).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
@@ -505,7 +612,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Daily).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
@@ -544,7 +651,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Monthly).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
@@ -664,7 +771,7 @@ public class TopVoterHandler implements Listener {
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : plugin.getTopVoter(TopVoter.Weekly).entrySet()) {
|
||||
String line = plugin.getConfigFile().getFormatCommandVoteTopLine();
|
||||
String line = plugin.getConfigFile().getFormatCommandsVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.UUID;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -19,9 +19,14 @@ public class TopVoterPlayer {
|
||||
@Setter
|
||||
private String playerName;
|
||||
|
||||
public TopVoterPlayer(UUID uuid, String playerName) {
|
||||
@Getter
|
||||
@Setter
|
||||
private Long lastVoteTime;
|
||||
|
||||
public TopVoterPlayer(UUID uuid, String playerName, Long lastVoteTime) {
|
||||
this.uuid = uuid;
|
||||
this.playerName = playerName;
|
||||
this.lastVoteTime = lastVoteTime;
|
||||
}
|
||||
|
||||
public ItemStack getPlayerHead() {
|
||||
@@ -29,6 +34,6 @@ public class TopVoterPlayer {
|
||||
}
|
||||
|
||||
public VotingPluginUser getUser() {
|
||||
return UserManager.getInstance().getVotingPluginUser(getUuid(), getPlayerName());
|
||||
return VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(getUuid(), getPlayerName());
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,8 @@ package com.bencodez.votingplugin.updater;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.bencodez.advancedcore.api.updater.Updater;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -74,7 +73,7 @@ public class CheckUpdate {
|
||||
if (plugin.getConfigFile().isDisableUpdateChecking()) {
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
BukkitScheduler.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
@@ -7,34 +7,36 @@ import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.usercache.UserDataManager;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class UserManager {
|
||||
/** The instance. */
|
||||
static UserManager instance = new UserManager();
|
||||
/** The plugin. */
|
||||
static VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of UserManager.
|
||||
*
|
||||
* @return single instance of UserManager
|
||||
*/
|
||||
public UserManager(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public UserManager() {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
static UserManager instance = new UserManager();
|
||||
|
||||
@Deprecated
|
||||
public static UserManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public UserManager() {
|
||||
}
|
||||
|
||||
public void addCachingKeys() {
|
||||
UserDataManager manager = plugin.getUserManager().getDataManager();
|
||||
manager.addKey(new UserDataKeyString("TopVoterIgnore").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyBoolean("TopVoterIgnore"));
|
||||
manager.addKey(new UserDataKeyInt("VotePartyVotes"));
|
||||
manager.addKey(new UserDataKeyString("LastVotes"));
|
||||
manager.addKey(new UserDataKeyString("CoolDownCheck").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyBoolean("CoolDownCheck"));
|
||||
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyInt("MilestoneCount"));
|
||||
manager.addKey(new UserDataKeyInt("MonthTotal"));
|
||||
@@ -45,9 +47,9 @@ public class UserManager {
|
||||
manager.addKey(new UserDataKeyInt("DayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("BestDayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyString("DayVoteStreakLastUpdate").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyString("Reminded").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyString("DisableBroadcast").setColumnType("VARCHAR(5)"));
|
||||
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("LONGTEXT"));
|
||||
manager.addKey(new UserDataKeyBoolean("Reminded"));
|
||||
manager.addKey(new UserDataKeyBoolean("DisableBroadcast"));
|
||||
manager.addKey(new UserDataKeyInt("WeekVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("BestWeekVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("MonthVoteStreak"));
|
||||
@@ -55,6 +57,8 @@ public class UserManager {
|
||||
manager.addKey(new UserDataKeyInt("HighestMonthlyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("HighestWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastMonthTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastDailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("BestMonthVoteStreak"));
|
||||
if (plugin.getOptions().isPerServerRewards()) {
|
||||
manager.addKey(new UserDataKeyString("OfflineRewards" + plugin.getOptions().getServer())
|
||||
@@ -63,6 +67,7 @@ public class UserManager {
|
||||
if (plugin.getConfigFile().isExtraAllSitesCheck()) {
|
||||
manager.addKey(new UserDataKeyInt(getGottenAllSitesDayPath()));
|
||||
}
|
||||
manager.addKey(new UserDataKeyInt(getGottenAlmostAllSitesDayPath()));
|
||||
}
|
||||
|
||||
public String getGottenAllSitesDayPath() {
|
||||
@@ -72,6 +77,13 @@ public class UserManager {
|
||||
return "AllSitesLast";
|
||||
}
|
||||
|
||||
public String getGottenAlmostAllSitesDayPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "AlmostAllSitesLast_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
}
|
||||
return "AlmostAllSitesLast";
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllUUIDs() {
|
||||
return plugin.getUserManager().getAllUUIDs();
|
||||
}
|
||||
@@ -90,7 +102,7 @@ public class UserManager {
|
||||
}
|
||||
|
||||
public VotingPluginUser getVotingPluginUser(Player player) {
|
||||
return getVotingPluginUser(player.getName());
|
||||
return getVotingPluginUser(player.getUniqueId(), player.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@@ -13,6 +13,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -115,7 +116,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* @param value the value
|
||||
* @return current total points
|
||||
*/
|
||||
public synchronized int addPoints(int value) {
|
||||
public int addPoints(int value) {
|
||||
return addPoints(value, false);
|
||||
}
|
||||
|
||||
public synchronized int addPoints(int value, boolean async) {
|
||||
PlayerReceivePointsEvent event = new PlayerReceivePointsEvent(this, value);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
@@ -123,7 +128,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return getPoints();
|
||||
}
|
||||
int newTotal = getPoints() + event.getPoints();
|
||||
setPoints(newTotal);
|
||||
setPoints(newTotal, async);
|
||||
return newTotal;
|
||||
}
|
||||
|
||||
@@ -170,13 +175,8 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setAddTotals(setTotals);
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
voteEvent.setVotingPluginUser(this);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,19 +191,15 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setAddTotals(setTotals);
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
voteEvent.setVotingPluginUser(this);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void bungeeVotePluginMessaging(String service, long time, BungeeMessageData text, boolean setTotals,
|
||||
boolean wasOnline, boolean broadcast) {
|
||||
boolean wasOnline, boolean broadcast, int num) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
|
||||
plugin.debug("Pluginmessaging vote for " + getPlayerName() + " on " + service);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(service, true), getPlayerName(), service,
|
||||
@@ -216,13 +212,9 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
voteEvent.setBungeeTextTotals(text);
|
||||
voteEvent.setWasOnline(wasOnline);
|
||||
voteEvent.setBroadcast(broadcast);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
voteEvent.setVoteNumber(num);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -284,10 +276,24 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() || now.getYear() != lastVote.getYear()) {
|
||||
return true;
|
||||
LocalDateTime offsetoclockyesterday = plugin.getTimeChecker().getTime().plusDays(-1).withHour(0)
|
||||
.withMinute(0).plusHours((long) voteSite.getTimeOffSet());
|
||||
LocalDateTime offsetoclocktoday = plugin.getTimeChecker().getTime().withHour(0).withMinute(0)
|
||||
.plusHours((long) voteSite.getTimeOffSet());
|
||||
|
||||
if (!now.isBefore(offsetoclocktoday)) {
|
||||
if (!lastVote.isBefore(offsetoclocktoday)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (!lastVote.isBefore(offsetoclockyesterday)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -296,6 +302,13 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
}
|
||||
|
||||
public boolean checkAlmostAllVotes() {
|
||||
if (getSitesNotVotedOn() == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all votes.
|
||||
*
|
||||
@@ -389,7 +402,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
if (str == null || str.isEmpty() || str.equals("null")) {
|
||||
return 0;
|
||||
}
|
||||
return Long.parseLong(str);
|
||||
try {
|
||||
return Long.parseLong(str);
|
||||
} catch (NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getDisableBroadcast() {
|
||||
@@ -400,6 +417,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return getData().getInt(plugin.getVotingPluginUserManager().getGottenAllSitesDayPath(), 0, isWaitForCache());
|
||||
}
|
||||
|
||||
public int getGottenAlmostAllSitesDay() {
|
||||
return getData().getInt(plugin.getVotingPluginUserManager().getGottenAlmostAllSitesDayPath(), 0,
|
||||
isWaitForCache());
|
||||
}
|
||||
|
||||
public HashMap<String, Boolean> getHasGottenMilestone() {
|
||||
HashMap<String, Boolean> hasGottenMilestone = new HashMap<String, Boolean>();
|
||||
ArrayList<String> milestoneList = getUserData().getStringList(getGottenMilestonesPath());
|
||||
@@ -429,6 +451,31 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return getData().getInt("LastMonthTotal", isCacheData(), isWaitForCache());
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Boolean> getCoolDownCheckSiteList() {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = new HashMap<VoteSite, Boolean>();
|
||||
ArrayList<String> coolDownCheck = getData().getStringList(getCoolDownCheckSitePath(), isCacheData(),
|
||||
isWaitForCache());
|
||||
for (String str : coolDownCheck) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1 && plugin.hasVoteSite(data[0])) {
|
||||
VoteSite site = plugin.getVoteSite(data[0], true);
|
||||
if (site != null) {
|
||||
Boolean b = Boolean.valueOf(data[1]);
|
||||
coolDownChecks.put(site, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
return coolDownChecks;
|
||||
}
|
||||
|
||||
public boolean getCoolDownCheckSite(VoteSite site) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
if (coolDownChecks.containsKey(site)) {
|
||||
return coolDownChecks.get(site).booleanValue();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Long> getLastVotes() {
|
||||
HashMap<VoteSite, Long> lastVotes = new HashMap<VoteSite, Long>();
|
||||
ArrayList<String> LastVotesList = getUserData().getStringList("LastVotes");
|
||||
@@ -451,6 +498,16 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return lastVotes;
|
||||
}
|
||||
|
||||
public Long getLastVoteTime() {
|
||||
Long time = Long.valueOf(0);
|
||||
for (Long value : getLastVotes().values()) {
|
||||
if (value.longValue() > time) {
|
||||
time = value;
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last vote times sorted.
|
||||
*
|
||||
@@ -570,22 +627,22 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
public void giveDailyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getDailyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
.withPlaceHolder("topvoter", "Daily").withPlaceHolder("votes", "" + getTotal(TopVoter.Daily))
|
||||
.setOnline(isOnline()).send(this);
|
||||
.withPlaceHolder("topvoter", "Daily").withPlaceHolder("votes", "" + getTotal(TopVoter.Daily))
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
public void giveMonthlyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMonthlyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
.withPlaceHolder("topvoter", "Monthly")
|
||||
.withPlaceHolder("votes", "" + getTotal(TopVoter.Monthly)).setOnline(isOnline()).send(this);
|
||||
.withPlaceHolder("topvoter", "Monthly").withPlaceHolder("votes", "" + getTotal(TopVoter.Monthly))
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
public void giveWeeklyTopVoterAward(int place, String path) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getWeeklyAwardRewardsPath(path)).withPlaceHolder("place", "" + place)
|
||||
.withPlaceHolder("topvoter", "Weekly").withPlaceHolder("votes", "" + getTotal(TopVoter.Weekly))
|
||||
.setOnline(isOnline()).send(this);
|
||||
.withPlaceHolder("topvoter", "Weekly").withPlaceHolder("votes", "" + getTotal(TopVoter.Weekly))
|
||||
.setOnline(isOnline()).send(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -653,17 +710,21 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* Login message.
|
||||
*/
|
||||
public void loginMessage() {
|
||||
if (plugin.getConfigFile().getVoteRemindingRemindOnLogin()) {
|
||||
if (plugin.getConfigFile().isVoteRemindingRemindOnLogin()) {
|
||||
plugin.getVoteReminding().runRemindLogin(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void loginRewards() {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(), "LoginRewards").send(this);
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(), "LoginRewards")) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(), "LoginRewards").send(this);
|
||||
}
|
||||
}
|
||||
|
||||
public void logoutRewards() {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(), "LogoutRewards").send(this);
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(), "LogoutRewards")) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(), "LogoutRewards").send(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -677,7 +738,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
plugin.extraDebug("Checking offline vote site votes for " + player.getName());
|
||||
plugin.extraDebug("Checking offline votes for " + player.getName());
|
||||
|
||||
boolean topVoterIngorePerm = player.hasPermission("VotingPlugin.TopVoter.Ignore");
|
||||
if (isTopVoterIgnore() != topVoterIngorePerm) {
|
||||
@@ -742,7 +803,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
@@ -755,7 +816,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast, boolean bungee) {
|
||||
if (plugin.getConfigFile().getFormatBroadcastWhenOnline() && plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
if (plugin.getConfigFile().isFormatBroadcastWhenOnline() && plugin.getConfigFile().isBroadcastVotesEnabled()
|
||||
&& broadcast && !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
voteSite.broadcastVote(this);
|
||||
}
|
||||
@@ -776,6 +837,14 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removePoints(int points, boolean async) {
|
||||
if (getPoints() >= points) {
|
||||
setPoints(getPoints() - points, async);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetTotals(TopVoter topVoter) {
|
||||
setTotal(topVoter, 0);
|
||||
}
|
||||
@@ -831,6 +900,10 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
getData().setInt(plugin.getVotingPluginUserManager().getGottenAllSitesDayPath(), day);
|
||||
}
|
||||
|
||||
public void setGottenAlmostAllSitesDay(int day) {
|
||||
getData().setInt(plugin.getVotingPluginUserManager().getGottenAlmostAllSitesDayPath(), day);
|
||||
}
|
||||
|
||||
public void setHasGotteMilestone(int votesRequired, boolean b) {
|
||||
HashMap<String, Boolean> hasGottenMilestone = getHasGottenMilestone();
|
||||
hasGottenMilestone.put("" + votesRequired, b);
|
||||
@@ -848,7 +921,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
|
||||
public String getGottenMilestonesPath() {
|
||||
if (plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
return plugin.getOptions().getServer() + "_" + "GottenMilestones";
|
||||
return plugin.getBungeeSettings().getServerNameStorage() + "_" + "GottenMilestones";
|
||||
}
|
||||
return "GottenMileStones";
|
||||
}
|
||||
@@ -878,18 +951,41 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
getUserData().setStringList("LastVotes", data);
|
||||
}
|
||||
|
||||
public void setCoolDownCheckSite(HashMap<VoteSite, Boolean> coolDownChecks) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<VoteSite, Boolean> entry : coolDownChecks.entrySet()) {
|
||||
String str = entry.getKey().getKey() + "//" + entry.getValue().toString();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList(getCoolDownCheckSitePath(), data);
|
||||
}
|
||||
|
||||
public void setCoolDownCheckSite(VoteSite site, boolean value) {
|
||||
HashMap<VoteSite, Boolean> coolDownChecks = getCoolDownCheckSiteList();
|
||||
coolDownChecks.put(site, Boolean.valueOf(value));
|
||||
setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
|
||||
public void setMilestoneCount(int value) {
|
||||
getData().setInt("MilestoneCount", value);
|
||||
}
|
||||
|
||||
public String getCoolDownCheckPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServer();
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
} else {
|
||||
return "CoolDownCheck";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCoolDownCheckSitePath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage() + "_Sites";
|
||||
} else {
|
||||
return "CoolDownCheck" + "_Sites";
|
||||
}
|
||||
}
|
||||
|
||||
public void setCoolDownCheck(boolean coolDownCheck) {
|
||||
getData().setBoolean(getCoolDownCheckPath(), coolDownCheck);
|
||||
}
|
||||
@@ -920,7 +1016,11 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
* @param value the new points
|
||||
*/
|
||||
public void setPoints(int value) {
|
||||
getUserData().setInt(getPointsPath(), value, !plugin.getBungeeSettings().isUseBungeecoord());
|
||||
getUserData().setInt(getPointsPath(), value, false);
|
||||
}
|
||||
|
||||
public void setPoints(int value, boolean async) {
|
||||
getUserData().setInt(getPointsPath(), value, false, async);
|
||||
}
|
||||
|
||||
public void setPrimaryAccount(java.util.UUID uuid) {
|
||||
@@ -931,6 +1031,40 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
}
|
||||
|
||||
public int getNextAvailableMileStone() {
|
||||
Set<String> mVotes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
int mileStoneCount = getMilestoneCount();
|
||||
HashMap<String, Boolean> gottenMileStones = getHasGottenMilestone();
|
||||
for (String vote : mVotes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
final int num = Integer.parseInt(vote);
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(num)) {
|
||||
if (gottenMileStones.containsKey("" + num)) {
|
||||
if (!gottenMileStones.get("" + num).booleanValue()) {
|
||||
nums.add(Integer.valueOf(num));
|
||||
}
|
||||
} else {
|
||||
nums.add(Integer.valueOf(num));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int lowestNum = -1;
|
||||
|
||||
for (Integer num : nums) {
|
||||
if (mileStoneCount < num.intValue()) {
|
||||
if (lowestNum == -1 || num.intValue() < lowestNum) {
|
||||
lowestNum = num.intValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return lowestNum;
|
||||
|
||||
}
|
||||
|
||||
public void setReminded(boolean reminded) {
|
||||
getUserData().setString("Reminded", "" + reminded);
|
||||
}
|
||||
@@ -1075,14 +1209,16 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
info += " ";
|
||||
}
|
||||
|
||||
if (diffSeconds == 1) {
|
||||
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
plugin.getConfigFile().getFormatTimeFormatsSecond()), "amount", "" + diffSeconds);
|
||||
} else {
|
||||
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
plugin.getConfigFile().getFormatTimeFormatsSeconds()), "amount", "" + diffSeconds);
|
||||
if (plugin.getConfigFile().isFormatCommandsVoteLastIncludeSeconds()) {
|
||||
if (diffSeconds == 1) {
|
||||
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
plugin.getConfigFile().getFormatTimeFormatsSecond()), "amount", "" + diffSeconds);
|
||||
} else {
|
||||
info += StringParser.getInstance().replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getConfigFile().getFormatCommandsVoteLastTimeFormat(), "TimeType",
|
||||
plugin.getConfigFile().getFormatTimeFormatsSeconds()), "amount", "" + diffSeconds);
|
||||
}
|
||||
}
|
||||
|
||||
info = StringParser.getInstance()
|
||||
@@ -1119,9 +1255,12 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public String voteCommandNextInfo(VoteSite voteSite) {
|
||||
return voteCommandNextInfo(voteSite, getTime(voteSite));
|
||||
}
|
||||
|
||||
public String voteCommandNextInfo(VoteSite voteSite, long time) {
|
||||
String info = new String();
|
||||
|
||||
long time = getTime(voteSite);
|
||||
LocalDateTime now = plugin.getTimeChecker().getTime();
|
||||
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault())
|
||||
@@ -1282,7 +1421,7 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
}
|
||||
|
||||
public TopVoterPlayer getTopVoterPlayer() {
|
||||
return new TopVoterPlayer(UUID.fromString(getUUID()), getPlayerName());
|
||||
return new TopVoterPlayer(UUID.fromString(getUUID()), getPlayerName(), getLastOnline());
|
||||
}
|
||||
|
||||
public long getNextTimeAllSitesAvailable() {
|
||||
@@ -1297,4 +1436,52 @@ public class VotingPluginUser extends com.bencodez.advancedcore.api.user.Advance
|
||||
return longest;
|
||||
}
|
||||
|
||||
public long getNextTimeFirstSiteAvailable() {
|
||||
long shortest = 0;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!canVoteSite(site)) {
|
||||
long seconds = voteNextDurationTime(site);
|
||||
if (shortest == 0 || seconds < shortest) {
|
||||
shortest = seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return shortest;
|
||||
}
|
||||
|
||||
public void resetLastVoted() {
|
||||
HashMap<VoteSite, Long> map = getLastVotes();
|
||||
for (Entry<VoteSite, Long> e : map.entrySet()) {
|
||||
e.setValue(0l);
|
||||
}
|
||||
setLastVotes(map);
|
||||
}
|
||||
|
||||
public void resetLastVoted(VoteSite site) {
|
||||
HashMap<VoteSite, Long> map = getLastVotes();
|
||||
map.put(site, 0l);
|
||||
setLastVotes(map);
|
||||
}
|
||||
|
||||
public int getNumberOfOfflineVotes(VoteSite site) {
|
||||
ArrayList<String> offlineVotes = getOfflineVotes();
|
||||
int num = 0;
|
||||
for (String str : offlineVotes) {
|
||||
if (str.equals(site.getKey())) {
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public long getLastVoteTimer(VoteSite voteSite) {
|
||||
HashMap<VoteSite, Long> times = getLastVotes();
|
||||
if (times.containsKey(voteSite)) {
|
||||
return times.get(voteSite).longValue();
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,9 @@ package com.bencodez.votingplugin.voteparty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -19,9 +21,9 @@ import com.bencodez.advancedcore.api.time.events.DayChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.MonthChangeEvent;
|
||||
import com.bencodez.advancedcore.api.time.events.WeekChangeEvent;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.DataType;
|
||||
import com.bencodez.advancedcore.scheduler.BukkitScheduler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.VotePartyEvent;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -59,30 +61,41 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void check(boolean forceBungee) {
|
||||
if (getTotalVotes() >= getVotesRequired() && ((plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()
|
||||
&& plugin.getServerData().isLastVotePartySameDay())
|
||||
|| !plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay())) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
}
|
||||
public void check(VotingPluginUser user, boolean forceBungee) {
|
||||
if (getTotalVotes() < getVotesRequired()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()
|
||||
&& plugin.getServerData().isLastVotePartySameDay()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerWeek()
|
||||
&& plugin.getServerData().isLastVotePartySameWeek()) {
|
||||
return;
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetCount()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
}
|
||||
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
giveRewards(forceBungee);
|
||||
giveRewards(user, forceBungee);
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired() > 0) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
|
||||
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRquired());
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired() > 0) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(plugin.getServerData().getVotePartyExtraRequired()
|
||||
+ plugin.getSpecialRewardsConfig().getVotePartyIncreaseVotesRequired());
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyOnlyOncePerDay()) {
|
||||
plugin.getServerData().updateLastVoteParty();
|
||||
}
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerDay()) {
|
||||
plugin.getServerData().updateLastVoteParty();
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyOnlyOncePerWeek()) {
|
||||
plugin.getServerData().updateLastVotePartyWeek();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -93,7 +106,7 @@ public class VoteParty implements Listener {
|
||||
* @param sender the sender
|
||||
*/
|
||||
public void commandVoteParty(CommandSender sender) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
ArrayList<String> msg = plugin.getConfigFile().getFormatCommandsVoteParty();
|
||||
int votesRequired = getVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
@@ -103,7 +116,13 @@ public class VoteParty implements Listener {
|
||||
placeholders.put("neededvotes", "" + neededVotes);
|
||||
placeholders.put("votes", "" + votes);
|
||||
msg = ArrayUtils.getInstance().colorize(ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders));
|
||||
sender.sendMessage(ArrayUtils.getInstance().convert(msg));
|
||||
if (sender instanceof Player) {
|
||||
Player p = (Player) sender;
|
||||
sender.sendMessage(
|
||||
ArrayUtils.getInstance().convert(ArrayUtils.getInstance().replacePlaceHolders(msg, p)));
|
||||
} else {
|
||||
sender.sendMessage(ArrayUtils.getInstance().convert(msg));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(StringParser.getInstance().colorize("&cVoteParty not enabled"));
|
||||
}
|
||||
@@ -164,42 +183,81 @@ public class VoteParty implements Listener {
|
||||
|
||||
public void giveReward(VotingPluginUser user, boolean online, boolean useBungee) {
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVotePartyRewardsPath())
|
||||
.setOnline(online)
|
||||
.withPlaceHolder("VotesRequired",
|
||||
"" + plugin.getSpecialRewardsConfig().getVotePartyVotesRequired())
|
||||
.setServer(useBungee).send(user);
|
||||
plugin.getSpecialRewardsConfig().getVotePartyRewardsPath()).setOnline(online)
|
||||
.withPlaceHolder("VotesRequired", "" + plugin.getSpecialRewardsConfig().getVotePartyVotesRequired())
|
||||
.setServer(useBungee).send(user);
|
||||
}
|
||||
|
||||
public void giveRewards(boolean forceBungee) {
|
||||
public String getRandomPlayerName() {
|
||||
ArrayList<String> allPlayers = new ArrayList<String>();
|
||||
for (Player players : Bukkit.getOnlinePlayers()) {
|
||||
allPlayers.add(players.getName());
|
||||
}
|
||||
if (allPlayers.size() == 0) {
|
||||
return "No Player";
|
||||
}
|
||||
int random = new Random().nextInt(allPlayers.size());
|
||||
return allPlayers.get(random);
|
||||
}
|
||||
|
||||
public void giveRewards(VotingPluginUser orgUser, boolean forceBungee) {
|
||||
MiscUtils.getInstance().broadcast(plugin.getSpecialRewardsConfig().getVotePartyBroadcast());
|
||||
|
||||
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyCommands()) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
String player = getRandomPlayerName();
|
||||
for (final String cmd : plugin.getSpecialRewardsConfig().getVotePartyGlobalCommands()) {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
|
||||
StringParser.getInstance().replacePlaceHolder(cmd, "randomonlineplayer", player));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyGiveAllPlayers()) {
|
||||
final ArrayList<String> list = plugin.getSpecialRewardsConfig().getVotePartyGlobalRandomCommand();
|
||||
if (list.size() > 0) {
|
||||
BukkitScheduler.runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
|
||||
StringParser.getInstance().replacePlaceHolder(
|
||||
list.get(ThreadLocalRandom.current().nextInt(list.size())), "randomonlineplayer",
|
||||
player));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyGiveAllPlayers()) {
|
||||
plugin.debug("Trying to give all players vote party");
|
||||
ArrayList<String> alreadyGotten = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
user.dontCache();
|
||||
VotingPluginUser user;
|
||||
if (orgUser != null && orgUser.getJavaUUID().equals(p.getUniqueId())) {
|
||||
user = orgUser;
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
user.dontCache();
|
||||
}
|
||||
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly() || user.isOnline()) {
|
||||
giveReward(user, forceBungee);
|
||||
}
|
||||
alreadyGotten.add(p.getUniqueId().toString());
|
||||
}
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
for (String uuid : plugin.getVotingPluginUserManager().getAllUUIDs()) {
|
||||
if (!alreadyGotten.contains(uuid)) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
VotingPluginUser user;
|
||||
if (orgUser != null && orgUser.getJavaUUID().toString().equals(uuid)) {
|
||||
user = orgUser;
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
}
|
||||
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly() || user.isOnline()) {
|
||||
giveReward(user, forceBungee);
|
||||
}
|
||||
@@ -209,8 +267,13 @@ public class VoteParty implements Listener {
|
||||
plugin.debug("Trying to give all voted players vote party");
|
||||
plugin.debug(ArrayUtils.getInstance().makeStringList(getVotedUsers()));
|
||||
for (String uuid : getVotedUsers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
VotingPluginUser user;
|
||||
if (orgUser != null && orgUser.getJavaUUID().toString().equals(uuid)) {
|
||||
user = orgUser;
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.dontCache();
|
||||
}
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyGiveOnlinePlayersOnly() || user.isOnline()) {
|
||||
giveReward(user, forceBungee);
|
||||
}
|
||||
@@ -222,14 +285,14 @@ public class VoteParty implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyResetEachDay()) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetEachDay()) {
|
||||
reset(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyResetMontly()) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetMonthly()) {
|
||||
reset(true);
|
||||
}
|
||||
|
||||
@@ -240,7 +303,7 @@ public class VoteParty implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyResetWeekly()) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyResetWeekly()) {
|
||||
reset(true);
|
||||
}
|
||||
}
|
||||
@@ -283,12 +346,12 @@ public class VoteParty implements Listener {
|
||||
}
|
||||
|
||||
public synchronized void vote(VotingPluginUser user, boolean realVote, boolean forceBungee) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyCountFakeVotes() || realVote) {
|
||||
if (plugin.getSpecialRewardsConfig().getVotePartyCountOfflineVotes() || user.isOnline()) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyCountFakeVotes() || realVote) {
|
||||
if (plugin.getSpecialRewardsConfig().isVotePartyCountOfflineVotes() || user.isOnline()) {
|
||||
addTotal(user);
|
||||
addVotePlayer(user);
|
||||
check(forceBungee);
|
||||
check(user, forceBungee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
package com.bencodez.votingplugin.votereminding;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -24,7 +24,7 @@ public class VoteReminding {
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private Timer timer;
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
@Getter
|
||||
private ConcurrentHashMap<UUID, Boolean> remindersEnabled = new ConcurrentHashMap<UUID, Boolean>();
|
||||
@@ -41,7 +41,7 @@ public class VoteReminding {
|
||||
public void checkRemind(VotingPluginUser user) {
|
||||
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
|
||||
if (shouldRemind(user)) {
|
||||
if (!plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
|
||||
if (!plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
|
||||
runRemind(user);
|
||||
} else if (!user.isReminded()) {
|
||||
runRemind(user);
|
||||
@@ -53,7 +53,8 @@ public class VoteReminding {
|
||||
|
||||
private void giveReward(VotingPluginUser user) {
|
||||
new RewardBuilder(plugin.getConfigFile().getData(), plugin.getConfigFile().getVoteRemindingRewardsPath())
|
||||
.withPlaceHolder("sitesavailable", "" + user.getSitesNotVotedOn()).setGiveOffline(false).send(user);
|
||||
.withPlaceHolder("sitesavailable", "" + user.getSitesNotVotedOn()).setGiveOffline(false)
|
||||
.disableDefaultWorlds().send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,24 +62,26 @@ public class VoteReminding {
|
||||
*/
|
||||
public void loadRemindChecking() {
|
||||
if (timer != null) {
|
||||
timer.cancel();
|
||||
timer.shutdownNow();
|
||||
}
|
||||
if (plugin.getConfigFile().getVoteRemindingRemindDelay() > 0) {
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
checkRemind(user);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
if (!plugin.getOptions().isTreatVanishAsOffline() || !user.isVanished()) {
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
timer.shutdown();
|
||||
}
|
||||
}
|
||||
}, 1000 * 30, plugin.getConfigFile().getVoteRemindingRemindDelay() * 1000 * 60);
|
||||
}, 30, plugin.getConfigFile().getVoteRemindingRemindDelay() * 60, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,12 +91,12 @@ public class VoteReminding {
|
||||
* @param user the user
|
||||
*/
|
||||
public void runRemind(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().getVoteRemindingEnabled()) {
|
||||
if (plugin.getConfigFile().isVoteRemindingEnabled()) {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
giveReward(user);
|
||||
if (user.getData().hasData() && plugin.getConfigFile().getVoteRemindingRemindOnlyOnce()) {
|
||||
if (user.getData().hasData() && plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
|
||||
user.setReminded(true);
|
||||
}
|
||||
|
||||
@@ -104,6 +107,7 @@ public class VoteReminding {
|
||||
public boolean shouldRemind(VotingPluginUser user) {
|
||||
if (remindersEnabled.containsKey(user.getJavaUUID())) {
|
||||
if (!remindersEnabled.get(user.getJavaUUID()).booleanValue()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -115,24 +119,30 @@ public class VoteReminding {
|
||||
return user.canVoteAny();
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getUUID() + " no need to remind because plaeyr has VotingPlugin.NoRemind");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void runRemindLogin(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().getVoteRemindingEnabled()) {
|
||||
if (plugin.getConfigFile().isVoteRemindingEnabled()) {
|
||||
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
if ((!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || shouldRemind(user))) {
|
||||
if ((!plugin.getVotingPluginUserManager().getAllUUIDs().contains(user.getUUID())
|
||||
|| shouldRemind(user))) {
|
||||
giveReward(user);
|
||||
if (user.getData().hasData()) {
|
||||
user.setReminded(true);
|
||||
}
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
} else {
|
||||
plugin.debug("Not reminding for " + user.getUUID());
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getUUID() + " has no permission for reminders");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user