Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f898d46c95
|
||
|
|
05c0c298ec
|
||
|
|
b6d0d224d8 | ||
|
|
26afe69a95 | ||
|
|
d38e70e012 | ||
|
|
12b77c50ce | ||
|
|
0fbcd8ca11 | ||
|
|
2e68f4e058 | ||
|
|
8b538ad86e | ||
|
|
1d4973f550 | ||
|
|
b13e4f9635 | ||
|
|
b075866f83 | ||
|
|
68896b32c3 | ||
|
|
8e81dc99c5 | ||
|
|
1b202f246f | ||
|
|
79bea20039 | ||
|
|
63905004b6 | ||
|
|
f326e2cbbb | ||
|
|
9f6edca531 | ||
|
|
3e277a4a76 | ||
|
|
3b33e5e4a7 | ||
|
|
b5f35038fa | ||
|
|
b937d30213 | ||
|
|
d43cf53276 | ||
|
|
6a7b677322 | ||
|
|
b309537f97 | ||
|
|
7e34dd89b8 | ||
|
|
5dcc0a1b33 | ||
|
|
36f8b3fbe8 | ||
|
|
df298fd66c | ||
|
|
c93aff6c20 | ||
|
|
b8acfe20ec | ||
|
|
110aaf096e | ||
|
|
171975c3d3 | ||
|
|
ac96d277c5 | ||
|
|
b1ad952950 | ||
|
|
ca30bcb183 | ||
|
|
eecd975731 | ||
|
|
aa55b10e50 | ||
|
|
64f59f8195 | ||
|
|
a51e041430 | ||
|
|
b39f768a46 | ||
|
|
e98bc49add | ||
|
|
8b2209aa59 | ||
|
|
58a0e85d00 | ||
|
|
3febfa4056 | ||
|
|
e5668c862a | ||
|
|
fd4c6a3954 | ||
|
|
9e9472680a | ||
|
|
cbecd7be30 | ||
|
|
fcb1af77cf | ||
|
|
5d9b5b7b6c | ||
|
|
d26d61a6f0 | ||
|
|
3f885aa358 | ||
|
|
d088f2e91a | ||
|
|
a536c53dd9 | ||
|
|
5d2d6f0763 | ||
|
|
0848ed83c2 | ||
|
|
1771fe0889 | ||
|
|
ce5b197e8b | ||
|
|
15489d9c64 | ||
|
|
758632b5a5 | ||
|
|
3dc45b6a63 | ||
|
|
26c9ad98bc | ||
|
|
ee2531af1e | ||
|
|
461e5f8413 | ||
|
|
1c5acbd1a1 | ||
|
|
e855c01854 | ||
|
|
aeec7d9d17 | ||
|
|
4861c041e4 | ||
|
|
d1c6752240 | ||
|
|
caa7058363 | ||
|
|
b67f6a509c | ||
|
|
0edc09dc80 | ||
|
|
19e597e094 | ||
|
|
bfc838bfaa | ||
|
|
9cda17e89e | ||
|
|
54a573a445 | ||
|
|
5432b2a0d3 | ||
|
|
13d3a614ed | ||
|
|
f9641e158d | ||
|
|
a0c1f64aac | ||
|
|
1f88cb0261 | ||
|
|
71ccf6a7b0 | ||
|
|
47a42d2bc8 | ||
|
|
ac41787c1e | ||
|
|
ed4e3968da | ||
|
|
09da81cc4e | ||
|
|
fd35c43c16 | ||
|
|
8060f594c3 | ||
|
|
39aa7062a5 | ||
|
|
7ff7fbb7cb | ||
|
|
231817314b | ||
|
|
a20f10d978 | ||
|
|
997beaae28 | ||
|
|
9acc5861b7 | ||
|
|
f299847d46 | ||
|
|
87ff48366c | ||
|
|
3dde76dcde | ||
|
|
237713a799 | ||
|
|
23141d4ec1 | ||
|
|
2cfbaf4de8 | ||
|
|
c31b83fcd3 | ||
|
|
4cfd887c33 | ||
|
|
f04930e437 | ||
|
|
c45e8356bb | ||
|
|
2f78b7784a | ||
|
|
911642f57f | ||
|
|
5e63c04f6c | ||
|
|
e368f30dd9 | ||
|
|
5d5e8b0d55 | ||
|
|
16e52a4fd7 | ||
|
|
331c8fedf5 | ||
|
|
c085d6823e | ||
|
|
47680b2646 | ||
|
|
60ed0ce73d | ||
|
|
e5ae3184e0 | ||
|
|
dca9c6fe18 | ||
|
|
083e90706f | ||
|
|
fed96bcda1 | ||
|
|
5bad8c8f98 | ||
|
|
e31326395c | ||
|
|
f5b2d27b9e | ||
|
|
42626e3789 | ||
|
|
b35ff9454d | ||
|
|
9ee1547691 | ||
|
|
cb1599fe56 | ||
|
|
59a206617c | ||
|
|
699d74ca3f | ||
|
|
ad6d411e64 | ||
|
|
1b430dc4b8 | ||
|
|
526dcc830e | ||
|
|
75aaae7016 | ||
|
|
89d3372701 | ||
|
|
209f1dbc25 | ||
|
|
bb67de8d0e | ||
|
|
b4d57c7eae | ||
|
|
2ac6609d8e | ||
|
|
9eec6525c0 | ||
|
|
858b8b7b3c | ||
|
|
0aaef50a82 | ||
|
|
365f06d2ed | ||
|
|
a1b7370da0 | ||
|
|
2f52576bc4 | ||
|
|
bac19aecb9 | ||
|
|
3ad6ce247d | ||
|
|
bb78792e27 | ||
|
|
726b116c20 | ||
|
|
f731f82b01 | ||
|
|
939c431bcf | ||
|
|
87ed9dfe39 | ||
|
|
eceacf607f | ||
|
|
8d6db5b94f | ||
|
|
700300a293 | ||
|
|
5e5e208de0 | ||
|
|
b48662acfe | ||
|
|
0aed3068db | ||
|
|
25a3ff904d | ||
|
|
bb7adc409a | ||
|
|
1b28966798 | ||
|
|
f5d34ad84a | ||
|
|
abd86834a6 | ||
|
|
c6647d7cc3 | ||
|
|
a3851f9bf2 | ||
|
|
a951aae0de | ||
|
|
826fc95131 | ||
|
|
dea13f6ff1 | ||
|
|
bab55de93b | ||
|
|
1c112688b1 | ||
|
|
bc0e82f68f | ||
|
|
a82397a67f | ||
|
|
b1ffce516c | ||
|
|
f48a008040 | ||
|
|
90c8255894 | ||
|
|
4001e865f5 | ||
|
|
77b7659cb6 | ||
|
|
bc073857f6 | ||
|
|
9c2a41c9b5 | ||
|
|
972f5350a1 | ||
|
|
66df9d85da | ||
|
|
4046dd9d7f | ||
|
|
d89aa6ccb2 | ||
|
|
813ffed723 | ||
|
|
c0bc1b2730 | ||
|
|
1217e63583 | ||
|
|
cd6ed92e4f | ||
|
|
07c9eda769 | ||
|
|
ef0f73ba32 | ||
|
|
10b0fd3b11 | ||
|
|
a4aa209aa7 | ||
|
|
70af742083 | ||
|
|
0463700037 | ||
|
|
69d9c09b06 | ||
|
|
4455cc96b9 | ||
|
|
0ee7c1f2e8 | ||
|
|
4b3cc8c8e0 | ||
|
|
c2fe26aaea | ||
|
|
2aa84c90e8 | ||
|
|
c8cace388e | ||
|
|
1da028476f | ||
|
|
c28bddd0ba | ||
|
|
1afd8253a5 | ||
|
|
a3a1b4604f | ||
|
|
3bd41af200 | ||
|
|
0042045d9b | ||
|
|
76d7579c7d | ||
|
|
f591b863f1 | ||
|
|
b43c4b89a8 | ||
|
|
bc49aae401 | ||
|
|
f9d7f5a136 | ||
|
|
338853a29f | ||
|
|
7d0722d5c4 | ||
|
|
86e6bca31d | ||
|
|
8488233be1 | ||
|
|
ba5f8dfa6d | ||
|
|
dc865f1d20 | ||
|
|
5dedb644b2 | ||
|
|
c041c7c33a | ||
|
|
bbc0c4a88e | ||
|
|
4d200f6675 | ||
|
|
ad7970c99d | ||
|
|
2ab6ff5105 | ||
|
|
0470993b81 | ||
|
|
7de3dff221 | ||
|
|
c17f6facbb | ||
|
|
d0e2a7987b | ||
|
|
c9d3b1655d | ||
|
|
348ad9d3d5 | ||
|
|
f90b87fa5a | ||
|
|
5b19d3397a | ||
|
|
dad0f88865 | ||
|
|
3e862efff2 | ||
|
|
52ca5467f7 | ||
|
|
61657dc670 | ||
|
|
4bac98c015 | ||
|
|
1215d224b4 | ||
|
|
6dde613558 | ||
|
|
99e34b5cd4 | ||
|
|
e049329f41 | ||
|
|
8fe4661fe1 | ||
|
|
af8cfc94a9 | ||
|
|
d98a9a9152 | ||
|
|
749ef7fa45 | ||
|
|
3f2a2fa33a | ||
|
|
2cb48d655a | ||
|
|
573315dd18 | ||
|
|
63091ad815 | ||
|
|
9e88f57bfb | ||
|
|
86d38d6ac9 | ||
|
|
e752d111a0 | ||
|
|
0a09d13bb3 | ||
|
|
08a6d91996 | ||
|
|
1082c47297 | ||
|
|
531812d800 | ||
|
|
903a7232de | ||
|
|
ed1a0c0708 | ||
|
|
15f12220a3 | ||
|
|
c24871c34d | ||
|
|
65e180ccf8 | ||
|
|
4cc523429d | ||
|
|
01b5e5f8a1 | ||
|
|
944458d858 | ||
|
|
9beaa4e440 | ||
|
|
3c78db5fe6 | ||
|
|
9400a4fa08 | ||
|
|
b4519bc6e7 | ||
|
|
f698481b97 | ||
|
|
927641f005 | ||
|
|
d85ad022fb | ||
|
|
e39fcd78ca | ||
|
|
6800ccd4a7 | ||
|
|
3065e57b44 | ||
|
|
fdcf092c7f | ||
|
|
7b9e734ccd | ||
|
|
5718e3261a | ||
|
|
e391ba88e4 | ||
|
|
b7942e763c | ||
|
|
cb039e052c | ||
|
|
07a4350f10 | ||
|
|
44130f6a52 | ||
|
|
6caf9afc1d | ||
|
|
7428581b4c | ||
|
|
a2dc362456 | ||
|
|
8d8e904a5f | ||
|
|
4485006fbb | ||
|
|
6fc3cb9096 | ||
|
|
cdf14896f0 | ||
|
|
bdd73b2873 | ||
|
|
e8781a0abe | ||
|
|
0d26b59777 | ||
|
|
fa0535cf32 | ||
|
|
2353ec321c | ||
|
|
cb4646f67d | ||
|
|
7a500f9cca | ||
|
|
b583b71721 | ||
|
|
c2fa7c4f90 | ||
|
|
2b82b8db82 | ||
|
|
c130004201 | ||
|
|
4829c772cb | ||
|
|
e8bf487d74 | ||
|
|
f5e9a450f9 | ||
|
|
ebb44330fd | ||
|
|
616a102d73 | ||
|
|
a5b741d92b | ||
|
|
e7f5000a56 | ||
|
|
0615f61f0b | ||
|
|
2ae913c743 | ||
|
|
4ec5bfef4f | ||
|
|
33e173448a | ||
|
|
20671c4504 | ||
|
|
16705c5707 | ||
|
|
549309ee8c | ||
|
|
2bb3fac778 | ||
|
|
1e84f3cbc6 | ||
|
|
98a0c9944e | ||
|
|
8016240445 | ||
|
|
4dc5e5c3b6 | ||
|
|
5a4f361d3f | ||
|
|
2542cc87d3 | ||
|
|
b13afd53c1 | ||
|
|
c1f9ba24a7 | ||
|
|
1c20ac60e5 | ||
|
|
98a4d7062b | ||
|
|
b08edc007a | ||
|
|
054c8d0361 | ||
|
|
c78141357e | ||
|
|
5efd5646f2 | ||
|
|
e1c1d7b530 | ||
|
|
f436b03584 | ||
|
|
e34f5f077f | ||
|
|
e1a059b766 | ||
|
|
9cb7158d84 | ||
|
|
35ce6cc68e | ||
|
|
a7832692b7 | ||
|
|
8fd7a30720 | ||
|
|
fdd8f28a29 | ||
|
|
f9d41d49b2 | ||
|
|
456e43b37a | ||
|
|
2cbf12cf1e | ||
|
|
aeac53a5a7 | ||
|
|
2ea402b67c | ||
|
|
ba1b8cafcd | ||
|
|
5984ee15b5 | ||
|
|
a13b5ee7a2 | ||
|
|
56e6a659fe | ||
|
|
56f5611a96 | ||
|
|
a828450846 | ||
|
|
3f8495d0f7 | ||
|
|
bbb2df5f16 | ||
|
|
40eb9b0afc | ||
|
|
545eb0cd69 | ||
|
|
050bfb3055 | ||
|
|
3ce40de5f6 | ||
|
|
095cd2a422 | ||
|
|
5e7cc2b7ad | ||
|
|
38c61ce669 | ||
|
|
9de71167ec | ||
|
|
e8b9c9fbc2 | ||
|
|
60ac9fcd46 | ||
|
|
a0d334c88b | ||
|
|
b90b4964e4 | ||
|
|
a0fbdaa2a0 | ||
|
|
17066cb679 | ||
|
|
9eb1ba82af | ||
|
|
06b12c9599 | ||
|
|
fe277d8bfd | ||
|
|
86cba23568 | ||
|
|
5a6140020f | ||
|
|
cb203edecf | ||
|
|
5510e3bb98 | ||
|
|
470c52e6e3 | ||
|
|
03e4c2165e | ||
|
|
45d617106b | ||
|
|
58869742bc | ||
|
|
a8841ca732 | ||
|
|
96ef82aef0 | ||
|
|
5a33b5b892 | ||
|
|
ed2fb77a7b | ||
|
|
8a1c820e42 | ||
|
|
43c5419453 | ||
|
|
4f2caf67d0 | ||
|
|
8b17e43ce0 | ||
|
|
05db0b189b | ||
|
|
93f91923bb | ||
|
|
6dca3ad152 | ||
|
|
637db5afdb | ||
|
|
029fa00e3a | ||
|
|
e1bb95c482 | ||
|
|
667b1b082d | ||
|
|
2097fc4b86 | ||
|
|
49d20c0bc8 | ||
|
|
fe2ac4f02c | ||
|
|
4859c37ef8 | ||
|
|
c818007426 | ||
|
|
c86f07aeb6 | ||
|
|
0a74e338c2 | ||
|
|
d1dc8b392f | ||
|
|
bd5234b479 | ||
|
|
cca9e3dc58 | ||
|
|
c3df294ce6 | ||
|
|
d81a113240 | ||
|
|
f2feafa45a | ||
|
|
f63a743c2c | ||
|
|
2d9c6482fc | ||
|
|
448a9eeea9 | ||
|
|
c8e32696af | ||
|
|
36eb6eafb3 | ||
|
|
040fafe33a | ||
|
|
040e467761 | ||
|
|
e0d28be260 | ||
|
|
1ef2440bf9 | ||
|
|
2a5d5d3bea | ||
|
|
419153d654 | ||
|
|
ed8c504c27 | ||
|
|
2c29f11a8b | ||
|
|
c442cd1deb | ||
|
|
770e3e866c | ||
|
|
4014046444 | ||
|
|
6f378297dd |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Bug report for VotingPlugin
|
||||
title: ''
|
||||
labels: Possible Bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots/Configs**
|
||||
If applicable, add screenshots to help explain your problem and/or configs relating to the issue.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea
|
||||
title: ''
|
||||
labels: Possible Feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
name: Question/Concerns
|
||||
about: Ask about a question or a concern about the plugin
|
||||
title: ''
|
||||
labels: Question/Concern
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version
|
||||
|
||||
**Relevant information**
|
||||
Configs that relate to the issue in a pastebin.
|
||||
|
||||
**Context**
|
||||
Context about the question/concern
|
||||
@@ -1,11 +0,0 @@
|
||||
# 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,24 +0,0 @@
|
||||
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'
|
||||
@@ -1,27 +0,0 @@
|
||||
# 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'
|
||||
@@ -0,0 +1,5 @@
|
||||
.gradle/
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
build/
|
||||
@@ -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
|
||||
|
||||
### Maven:
|
||||
|
||||
<repository>
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
/bin/
|
||||
/target/
|
||||
/doc/
|
||||
/.idea/
|
||||
/*.iml
|
||||
/.settings/
|
||||
/.classpath
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>VotingPlugin</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,133 +0,0 @@
|
||||
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
|
||||
# Default: false
|
||||
Enabled: false
|
||||
|
||||
# Display name of voting site
|
||||
Name: 'ExampleVoteSite'
|
||||
|
||||
# Priority of this site
|
||||
# Used for sorted list
|
||||
# High prority, higher on the list
|
||||
Priority: 5
|
||||
|
||||
# If true, voteside will be hidden from some GUI's, similar to being disabled
|
||||
Hidden: false
|
||||
|
||||
# The serviceName from the vote, has to be correct to work correctly
|
||||
# Gotten from voting on the site (will be in console/log)
|
||||
# Usually is the main part of the url(e.g. PlanetMinecraft.com), but not always
|
||||
# See console when you vote (it will notify you if the plugin didn't find a votingsite matching the service site
|
||||
ServiceSite: 'PlanetMinecraft.com'
|
||||
|
||||
# vote url for /vote
|
||||
# Format for this can be set in Config.yml
|
||||
# Do not include colors here
|
||||
# If you need to force a url set the url as this:
|
||||
# VoteURL: '[Text="ANY TEXT TO CLICK ON HERE",url="URLHERE"]'
|
||||
VoteURL: 'link to vote URL here, used in /vote'
|
||||
|
||||
# Time between votes in hours (used for /vote next)
|
||||
# Most sites are 24 hours
|
||||
VoteDelay: 24
|
||||
|
||||
# Use to have a minute votedelay
|
||||
#VoteDelayMin: 30
|
||||
|
||||
# Require waiting until votedelay time has pasted in order to accept vote
|
||||
# Recommend: false
|
||||
WaitUntilVoteDelay: false
|
||||
|
||||
# Reset vote delay each day (for certain sites that do this)
|
||||
# Recommend: false
|
||||
VoteDelayDaily: false
|
||||
|
||||
# Replaces offset, set the exact hour based on server time
|
||||
# Include server time offset when setting this
|
||||
# 2 = 2 am server time
|
||||
# Use 1-24
|
||||
#VoteDelayDailyHour: 14
|
||||
|
||||
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
|
||||
# Setting this to true will execute the reward offline while the player is offline
|
||||
# This basiclly disables offline voting if set to true, don't misinterpret this option
|
||||
ForceOffline: false
|
||||
|
||||
# VoteSite Material for some GUI's
|
||||
# Removing this may result in an error, required on each site
|
||||
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
|
||||
Rewards:
|
||||
# Execute console commands
|
||||
Commands:
|
||||
- 'say hello'
|
||||
# Send player a message
|
||||
Messages:
|
||||
Player: 'You voted'
|
||||
# Site 2 example
|
||||
Site2:
|
||||
Enabled: false
|
||||
Name: 'Site2'
|
||||
ServiceSite: 'PlanetMinecraft.com'
|
||||
VoteURL: 'link to vote URL here, used in /vote'
|
||||
VoteDelay: 24
|
||||
DisplayItem:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
Rewards:
|
||||
Commands:
|
||||
- 'say hello'
|
||||
# Advanced example
|
||||
# 50% chance for reward1, if reward1 not given then 20% chance to get reward2, if reward2 not given then fallback
|
||||
AdvancedPriority:
|
||||
# Similar to priority, but no need to have to use reward files
|
||||
# Add requirements under each reward
|
||||
# Will go in order from list here and try to run each of the following rewards...
|
||||
# This name can be anything, but they need to be different
|
||||
Reward1:
|
||||
Chance: 50
|
||||
# Any other requirement here
|
||||
# If any requirement fails, the next reward will be attempted
|
||||
# Use permission requirement for rank based rewards
|
||||
#RequirePermission: true
|
||||
#Permission: 'permhere'
|
||||
Messages:
|
||||
Player: 'You got first reward'
|
||||
Reward2:
|
||||
Chance: 20
|
||||
Messages:
|
||||
Player: 'You got second reward'
|
||||
# Fallback, 100% chance, after other rewards fail chances
|
||||
Fallback:
|
||||
Messages:
|
||||
Player: 'You got unlucky'
|
||||
|
||||
# Give 1 diamond regardless of above
|
||||
Items:
|
||||
item1:
|
||||
Material: DIAMOND
|
||||
Amount: 1
|
||||
|
||||
Messages:
|
||||
Player: 'You voted'
|
||||
|
||||
# Reward for any site
|
||||
# Similar to AnySiteReward
|
||||
# This requires the site to be configured in order to get the reward.
|
||||
EverySiteReward: {}
|
||||
@@ -1,6 +0,0 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.bungee.VotingPluginBungee
|
||||
author: BenCodez
|
||||
softDepends:
|
||||
- RedisBungee
|
||||
@@ -1,4 +0,0 @@
|
||||
time: '${timestamp}'
|
||||
profile: '${build.profile.id}'
|
||||
version: '${project.version}'
|
||||
buildnumber: '${build.number}'
|
||||
@@ -1,540 +0,0 @@
|
||||
<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>${version.art}</artifactId>
|
||||
<version>6.15.1</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
<build.number>NOTSET</build.number>
|
||||
</properties>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>Resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>bungee.yml</include>
|
||||
<include>votingpluginversion.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>Resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<versionRange>[1,)</versionRange>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.20.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>delombok</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>mysql-connector-java</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.bencodez.advancedcore</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.mrten.mysqlapi</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.mysqlapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.HikariCP</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.HikariCP</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>xyz.upperlevel.spigot</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore.xyz.upperlevel.spigot</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<!-- Lets exclude google code, because the server already has this
|
||||
code in it (guava, etc) -->
|
||||
<excludes>
|
||||
<exclude>com.google.*:*</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${user.home}/Documents/Test Server/plugins</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/target</directory>
|
||||
<includes>
|
||||
<include>VotingPlugin.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
<repository>
|
||||
<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>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>velocity</id>
|
||||
<url>https://nexus.velocitypowered.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bencodez repo</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>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>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.30</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>1.20-R0.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vexsoftware</groupId>
|
||||
<artifactId>nuvotifier-universal</artifactId>
|
||||
<version>2.7.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>mvdwplaceholderapi</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
<artifactId>velocity-api</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-velocity</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.11.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>normal</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<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.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<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>
|
||||
</profile>
|
||||
<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>
|
||||
<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>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>deploy-snapshot</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-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>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<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.6.3</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>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
<repository>
|
||||
<id>nexus</id>
|
||||
<url>https://nexus.bencodez.com/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>3.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>
|
||||
<!--<plugin>
|
||||
<groupId>com.github.github</groupId>
|
||||
<artifactId>site-maven-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc</id>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<message>Maven javadoc for ${project.version}</message>
|
||||
<noJekyll>true</noJekyll>
|
||||
<outputDirectory>${project.build.directory}/apidocs
|
||||
</outputDirectory>
|
||||
<branch>refs/heads/gh-pages</branch>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<repositoryName>VotingPlugin</repositoryName>
|
||||
<repositoryOwner>BenCodez</repositoryOwner>
|
||||
<server>github</server>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>-->
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@Deprecated
|
||||
public class User {
|
||||
private VotingPluginUser user;
|
||||
|
||||
public User(Player p) {
|
||||
user = VotingPluginMain.plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
}
|
||||
|
||||
public void addPoints(int points) {
|
||||
user.addPoints(points);
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return user.getPoints();
|
||||
}
|
||||
|
||||
public boolean removePoints(int points) {
|
||||
return user.removePoints(points);
|
||||
}
|
||||
|
||||
public void setPoints(int points) {
|
||||
user.setPoints(points);
|
||||
}
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
public class Config {
|
||||
private VotingPluginBungee bungee;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
|
||||
public Config(VotingPluginBungee bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public String getRedisHost() {
|
||||
return getData().getString("Redis.Host", "");
|
||||
}
|
||||
|
||||
public int getRedisPort() {
|
||||
return getData().getInt("Redis.Port", 6379);
|
||||
}
|
||||
|
||||
public String getRedisUsername() {
|
||||
return getData().getString("Redis.Username", "");
|
||||
}
|
||||
|
||||
|
||||
public String getRedisPassword() {
|
||||
return getData().getString("Redis.Password", "");
|
||||
}
|
||||
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getData().getBoolean("AllowUnJoined", false);
|
||||
}
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getData().getStringList("BlockedServers");
|
||||
}
|
||||
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getData().getStringList("WhiteListedServers");
|
||||
}
|
||||
|
||||
public boolean getBroadcast() {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public String getBedrockPlayerPrefix() {
|
||||
return getData().getString("BedrockPlayerPrefix", ".");
|
||||
}
|
||||
|
||||
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() {
|
||||
return getData().getString("BungeeServer.Host", "");
|
||||
}
|
||||
|
||||
public boolean getBungeeManageTotals() {
|
||||
return getData().getBoolean("BungeeManageTotals", true);
|
||||
}
|
||||
|
||||
public String getBungeeMethod() {
|
||||
return getData().getString("BungeeMethod", "SOCKETS");
|
||||
}
|
||||
|
||||
public int getBungeePort() {
|
||||
return getData().getInt("BungeeServer.Port", 1297);
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return getData().getBoolean("Debug", false);
|
||||
}
|
||||
|
||||
public boolean getMultiProxySupport() {
|
||||
return getData().getBoolean("MultiProxySupport", false);
|
||||
}
|
||||
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getData().getInt("MaxAmountOfVotesPerDay", -1);
|
||||
}
|
||||
|
||||
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", "");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getData().getBoolean("SendVotesToAllServers");
|
||||
}
|
||||
|
||||
public Configuration getSpigotServerConfiguration(String s) {
|
||||
return getData().getSection("SpigotServers." + s);
|
||||
}
|
||||
|
||||
public Collection<String> getSpigotServers() {
|
||||
return getData().getSection("SpigotServers").getKeys();
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getData().getBoolean("WaitForUserOnline", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled", false);
|
||||
}
|
||||
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getData().getBoolean("VoteParty.SendToAllServers", true);
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired", 100);
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRequired", 0);
|
||||
}
|
||||
|
||||
public int getVoteCacheTime() {
|
||||
return getData().getInt("VoteCacheTime", -1);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getData().getStringList("VoteParty.BungeeCommands");
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "bungeeconfig.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
try (InputStream in = bungee.getResourceAsStream("bungeeconfig.yml")) {
|
||||
Files.copy(in, file.toPath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "bungeeconfig.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "bungeeconfig.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
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 {
|
||||
private VotingPluginBungee bungee;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
|
||||
public NonVotedPlayersCache(VotingPluginBungee bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public void addPlayer(ProxiedPlayer proxiedPlayer) {
|
||||
if (!bungee.getMysql().containsKeyQuery(proxiedPlayer.getUniqueId().toString())) {
|
||||
addPlayer(proxiedPlayer.getUniqueId().toString(), proxiedPlayer.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayer(String uuid, String playerName) {
|
||||
getData().set("NonVotedPlayers." + playerName + ".UUID", uuid);
|
||||
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
|
||||
save();
|
||||
}
|
||||
|
||||
public void addPlayerCheck(String uuid, String playerName) {
|
||||
if (!bungee.getMysql().containsKeyQuery(uuid)) {
|
||||
addPlayer(uuid, playerName);
|
||||
}
|
||||
}
|
||||
|
||||
public void check() {
|
||||
for (String player : getData().getSection("NonVotedPlayers").getKeys()) {
|
||||
long time = getData().getLong("NonVotedPlayers." + player + ".LastTime", 0);
|
||||
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
|
||||
remove(player);
|
||||
} else {
|
||||
String uuid = getData().getString("NonVotedPlayers." + player + ".UUID", "");
|
||||
if (!uuid.isEmpty()) {
|
||||
if (bungee.getMysql().containsKeyQuery(uuid)) {
|
||||
remove(player);
|
||||
}
|
||||
} else {
|
||||
remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File yamlFile = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
File file = new File(bungee.getDataFolder(), "nonvotedplayerscache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
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(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String playerExists(String playerName) {
|
||||
if (getData().getSection("NonVotedPlayers").getKeys().contains(playerName)) {
|
||||
return getData().getString("NonVotedPlayers." + playerName + ".UUID", "");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void remove(String player) {
|
||||
bungee.debug("Removing nonvotedplayer: " + player);
|
||||
getData().set("NonVotedPlayers." + player, null);
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
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 {
|
||||
private VotingPluginBungee bungee;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
|
||||
public VoteCache(VotingPluginBungee bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getData().getInt("VoteParty.CurrentVotes", 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotes", 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
getData().set("VoteParty.CurrentVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
getData().set("VoteParty.IncreaseVotes", amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
getData().set("VoteParty.Cache." + server, amount);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getData().getInt("VoteParty.Cache." + server, 0);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
Configuration section = getData().getSection("VoteCache." + server + "." + num);
|
||||
section.set("Name", voteData.getPlayerName());
|
||||
section.set("Service", voteData.getService());
|
||||
section.set("UUID", voteData.getUuid());
|
||||
section.set("Time", voteData.getTime());
|
||||
section.set("Real", voteData.isRealVote());
|
||||
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());
|
||||
section.set("Service", voteData.getService());
|
||||
section.set("UUID", voteData.getUuid());
|
||||
section.set("Time", voteData.getTime());
|
||||
section.set("Real", voteData.isRealVote());
|
||||
section.set("Text", voteData.getText());
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
getData().set("VoteCache", null);
|
||||
getData().set("OnlineCache", null);
|
||||
save();
|
||||
}
|
||||
|
||||
public Collection<String> getOnlineVotes(String name) {
|
||||
return getData().getSection("OnlineCache." + name).getKeys();
|
||||
}
|
||||
|
||||
public Configuration getOnlineVotes(String name, String num) {
|
||||
return getData().getSection("OnlineCache." + name + "." + num);
|
||||
}
|
||||
|
||||
public Collection<String> getPlayers() {
|
||||
return getData().getSection("OnlineCache").getKeys();
|
||||
}
|
||||
|
||||
public Collection<String> getServers() {
|
||||
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();
|
||||
}
|
||||
|
||||
public Configuration getServerVotes(String server, String num) {
|
||||
return getData().getSection("VoteCache." + server + "." + num);
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (!bungee.getDataFolder().exists()) {
|
||||
bungee.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File yamlFile = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
|
||||
File file = new File(bungee.getDataFolder(), "votecache.json");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
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(JsonConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(JsonConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,115 +0,0 @@
|
||||
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;
|
||||
|
||||
public class VotingPluginBungeeCommand extends Command {
|
||||
private VotingPluginBungee bungee;
|
||||
|
||||
public VotingPluginBungeeCommand(VotingPluginBungee bungee) {
|
||||
super("votingpluginbungee", "votingplugin.admin");
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (sender.hasPermission("votingplugin.admin")) {
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
bungee.reload(false);
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
bungee.reload(true);
|
||||
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, 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(
|
||||
"&aChecking status, waiting for response, check console, method: sockets"));
|
||||
bungee.status(sender);
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"&aChecking status, waiting for response, check console, method: plugin messaging"));
|
||||
bungee.status(sender);
|
||||
bungee.sendServerNameMessage();
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.REDIS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"&aChecking status, waiting for response, check console, method: redis"));
|
||||
bungee.status(sender);
|
||||
bungee.sendServerNameMessage();
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
new TextComponent("&aNot using socket/pluginmessage/redis 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[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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import com.bencodez.advancedcore.bungeeapi.velocity.VelocityYMLFile;
|
||||
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
public class Config extends VelocityYMLFile {
|
||||
|
||||
public Config(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getBoolean(getNode("AllowUnJoined"), false);
|
||||
}
|
||||
|
||||
public List<String> getBlockedServers() {
|
||||
return getStringList(getNode("BlockedServers"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public List<String> getWhiteListedServers() {
|
||||
return getStringList(getNode("WhiteListedServers"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getBroadcast() {
|
||||
return getBoolean(getNode("Broadcast"), false);
|
||||
}
|
||||
|
||||
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() {
|
||||
return getBoolean(getNode("BungeeManageTotals"), true);
|
||||
}
|
||||
|
||||
public String getBungeeMethod() {
|
||||
return getString(getNode("BungeeMethod"), "PLUGINMESSAGING");
|
||||
}
|
||||
|
||||
public String getRedisHost() {
|
||||
return getString(getNode("Redis", "Host"), "");
|
||||
}
|
||||
|
||||
public int getRedisPort() {
|
||||
return getInt(getNode("Redis", "Port"), 6379);
|
||||
}
|
||||
|
||||
public String getRedisUsername() {
|
||||
return getString(getNode("Redis", "Username"), "");
|
||||
}
|
||||
|
||||
public String getRedisPassword() {
|
||||
return getString(getNode("Redis", "Password"), "");
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getString(getNode("BungeeServer", "Host"), "");
|
||||
}
|
||||
|
||||
public int getBungeePort() {
|
||||
return getInt(getNode("BungeeServer", "Port"), 1297);
|
||||
}
|
||||
|
||||
public int getMaxAmountOfVotesPerDay() {
|
||||
return getInt(getNode("MaxAmountOfVotesPerDay"), -1);
|
||||
}
|
||||
|
||||
public int getVoteCacheTime() {
|
||||
return getInt(getNode("VoteCacheTime"), -1);
|
||||
}
|
||||
|
||||
public boolean getDebug() {
|
||||
return getBoolean(getNode("Debug"), false);
|
||||
}
|
||||
|
||||
public String getFallBack() {
|
||||
return getString(getNode("FallBackServer"), "");
|
||||
}
|
||||
|
||||
public ConfigurationNode getMysqlNode() {
|
||||
return getNode("MySQL");
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getInt(getNode("PointsOnVote"), 1);
|
||||
}
|
||||
|
||||
public boolean getSendVotesToAllServers() {
|
||||
return getBoolean(getNode("SendVotesToAllServers"), true);
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getBoolean(getVotePartyNode().getNode("Enabled"), false);
|
||||
}
|
||||
|
||||
public ConfigurationNode getVotePartyNode() {
|
||||
return getNode("VoteParty");
|
||||
}
|
||||
|
||||
public boolean getVotePartySendToAllServers() {
|
||||
return getBoolean(getVotePartyNode().getNode("SendToAllServers"), false);
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("VotesRequired"), 100);
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequired() {
|
||||
return getInt(getVotePartyNode().getNode("IncreaseVotesRequired"), 0);
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getString(getVotePartyNode().getNode("Broadcast"), "");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getStringList(getVotePartyNode().getNode("ServersToSend"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getStringList(getVotePartyNode().getNode("BungeeCommands"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public ConfigurationNode getSpigotServerConfiguration(String s) {
|
||||
return getNode("SpigotServers", s);
|
||||
}
|
||||
|
||||
public @NonNull Collection<? extends ConfigurationNode> getSpigotServers() {
|
||||
return getNode("SpigotServers").getChildrenMap().values();
|
||||
}
|
||||
|
||||
public boolean getWaitForUserOnline() {
|
||||
return getBoolean(getNode("WaitForUserOnline"), false);
|
||||
}
|
||||
|
||||
public boolean getMultiProxySupport() {
|
||||
return getBoolean(getNode("MultiProxySupport"), false);
|
||||
}
|
||||
|
||||
public boolean getMultiProxyOneGlobalReward() {
|
||||
return getBoolean(getNode("MultiProxyOneGlobalReward"), false);
|
||||
}
|
||||
|
||||
public boolean getPrimaryServer() {
|
||||
return getBoolean(getNode("PrimaryServer"), false);
|
||||
}
|
||||
|
||||
public String getBedrockPlayerPrefix() {
|
||||
return getString(getNode("BedrockPlayerPrefix"), ".");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
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 VelocityJSONFile {
|
||||
|
||||
public VoteCache(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
public int getVotePartyCurrentVotes() {
|
||||
return getInt(getNode("VoteParty").getNode("CurrentVotes"), 0);
|
||||
}
|
||||
|
||||
public int getVotePartyInreaseVotesRequired() {
|
||||
return getInt(getNode("VoteParty").getNode("IncreaseVotes"), 0);
|
||||
}
|
||||
|
||||
public void setVotePartyCurrentVotes(int amount) {
|
||||
getNode("VoteParty").getNode("CurrentVotes").setValue(amount);
|
||||
}
|
||||
|
||||
public void setVotePartyInreaseVotesRequired(int amount) {
|
||||
getNode("VoteParty").getNode("IncreaseVotes").setValue(amount);
|
||||
}
|
||||
|
||||
public void setVotePartyCache(String server, int amount) {
|
||||
getNode("VoteParty").getNode("Cache").getNode(server).setValue(amount);
|
||||
}
|
||||
|
||||
public int getVotePartyCache(String server) {
|
||||
return getNode("VoteParty").getNode("Cache").getNode(server).getInt(0);
|
||||
}
|
||||
|
||||
public void addVote(String server, int num, OfflineBungeeVote voteData) {
|
||||
String[] path = new String[] { "VoteCache", server, "" + num };
|
||||
|
||||
getNode(path, "Name").setValue(voteData.getPlayerName());
|
||||
getNode(path, "Service").setValue(voteData.getService());
|
||||
getNode(path, "UUID").setValue(voteData.getUuid());
|
||||
getNode(path, "Time").setValue(voteData.getTime());
|
||||
getNode(path, "Real").setValue(voteData.isRealVote());
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
}
|
||||
|
||||
public void 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 };
|
||||
|
||||
getNode(path, "Name").setValue(voteData.getPlayerName());
|
||||
getNode(path, "Service").setValue(voteData.getService());
|
||||
getNode(path, "UUID").setValue(voteData.getUuid());
|
||||
getNode(path, "Time").setValue(voteData.getTime());
|
||||
getNode(path, "Real").setValue(voteData.isRealVote());
|
||||
getNode(path, "Text").setValue(voteData.getText());
|
||||
}
|
||||
|
||||
public void clearData() {
|
||||
getNode("VoteCache").setValue(null);
|
||||
getNode("OnlineCache").setValue(null);
|
||||
save();
|
||||
}
|
||||
|
||||
public Collection<String> getOnlineVotes(String name) {
|
||||
return getKeys(getNode("OnlineCache", name));
|
||||
}
|
||||
|
||||
public ConfigurationNode getTimedVoteCache(String name) {
|
||||
return getNode("TimedVoteCache", name);
|
||||
}
|
||||
|
||||
public ConfigurationNode getOnlineVotes(String name, String num) {
|
||||
return getNode("OnlineCache", name, num);
|
||||
}
|
||||
|
||||
public Collection<String> getPlayers() {
|
||||
return getKeys(getNode("OnlineCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getServers() {
|
||||
return getKeys(getNode("VoteCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getTimedVoteCache() {
|
||||
return getKeys(getNode("TimedVoteCache"));
|
||||
}
|
||||
|
||||
public Collection<String> getServerVotes(String server) {
|
||||
return getKeys(getNode("OnlineCache", server));
|
||||
}
|
||||
|
||||
public ConfigurationNode getServerVotes(String server, String num) {
|
||||
return getNode("VoteCache", server, num);
|
||||
}
|
||||
|
||||
}
|
||||
-1648
File diff suppressed because it is too large.
Load diff
-127
@@ -1,127 +0,0 @@
|
||||
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;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class VotingPluginVelocityCommand implements SimpleCommand {
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
public VotingPluginVelocityCommand(VotingPluginVelocity plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Invocation invocation) {
|
||||
CommandSource source = invocation.source();
|
||||
// Get the arguments after the command alias
|
||||
String[] args = invocation.arguments();
|
||||
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
plugin.reload(false);
|
||||
source.sendMessage(Component.text("Reloading VotingPluginBungee").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("reloadmysql")) {
|
||||
plugin.reload(true);
|
||||
source.sendMessage(Component.text("Reloading VotingPluginBungee MySQL").color(NamedTextColor.AQUA));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
plugin.vote(user, site, false, 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(
|
||||
Component.text("Checking status, waiting for response, check console, method: sockets")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
} else if (plugin.getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
source.sendMessage(Component
|
||||
.text("Checking status, waiting for response, check console, method: pluginmessaging")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
plugin.sendServerNameMessage();
|
||||
} else if (plugin.getMethod().equals(BungeeMethod.REDIS)) {
|
||||
source.sendMessage(
|
||||
Component.text("Checking status, waiting for response, check console, method: redis")
|
||||
.color(NamedTextColor.AQUA));
|
||||
plugin.status();
|
||||
plugin.sendServerNameMessage();
|
||||
} else {
|
||||
source.sendMessage(Component.text("Not using socket/pluginmessage method, command unavailable")
|
||||
.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[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;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Invocation invocation) {
|
||||
return invocation.source().hasPermission("votingpluginbungee.admin");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.jvm.toolchain.JvmVendorSpec
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
eclipse
|
||||
id("com.gradleup.shadow") version "8.3.9"
|
||||
}
|
||||
|
||||
group = "com.bencodez"
|
||||
version = "6.19.1-SNAPSHOT"
|
||||
description = "VotingPlugin"
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
vendor.set(JvmVendorSpec.GRAAL_VM)
|
||||
}
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url = uri("https://oss.sonatype.org/content/groups/public") }
|
||||
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
|
||||
maven {
|
||||
url = uri("https://nexus.velocitypowered.com/repository/maven-public/")
|
||||
content { includeGroup("com.velocitypowered") }
|
||||
}
|
||||
maven { url = uri("https://nexus.bencodez.com/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/") }
|
||||
maven { url = uri("https://nexus.scarsz.me/content/groups/public/") }
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT")
|
||||
compileOnly("org.projectlombok:lombok:1.18.38")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.38")
|
||||
compileOnly("net.md-5:bungeecord-api:1.21-R0.3")
|
||||
compileOnly("com.vexsoftware:nuvotifier-universal:2.7.2")
|
||||
compileOnly("be.maximvdw:mvdwplaceholderapi:3.1.1")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
implementation("org.bstats:bstats-velocity:3.1.0")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
implementation("com.bencodez:advancedcore:3.7.19-SNAPSHOT")
|
||||
compileOnly("com.discordsrv:discordsrv:1.30.0")
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.encoding = "Cp1252"
|
||||
}
|
||||
|
||||
val buildProfileId = (findProperty("buildProfile") ?: System.getenv("BUILD_PROFILE") ?: "default").toString()
|
||||
val buildNumber = (findProperty("buildNumber") ?: System.getenv("BUILD_NUMBER") ?: "NOTSET").toString()
|
||||
val timestamp = System.currentTimeMillis().toString()
|
||||
val apiVersion = "1.19"
|
||||
val resourceProps = mapOf(
|
||||
"name" to project.name,
|
||||
"version" to project.version.toString(),
|
||||
"apiVersion" to apiVersion,
|
||||
"timestamp" to timestamp,
|
||||
"build" to mapOf(
|
||||
"profile" to mapOf("id" to buildProfileId),
|
||||
"number" to buildNumber
|
||||
)
|
||||
)
|
||||
|
||||
tasks.processResources {
|
||||
filteringCharset = "Cp1252"
|
||||
inputs.properties(resourceProps)
|
||||
filesMatching(listOf("plugin.yml", "bungee.yml", "votingpluginversion.yml")) {
|
||||
expand(resourceProps)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.jar { enabled = false }
|
||||
|
||||
tasks.named<ShadowJar>("shadowJar") {
|
||||
archiveBaseName.set("VotingPlugin")
|
||||
archiveVersion.set("")
|
||||
archiveClassifier.set("")
|
||||
mergeServiceFiles()
|
||||
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "module-info.class")
|
||||
dependencies { exclude(dependency("com.google.*:.*")) }
|
||||
relocate("com.tcoded.folialib", "${project.group}.votingplugin.simpleapi.folialib")
|
||||
relocate("com.bencodez.simpleapi", "${project.group}.votingplugin.simpleapi")
|
||||
relocate("com.bencodez.advancedcore", "${project.group}.votingplugin.advancedcore")
|
||||
relocate("net.pl3x.bukkit.chatapi", "${project.group}.votingplugin")
|
||||
relocate("me.mrten.mysqlapi", "${project.group}.votingplugin.mysqlapi")
|
||||
relocate("com.zaxxer.hikari", "${project.group}.votingplugin.simpleapi.hikari")
|
||||
relocate("org.bstats", "${project.group}.votingplugin.bstats")
|
||||
relocate("xyz.upperlevel.spigot", "${project.group}.votingplugin.advancedcore.xyz.upperlevel.spigot")
|
||||
manifest { attributes(mapOf("paperweight-mappings-namespace" to "mojang")) }
|
||||
}
|
||||
|
||||
tasks.build { dependsOn(tasks.named("shadowJar")) }
|
||||
|
||||
tasks.register<Copy>("copyToTestServer") {
|
||||
dependsOn(tasks.named("shadowJar"))
|
||||
from(tasks.named("shadowJar"))
|
||||
into("${System.getProperty("user.home")}/Documents/Test_Server/plugins")
|
||||
}
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+7
@@ -0,0 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,251 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+94
@@ -0,0 +1,94 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,2 @@
|
||||
rootProject.name = "VotingPlugin"
|
||||
|
||||
+289
-372
@@ -1,6 +1,7 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
@@ -9,34 +10,41 @@ import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
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.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.GlobalMessage.GlobalMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.GlobalMessage.GlobalMessageListener;
|
||||
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.redis.RedisHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.redis.RedisListener;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.global.GlobalMessageListener;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttHandler.MessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.mqtt.MqttServerComm;
|
||||
import com.bencodez.simpleapi.servercomm.mysql.BackendMessenger;
|
||||
import com.bencodez.simpleapi.servercomm.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisHandler;
|
||||
import com.bencodez.simpleapi.servercomm.redis.RedisListener;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.ClientHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketHandler;
|
||||
import com.bencodez.simpleapi.servercomm.sockets.SocketReceiver;
|
||||
import com.bencodez.simpleapi.sql.data.DataValue;
|
||||
import com.bencodez.simpleapi.sql.data.DataValueBoolean;
|
||||
import com.bencodez.simpleapi.sql.mysql.config.MysqlConfigSpigot;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.BungeeVersion;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -74,33 +82,13 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
private Thread redisThread;
|
||||
|
||||
@Getter
|
||||
private BackendMessenger backendMysqlMessenger;
|
||||
|
||||
public BungeeHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
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()); } }
|
||||
*/
|
||||
|
||||
public void checkGlobalData() {
|
||||
HashMap<String, DataValue> data = globalDataHandler.getExact(plugin.getBungeeSettings().getServer());
|
||||
// plugin.debug(data.toString());
|
||||
@@ -131,19 +119,21 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<>();
|
||||
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());
|
||||
}
|
||||
/*
|
||||
* @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 boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
|
||||
boolean isProcessing = false;
|
||||
@@ -167,101 +157,35 @@ public class BungeeHandler implements Listener {
|
||||
plugin.debug("Detected time change from bungee: " + type.toString());
|
||||
plugin.getTimeChecker().forceChanged(type, false, true, true);
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
getGlobalMessageHandler().sendMessage("TimeChangeFinished",
|
||||
"" + plugin.getBungeeSettings().getServer());
|
||||
}
|
||||
}
|
||||
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() {
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkGlobalData();
|
||||
}
|
||||
}, 60, 10, TimeUnit.SECONDS);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
public void close() {
|
||||
if (backendMysqlMessenger != null) {
|
||||
backendMysqlMessenger.shutdown();
|
||||
}
|
||||
|
||||
@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);
|
||||
if (socketHandler != null) {
|
||||
socketHandler.closeConnection();
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,19 +203,38 @@ public class BungeeHandler implements Listener {
|
||||
@Override
|
||||
public void sendMessage(String subChannel, String... messageData) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
// plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
|
||||
try {
|
||||
backendMysqlMessenger.sendToProxy(subChannel + "%l%" + String.join("%l%", messageData));
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.getInstance().convert(messageData));
|
||||
sendData(ArrayUtils.getInstance().convert(list));
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
sendData(ArrayUtils.convert(list));
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.getInstance().convert(messageData));
|
||||
redisHandler.sendMessage("VotingPlugin", ArrayUtils.getInstance().convert(list));
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
redisHandler.sendMessage(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
|
||||
ArrayUtils.convert(list));
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
try {
|
||||
mqttHandler.publish(plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/proxy",
|
||||
String.join(":", list));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -414,10 +357,6 @@ public class BungeeHandler implements Listener {
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
@@ -493,11 +432,6 @@ public class BungeeHandler implements Listener {
|
||||
|
||||
user.offVote();
|
||||
|
||||
if (args.size() > 3 && plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(3));
|
||||
plugin.getSpecialRewards().checkMilestone(user, text, true);
|
||||
}
|
||||
|
||||
if (args.size() > 2) {
|
||||
bungeeVotePartyCurrent = Integer.parseInt(args.get(1));
|
||||
bungeeVotePartyRequired = Integer.parseInt(args.get(2));
|
||||
@@ -505,6 +439,26 @@ public class BungeeHandler implements Listener {
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
}
|
||||
|
||||
if (args.size() > 3 && plugin.getBungeeSettings().isPerServerMilestones()) {
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(3));
|
||||
plugin.getSpecialRewards().checkMilestone(user, text, true);
|
||||
}
|
||||
|
||||
if (args.size() > 5) {
|
||||
String service = args.get(4);
|
||||
String data = args.get(5);
|
||||
if (MessageAPI.isLong(data)) {
|
||||
long time = Long.valueOf(data);
|
||||
if (time > 0) {
|
||||
user.setTime(plugin.getVoteSite(service, true), time);
|
||||
} else {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug("Invalid last vote time received from bungee: " + time);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
@@ -595,29 +549,51 @@ public class BungeeHandler implements Listener {
|
||||
});
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
try {
|
||||
backendMysqlMessenger = new BackendMessenger("VotingPlugin",
|
||||
plugin.getMysql().getMysql().getConnectionManager().getDataSource(),
|
||||
plugin.getOptions().getServer(), msg -> {
|
||||
plugin.debug("Proxy sent: " + msg.payload);
|
||||
|
||||
String[] message = msg.payload.split(Pattern.quote("%l%"));
|
||||
if (message.length > 0) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (int i = 1; i < message.length; i++) {
|
||||
list.add(message[i]);
|
||||
}
|
||||
globalMessageHandler.onMessage(message[0], list);
|
||||
}
|
||||
|
||||
});
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
redisHandler = new RedisHandler(plugin.getBungeeSettings().getRedisHost(),
|
||||
plugin.getBungeeSettings().getRedisPort(), plugin.getBungeeSettings().getRedisUsername(),
|
||||
plugin.getBungeeSettings().getRedisPassword()) {
|
||||
|
||||
@Override
|
||||
protected void onMessage(String channel, String[] message) {
|
||||
plugin.getLogger().info(channel
|
||||
+ ArrayUtils.getInstance().makeStringList(ArrayUtils.getInstance().convert(message)));
|
||||
if (message.length > 0) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (int i = 1; i < message.length; i++) {
|
||||
list.add(message[i]);
|
||||
}
|
||||
globalMessageHandler.onMessage(message[0], list);
|
||||
public void debug(String message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
protected void onMessage(String channel, String[] message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
plugin.debug(channel + " " + ArrayUtils.makeStringList(ArrayUtils.convert(message)));
|
||||
}
|
||||
if (message.length > 0) {
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
for (int i = 1; i < message.length; i++) {
|
||||
list.add(message[i]);
|
||||
}
|
||||
globalMessageHandler.onMessage(message[0], list);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -626,95 +602,36 @@ public class BungeeHandler implements Listener {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.isEnabled()) {
|
||||
redisHandler.loadListener(new RedisListener(redisHandler,
|
||||
"VotingPlugin_" + plugin.getBungeeSettings().getServer()));
|
||||
redisHandler.loadListener(
|
||||
new RedisListener(redisHandler, plugin.getBungeeSettings().getRedisPrefix()
|
||||
+ "VotingPlugin_" + plugin.getBungeeSettings().getServer()));
|
||||
}
|
||||
}
|
||||
});
|
||||
redisThread.start();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
|
||||
if (plugin.getBungeeSettings().isPluginMessageEncryption()) {
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
plugin.getPluginMessaging().setEncryptionHandler(encryptionHandler);
|
||||
}
|
||||
|
||||
plugin.getPluginMessaging().setDebug(plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler() {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("Vote", args);
|
||||
}
|
||||
});
|
||||
globalMessageHandler.onMessage(subChannel, args);
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteOnline") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteOnline", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteUpdate") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteUpdate", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("BungeeTimeChange") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("BungeeTimeChange", args);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteBroadcast", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcastOffline") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VoteBroadcastOffline", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("Status", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("ServerName") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("ServerName", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBungee") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VotePartyBungee", args);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VotePartyBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("VotePartyBroadcast", args);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
clientHandler = new ClientHandler(plugin.getBungeeSettings().getBungeeServerHost(),
|
||||
plugin.getBungeeSettings().getBungeeServerPort(), encryptionHandler,
|
||||
@@ -730,156 +647,156 @@ public class BungeeHandler implements Listener {
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevote") {
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 5) {
|
||||
plugin.extraDebug("BungeeVote from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
user.bungeeVote(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
|
||||
}
|
||||
globalMessageHandler.onMessage(data[0], ArrayUtils.convertAndRemoveFirst(data));
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeTimeChange") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
checkGlobalData();
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
try {
|
||||
String id = plugin.getBungeeSettings().getMqttClientID();
|
||||
if (id.isEmpty()) {
|
||||
id = plugin.getOptions().getServer();
|
||||
}
|
||||
});
|
||||
mqttHandler = new MqttHandler(new MqttServerComm(plugin.getBungeeSettings().getMqttClientID(),
|
||||
plugin.getBungeeSettings().getMqttBrokerURL(), plugin.getBungeeSettings().getMqttUsername(),
|
||||
plugin.getBungeeSettings().getMqttPassword()), 2);
|
||||
mqttHandler.subscribe(plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/"
|
||||
+ plugin.getOptions().getServer(), new MessageHandler() {
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevoteonline") {
|
||||
@Override
|
||||
public void onMessage(String topic, String payload) {
|
||||
String[] message = payload.split(":");
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 5) {
|
||||
plugin.extraDebug("BungeeVoteOnline from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.cache();
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
user.bungeeVoteOnline(data[3], new BungeeMessageData(data[4]), !Boolean.valueOf(data[5]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BroadcastOffline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
String votes = data[0];
|
||||
String p = data[1];
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[3];
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("Broadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1], true);
|
||||
String p = data[2];
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("Status") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 0) {
|
||||
plugin.getLogger().info("Received status command, sending status back");
|
||||
sendData("StatusOkay", plugin.getOptions().getServer());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeUpdate") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBungee") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("VotePartyBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
String broadcast = data[0];
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
if (message.length > 0) {
|
||||
globalMessageHandler.onMessage(message[0],
|
||||
ArrayUtils.convertAndRemoveFirst(message));
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
|
||||
|
||||
if (plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
private MqttHandler mqttHandler;
|
||||
|
||||
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 debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
plugin.getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void debugEx(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debugLog(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void info(String text) {
|
||||
plugin.getLogger().info(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logSevere(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(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);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendData(String... strings) {
|
||||
File renamed without changes.
+1791
-1661
File diff suppressed because it is too large.
Load diff
+24
-30
@@ -2,7 +2,7 @@ package com.bencodez.votingplugin;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
|
||||
import com.bencodez.simpleapi.metrics.BStatsMetrics;
|
||||
|
||||
public class VotingPluginMetrics {
|
||||
|
||||
@@ -16,9 +16,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite", new Callable<String>() {
|
||||
@@ -28,9 +27,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites", new Callable<String>() {
|
||||
@@ -40,9 +38,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative", new Callable<String>() {
|
||||
@@ -51,14 +48,13 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
for (String cum : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(Integer.parseInt(cum))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
for (String cum : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(Integer.parseInt(cum))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty", new Callable<String>() {
|
||||
@@ -67,9 +63,8 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (!plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
return "False";
|
||||
} else {
|
||||
return "True";
|
||||
}
|
||||
return "True";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("placeholder_cache_level", new Callable<String>() {
|
||||
@@ -85,14 +80,13 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
for (String milestone : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(Integer.parseInt(milestone))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
for (String milestone : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(Integer.parseInt(milestone))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward", new Callable<String>() {
|
||||
@@ -102,9 +96,8 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday", new Callable<String>() {
|
||||
@@ -161,7 +154,7 @@ public class VotingPluginMetrics {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getVoteSites().size();
|
||||
return "" + plugin.getVoteSitesEnabled().size();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards", new Callable<String>() {
|
||||
@@ -186,9 +179,11 @@ public class VotingPluginMetrics {
|
||||
int total = plugin.getUserManager().getAllUUIDs().size();
|
||||
if (total > 800000) {
|
||||
return ">800000";
|
||||
} else if (total > 700000) {
|
||||
}
|
||||
if (total > 700000) {
|
||||
return "700000-800000";
|
||||
} else if (total > 600000) {
|
||||
}
|
||||
if (total > 600000) {
|
||||
return "600000-700000";
|
||||
} else if (total > 500000) {
|
||||
return "500000-600000";
|
||||
@@ -255,9 +250,8 @@ public class VotingPluginMetrics {
|
||||
public String call() throws Exception {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "" + plugin.getBungeeHandler().getMethod().toString();
|
||||
} else {
|
||||
return "Disabled";
|
||||
}
|
||||
return "Disabled";
|
||||
}
|
||||
}));
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
+7
-7
@@ -10,14 +10,15 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class BroadcastHandler {
|
||||
private VotingPluginMain plugin;
|
||||
private ScheduledExecutorService timer;
|
||||
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<String>();
|
||||
ConcurrentLinkedQueue<String> votedPlayers = new ConcurrentLinkedQueue<>();
|
||||
|
||||
public BroadcastHandler(VotingPluginMain plugin, int delay) {
|
||||
this.plugin = plugin;
|
||||
@@ -30,8 +31,7 @@ public class BroadcastHandler {
|
||||
for (int i = 0; i < size; i++) {
|
||||
votedPlayers.poll();
|
||||
}
|
||||
String bc = StringParser.getInstance()
|
||||
.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
|
||||
String bc = MessageAPI.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
|
||||
String playersText = "";
|
||||
while (!votedPlayers.isEmpty()) {
|
||||
playersText += votedPlayers.remove();
|
||||
@@ -39,11 +39,11 @@ public class BroadcastHandler {
|
||||
playersText += ", ";
|
||||
}
|
||||
}
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("numberofplayers", "" + size);
|
||||
placeholders.put("players", playersText);
|
||||
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
bc = PlaceholderUtils.replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
+382
-255
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -5,7 +5,7 @@ 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.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -36,7 +36,7 @@ public class CommandAdminVote implements CommandExecutor {
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
|
||||
return true;
|
||||
}
|
||||
+8
-8
@@ -7,8 +7,8 @@ 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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -40,15 +40,15 @@ public class CommandAliases implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
ArrayList<String> argsNew = new ArrayList<String>();
|
||||
ArrayList<String> argsNew = new ArrayList<>();
|
||||
argsNew.add(cmdHandle.getArgs()[0]);
|
||||
for (String arg : args) {
|
||||
argsNew.add(arg);
|
||||
}
|
||||
plugin.debug("Attempting cmd...");
|
||||
plugin.debug("Inputed args: " + ArrayUtils.getInstance().makeStringList(argsNew));
|
||||
plugin.debug("Inputed args: " + ArrayUtils.makeStringList(argsNew));
|
||||
|
||||
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
|
||||
ArrayList<CommandHandler> handles = new ArrayList<>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
@@ -73,7 +73,7 @@ public class CommandAliases implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
if (cmdHandle.runCommand(sender, ArrayUtils.getInstance().convert(argsNew))) {
|
||||
if (cmdHandle.runCommand(sender, ArrayUtils.convert(argsNew))) {
|
||||
plugin.debug("cmd found, ran cmd");
|
||||
return true;
|
||||
}
|
||||
@@ -91,9 +91,9 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
} else {
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
+2
-2
@@ -5,7 +5,7 @@ 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.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -61,7 +61,7 @@ public class CommandVote implements CommandExecutor {
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
return true;
|
||||
}
|
||||
|
||||
+18
-16
@@ -19,14 +19,14 @@ import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueLi
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.player.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteVoteParty;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.cumulative.AdminVoteCumulative;
|
||||
@@ -49,7 +49,7 @@ public class AdminGUI {
|
||||
* @return ArrayList of buttons
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<>();
|
||||
buttons.add(new BInventoryButton("&cVoteSites",
|
||||
new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
@@ -241,25 +241,27 @@ public class AdminGUI {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("Enabled: " + voteSite.isEnabled());
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
|
||||
lore.add("Name: " + voteSite.getDisplayName());
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
lore.add("VoteDelayMin: " + voteSite.getVoteDelayMin());
|
||||
|
||||
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
inv.addButton(count,
|
||||
new BInventoryButton(voteSite.getKey(), ArrayUtils.convert(lore), new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
inv.openInventory(player);
|
||||
@@ -279,7 +281,7 @@ public class AdminGUI {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ArrayList<String> playerNames = new ArrayList<String>();
|
||||
ArrayList<String> playerNames = new ArrayList<>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
@@ -287,7 +289,7 @@ public class AdminGUI {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
|
||||
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
@@ -300,8 +302,8 @@ public class AdminGUI {
|
||||
});
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
.allowCustomOption(true).request(event.getWhoClicked());
|
||||
}, ArrayUtils.convert(playerNames)).usingMethod(InputMethod.INVENTORY).allowCustomOption(true)
|
||||
.request(event.getWhoClicked());
|
||||
}
|
||||
});
|
||||
|
||||
File renamed without changes.
+8
-8
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
@@ -35,7 +35,7 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelp(CommandSender sender, int page) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
ArrayList<TextComponent> text = adminHelpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
@@ -43,9 +43,9 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add(StringParser.getInstance().stringToComp("&6&lVotingPlugin Admin Help " + (page) + "/" + maxPage));
|
||||
msg.add(StringParser.getInstance().stringToComp("&6&l() = Needed"));
|
||||
msg.add(StringParser.getInstance().stringToComp("&6&lAliases: adminvote, av"));
|
||||
msg.add(MessageAPI.stringToComp("&6&lVotingPlugin Admin Help " + (page) + "/" + maxPage));
|
||||
msg.add(MessageAPI.stringToComp("&6&l() = Needed"));
|
||||
msg.add(MessageAPI.stringToComp("&6&lAliases: adminvote, av"));
|
||||
|
||||
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
|
||||
msg.add(text.get(i));
|
||||
@@ -61,8 +61,8 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
@@ -71,7 +71,7 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
+12
-12
@@ -12,7 +12,7 @@ import org.bukkit.permissions.Permission;
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class AdminVotePerms extends GUIHandler {
|
||||
@@ -40,7 +40,7 @@ public class AdminVotePerms extends GUIHandler {
|
||||
}
|
||||
|
||||
public String[] listPerms(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
@@ -100,7 +100,7 @@ public class AdminVotePerms extends GUIHandler {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
ArrayList<String> text = new ArrayList<>();
|
||||
|
||||
text.add("&c&lCommand : Permissions " + page + "/" + maxPage);
|
||||
|
||||
@@ -108,17 +108,17 @@ public class AdminVotePerms extends GUIHandler {
|
||||
text.add(msg.get(i));
|
||||
}
|
||||
|
||||
text = ArrayUtils.getInstance().colorize(text);
|
||||
text = ArrayUtils.colorize(text);
|
||||
|
||||
return ArrayUtils.getInstance().convert(text);
|
||||
return ArrayUtils.convert(text);
|
||||
}
|
||||
|
||||
public ArrayList<String> listPerms(CommandSender sender, String player, int page) {
|
||||
Player p = Bukkit.getPlayer(player);
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
ArrayList<String> text = new ArrayList<>();
|
||||
if (p != null) {
|
||||
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
@@ -158,7 +158,7 @@ public class AdminVotePerms extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
|
||||
@@ -175,12 +175,12 @@ public class AdminVotePerms extends GUIHandler {
|
||||
} else {
|
||||
text.add("&cPlayer not online: " + player);
|
||||
}
|
||||
return ArrayUtils.getInstance().colorize(text);
|
||||
return ArrayUtils.colorize(text);
|
||||
|
||||
}
|
||||
|
||||
public String[] listPermsDev(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("Command");
|
||||
msg.add(" Permissions (seperated by |");
|
||||
msg.add(" Help messasge");
|
||||
@@ -202,9 +202,9 @@ public class AdminVotePerms extends GUIHandler {
|
||||
msg.add(perm.getName() + " : " + perm.getDescription());
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
return ArrayUtils.convert(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
+3
-3
@@ -48,7 +48,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -66,7 +66,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
msg = "votingplugin_" + identifier + "";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -79,7 +79,7 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cPlaceholders:");
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
+3
-3
@@ -45,7 +45,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user, identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -60,7 +60,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
String value = placeholder.placeholderRequest(identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout layout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
@@ -70,7 +70,7 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cPlaceholders:");
|
||||
VotingPluginUser placeholderUser = user;
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
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.UUID;
|
||||
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 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.player.VoteGUI;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class AdminVoteTopPoints extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public AdminVoteTopPoints(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@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) {
|
||||
try {
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topPoints1 = new LinkedHashMap<TopVoterPlayer, Integer>();
|
||||
|
||||
for (String uuid : plugin.getVotingPluginUserManager().getAllUUIDs()) {
|
||||
VotingPluginUser vpUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid));
|
||||
vpUser.dontCache();
|
||||
int points = vpUser.getPoints();
|
||||
if (points > 0) {
|
||||
topPoints1.put(vpUser.getTopVoterPlayer(), points);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topPoints = plugin.getTopVoterHandler().sortByValues(topPoints1,
|
||||
false);
|
||||
|
||||
users = topPoints.entrySet();
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
playerSlots.addAll(customizationPlayerSlots);
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory("Top Points");
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
|
||||
ItemBuilder playerItem = new ItemBuilder(Material.PAPER);
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
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().isChestVoteTopOpenMainGUIOnClick()) {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey());
|
||||
|
||||
if (customzationEnabled && !playerSlots.isEmpty()) {
|
||||
button.setSlot(playerSlots.remove());
|
||||
}
|
||||
|
||||
inv.setCloseInv(plugin.getGui().isChestVoteTopCloseGUIOnClick());
|
||||
|
||||
inv.addButton(button);
|
||||
pos++;
|
||||
}
|
||||
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
File renamed without changes.
+1
-1
@@ -44,7 +44,7 @@ public class AdminVoteVotePlayer extends GUIHandler {
|
||||
EditGUI inv = new EditGUI("Trigger vote for " + playerName);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Vote|VotingPlugin.Admin");
|
||||
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {
|
||||
|
||||
@Override
|
||||
+3
-3
@@ -12,12 +12,12 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
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.NumberListener;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class AdminVoteCumulative extends GUIHandler {
|
||||
@@ -52,9 +52,9 @@ public class AdminVoteCumulative extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
ArrayList<Integer> nums = new ArrayList<>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (StringParser.getInstance().isInt(num)) {
|
||||
if (MessageAPI.isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
}
|
||||
}
|
||||
-1
@@ -63,7 +63,6 @@ public class AdminVoteCumulativeRemove extends GUIHandler {
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
-1
@@ -63,7 +63,6 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
+3
-3
@@ -12,12 +12,12 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
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.NumberListener;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class AdminVoteMilestones extends GUIHandler {
|
||||
@@ -52,9 +52,9 @@ public class AdminVoteMilestones extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
ArrayList<Integer> nums = new ArrayList<>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (StringParser.getInstance().isInt(num)) {
|
||||
if (MessageAPI.isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -59,7 +59,7 @@ public class AdminVoteVoteShop extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
plugin.getGui().createShop(value);
|
||||
plugin.getShopFile().createShop(value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
+8
-8
@@ -53,7 +53,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
// to add
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1), new EditGUIValueString("Identifier_Name",
|
||||
plugin.getGui().getChestShopIdentifierIdentifierName(identifier)) {
|
||||
plugin.getShopFile().getShopIdentifierIdentifierName(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String name) {
|
||||
@@ -61,7 +61,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.OAK_DOOR, 1),
|
||||
new EditGUIValueString("Permission", plugin.getGui().getChestVoteShopPermission(identifier)) {
|
||||
new EditGUIValueString("Permission", plugin.getShopFile().getVoteShopPermission(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String name) {
|
||||
@@ -69,7 +69,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.EMERALD, 1),
|
||||
new EditGUIValueNumber("Cost", plugin.getGui().getChestShopIdentifierCost(identifier)) {
|
||||
new EditGUIValueNumber("Cost", plugin.getShopFile().getShopIdentifierCost(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
@@ -77,7 +77,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
}
|
||||
}));
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.BARRIER, 1),
|
||||
new EditGUIValueNumber("Limit", plugin.getGui().getChestShopIdentifierLimit(identifier)) {
|
||||
new EditGUIValueNumber("Limit", plugin.getShopFile().getShopIdentifierLimit(identifier)) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
@@ -86,7 +86,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
}));
|
||||
|
||||
// display item
|
||||
ConfigurationSection displayItemData = plugin.getGui().getChestShopIdentifierSection(identifier);
|
||||
ConfigurationSection displayItemData = plugin.getShopFile().getShopIdentifierSection(identifier);
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(displayItemData.getString("Material")).setAmount(1),
|
||||
new EditGUIValueString("Material", displayItemData.getString("Material")) {
|
||||
|
||||
@@ -141,7 +141,7 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("CHEST.Shop." + identifier + ".Rewards"));
|
||||
plugin.getRewardHandler().getDirectlyDefined("Shop." + identifier + ".Rewards"));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -156,8 +156,8 @@ public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
}
|
||||
|
||||
private void setPathData(String path, Object value) {
|
||||
plugin.getGui().getData().set("CHEST.Shop." + identifier + "." + path, value);
|
||||
plugin.getGui().saveData();
|
||||
plugin.getShopFile().getData().set("Shop." + identifier + "." + path, value);
|
||||
plugin.getShopFile().saveData();
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
+3
-4
@@ -42,9 +42,9 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
BInventory inv = new BInventory("Edit VoteShop Remove Item");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier))
|
||||
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))
|
||||
.addLoreLine("&c&lClick to remove")) {
|
||||
|
||||
@Override
|
||||
@@ -54,7 +54,7 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getGui().removeShop(identifier);
|
||||
plugin.getShopFile().removeShop(identifier);
|
||||
p.sendMessage("Removed " + identifier);
|
||||
plugin.reload();
|
||||
}
|
||||
@@ -65,7 +65,6 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
}
|
||||
+2
-2
@@ -41,9 +41,9 @@ public class AdminVoteVoteShopItems extends GUIHandler {
|
||||
BInventory inv = new BInventory("Edit VoteShop Items");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteShop");
|
||||
|
||||
for (String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
for (String identifier : plugin.getShopFile().getShopIdentifiers()) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier))) {
|
||||
new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
+6
-5
@@ -12,8 +12,9 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -30,20 +31,20 @@ public class VoteBest extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteBestTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteBestLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("HighestDailyTotal", "" + user.getHighestDailyTotal());
|
||||
placeholders.put("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal());
|
||||
placeholders.put("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal());
|
||||
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
|
||||
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
+26
-19
@@ -12,10 +12,10 @@ 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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -39,19 +39,19 @@ public class VoteGUI extends GUIHandler {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteGUISlotSection(slot));
|
||||
|
||||
String[] lore = new String[1];
|
||||
lore = ArrayUtils.getInstance().convert(plugin.getGui().getChestVoteGUISlotLore(slot));
|
||||
lore = ArrayUtils.convert(plugin.getGui().getChestVoteGUISlotLore(slot));
|
||||
|
||||
String str = plugin.getConfigFile().getVoteTopDefault();
|
||||
if (lore.length == 0) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(slot, "url")) {
|
||||
if (MessageAPI.startsWithIgnoreCase(slot, "url")) {
|
||||
lore = new String[] { "&aClick me" };
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "next")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteNext(plugin, player, user).getChat(player));
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "last")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteLast(plugin, player, user).getChat(player));
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "total")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteTotal(plugin, player, user).getChat(player));
|
||||
} else if (StringParser.getInstance().startsWithIgnoreCase(slot, "top")) {
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "next")) {
|
||||
lore = ArrayUtils.convert(new VoteNext(plugin, player, user).getChat(player));
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "last")) {
|
||||
lore = ArrayUtils.convert(new VoteLast(plugin, player, user).getChat(player));
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "total")) {
|
||||
lore = ArrayUtils.convert(new VoteTotal(plugin, player, user).getChat(player));
|
||||
} else if (MessageAPI.startsWithIgnoreCase(slot, "top")) {
|
||||
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterMonthly(1);
|
||||
@@ -64,18 +64,18 @@ public class VoteGUI extends GUIHandler {
|
||||
}
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
String[] today = new VoteToday(plugin, player, user, 1).voteTodayGUI();
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
if (today.length > 0) {
|
||||
for (int i = today.length - 1; i < today.length && list.size() < 10 && i >= 0; i--) {
|
||||
list.add(today[i]);
|
||||
}
|
||||
}
|
||||
lore = ArrayUtils.getInstance().convert(list);
|
||||
lore = ArrayUtils.convert(list);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
lore = new String[] { "Click to view help" };
|
||||
}
|
||||
}
|
||||
builder.setLore(ArrayUtils.getInstance().convert(lore));
|
||||
builder.setLore(ArrayUtils.convert(lore));
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,8 @@ public class VoteGUI extends GUIHandler {
|
||||
String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
|
||||
if (cmd.equalsIgnoreCase("none")) {
|
||||
return;
|
||||
} else if (!cmd.equals("")) {
|
||||
}
|
||||
if (!cmd.equals("")) {
|
||||
event.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -162,13 +163,19 @@ public class VoteGUI extends GUIHandler {
|
||||
} else {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, slot);
|
||||
}
|
||||
String prefix = "";
|
||||
if (event.getButton().getBuilder().isConditional()) {
|
||||
prefix = "Item.";
|
||||
}
|
||||
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(), plugin.getGui()
|
||||
.getChestVoteGUISlotRewardsPath(slot, event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(plugin.getVotingPluginUserManager().getVotingPluginUser(player),
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
prefix + event.getButton().getLastRewardsPath(player)))) {
|
||||
plugin.getRewardHandler().giveReward(
|
||||
plugin.getVotingPluginUserManager().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot,
|
||||
event.getButton().getLastRewardsPath(player)),
|
||||
prefix + event.getButton().getLastRewardsPath(player)),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -10,8 +10,8 @@ import org.bukkit.entity.Player;
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
@@ -34,8 +34,8 @@ public class VoteHelp extends GUIHandler {
|
||||
}
|
||||
|
||||
public ArrayList<TextComponent> helpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class VoteHelp extends GUIHandler {
|
||||
plugin.getConfigFile().getFormatCommandsVoteHelpLine(), hoverColor));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
@@ -65,8 +65,8 @@ public class VoteHelp extends GUIHandler {
|
||||
}
|
||||
|
||||
public ArrayList<TextComponent> helpTextLegacy(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().isFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
@@ -76,7 +76,7 @@ public class VoteHelp extends GUIHandler {
|
||||
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
ArrayList<String> unsortedList = new ArrayList<>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
@@ -108,8 +108,8 @@ public class VoteHelp extends GUIHandler {
|
||||
|
||||
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
ArrayList<TextComponent> text = new ArrayList<>();
|
||||
if (NMSManager.getInstance().isVersion("1.12")) {
|
||||
text = helpTextLegacy(sender);
|
||||
} else {
|
||||
@@ -121,7 +121,7 @@ public class VoteHelp extends GUIHandler {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add(StringParser.getInstance()
|
||||
msg.add(MessageAPI
|
||||
.stringToComp(plugin.getConfigFile().getFormatCommandsVoteHelpTitle() + " " + page + "/" + maxPage));
|
||||
|
||||
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
|
||||
+16
-14
@@ -12,9 +12,10 @@ 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.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -32,20 +33,20 @@ public class VoteLast extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(StringParser.getInstance().replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(),
|
||||
"%player%", playerName));
|
||||
msg.add(MessageAPI.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(), "%player%",
|
||||
playerName));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
msg.add(user.voteCommandLastLine(voteSite));
|
||||
}
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -62,7 +63,7 @@ public class VoteLast extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteLastName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
|
||||
@@ -73,15 +74,16 @@ public class VoteLast extends GUIHandler {
|
||||
if (plugin.getGui().isChestVoteLastClickableLinks()) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(player);
|
||||
user.sendMessage(
|
||||
StringParser.getInstance()
|
||||
PlaceholderUtils
|
||||
.replacePlaceHolder(
|
||||
StringParser.getInstance().replacePlaceHolder(
|
||||
StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getGui()
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui()
|
||||
.getChestVoteURLURLText(),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"sitename", site.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
+19
-17
@@ -11,12 +11,13 @@ import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -36,23 +37,21 @@ public class VoteNext extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(StringParser.getInstance().colorize(StringParser.getInstance()
|
||||
msg.add(MessageAPI.colorize(MessageAPI
|
||||
.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteNextTitle(), "%player%", playerName)));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
|
||||
|
||||
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%info%",
|
||||
user.voteCommandNextInfo(voteSite));
|
||||
msgLine = MessageAPI.replaceIgnoreCase(msgLine, "%info%", user.voteCommandNextInfo(voteSite));
|
||||
|
||||
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%SiteName%",
|
||||
voteSite.getDisplayName());
|
||||
msg.add(StringParser.getInstance().colorize(msgLine));
|
||||
msgLine = MessageAPI.replaceIgnoreCase(msgLine, "%SiteName%", voteSite.getDisplayName());
|
||||
msg.add(MessageAPI.colorize(msgLine));
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
@@ -63,9 +62,9 @@ public class VoteNext extends GUIHandler {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
Layout nextLayout = new Layout(new ArrayList<>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
@@ -87,17 +86,20 @@ public class VoteNext extends GUIHandler {
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(siteNameDisplay)
|
||||
.setLore(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time", user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1), 1000, 1000) {
|
||||
new UpdatingBInventoryButton(plugin,
|
||||
site.getItem().setName(siteNameDisplay)
|
||||
.setLore(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteNextLine(), "time",
|
||||
user.voteCommandNextInfo(site)))
|
||||
.setAmountNone(1),
|
||||
1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
+38
-30
@@ -12,9 +12,10 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -45,8 +46,8 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (!plugin.getGui().isChestVoteShopEnabled()) {
|
||||
player.sendMessage(StringParser.getInstance().colorize(plugin.getGui().getChestVoteShopDisabled()));
|
||||
if (!plugin.getShopFile().isVoteShopEnabled()) {
|
||||
player.sendMessage(MessageAPI.colorize(plugin.getShopFile().getVoteShopDisabled()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -57,26 +58,33 @@ public class VoteShop extends GUIHandler {
|
||||
/*
|
||||
* if (!plugin.getConfigFile().isExtraVoteShopCheck()) { user.cacheAsync(); }
|
||||
*/
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
BInventory inv = new BInventory(plugin.getShopFile().getVoteShopName());
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
for (final String identifier : plugin.getShopFile().getShopIdentifiers()) {
|
||||
|
||||
String perm = plugin.getGui().getChestVoteShopPermission(identifier);
|
||||
String perm = plugin.getShopFile().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
String p = "";
|
||||
if (perm.startsWith("!")) {
|
||||
hasPerm = !player.hasPermission(perm.substring(1));
|
||||
p = PlaceholderUtils.replacePlaceHolders(player, perm.substring(1));
|
||||
hasPerm = !player.hasPermission(p);
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
p = PlaceholderUtils.replacePlaceHolders(player, perm);
|
||||
hasPerm = player.hasPermission(p);
|
||||
}
|
||||
if (!hasPerm) {
|
||||
plugin.extraDebug("VoteShop: " + player.getName() + "/" + player.getUniqueId()
|
||||
+ " does not have permission `" + p + "` for " + identifier);
|
||||
}
|
||||
}
|
||||
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
@@ -85,10 +93,10 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
|
||||
if ((hasPerm || !plugin.getGui().getChestVoteShopHideOnNoPermission(identifier))
|
||||
&& (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
|
||||
if (!plugin.getShopFile().getVoteShopNotBuyable(identifier)) {
|
||||
if ((hasPerm || !plugin.getShopFile().getVoteShopHideOnNoPermission(identifier))
|
||||
&& (limitPass || !plugin.getShopFile().isVoteShopHideLimitedReached())) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@@ -103,7 +111,7 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
// if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
// event.closeInventory();
|
||||
@@ -118,10 +126,10 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
|
||||
if (limitPass) {
|
||||
if (!plugin.getGui().isChestVoteShopRequireConfirmation(identifier)) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
if (!plugin.getShopFile().isVoteShopRequireConfirmation(identifier)) {
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("identifier",
|
||||
plugin.getGui().getChestShopIdentifierIdentifierName(identifier));
|
||||
plugin.getShopFile().getShopIdentifierIdentifierName(identifier));
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points, true)) {
|
||||
@@ -131,19 +139,19 @@ public class VoteShop extends GUIHandler {
|
||||
plugin.getServerData().addVoteShopPurchase(identifier);
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
|
||||
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getCHESTVoteShopPurchase(identifier),
|
||||
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getShopFile().getVoteShopPurchase(identifier),
|
||||
placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
} else {
|
||||
@@ -158,10 +166,10 @@ public class VoteShop extends GUIHandler {
|
||||
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
user.sendMessage(plugin.getShopFile().getVoteShopLimitReached());
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, identifier);
|
||||
if (plugin.getGui().isChestVoteShopReopenGUIOnPurchase()) {
|
||||
if (plugin.getShopFile().isVoteShopReopenGUIOnPurchase()) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, "shop");
|
||||
}
|
||||
}
|
||||
@@ -171,7 +179,7 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
} else {
|
||||
if (hasPerm) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getShopFile().getShopIdentifierSection(identifier));
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
@@ -184,20 +192,20 @@ public class VoteShop extends GUIHandler {
|
||||
}
|
||||
}
|
||||
|
||||
for (final String str : plugin.getGui().getChestGUIVoteShopExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIVoteShopExtraItems(str))) {
|
||||
for (final String str : plugin.getShopFile().getVoteShopExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getGUIVoteShopExtraItems(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))
|
||||
new RewardBuilder(plugin.getShopFile().getData(),
|
||||
"ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteShopBackButton()) {
|
||||
if (plugin.getShopFile().isVoteShopBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
+16
-16
@@ -12,9 +12,9 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.simpleapi.player.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -46,17 +46,17 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "ident", identifier);
|
||||
BInventory inv = new BInventory(plugin.getShopFile().getShopConfirmPurchaseTitle());
|
||||
inv.dontClose();
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseYesItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.cache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
int points = plugin.getShopFile().getShopIdentifierCost(identifier);
|
||||
int limit = plugin.getShopFile().getShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
@@ -67,20 +67,20 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
plugin.getServerData().addVoteShopPurchase(identifier);
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getShopFile().getData(),
|
||||
plugin.getShopFile().getShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
|
||||
user.sendMessage(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getShopFile().getVoteShopPurchase(identifier), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringParser.getInstance()
|
||||
user.sendMessage(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
if (plugin.getShopFile().getVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
@@ -88,11 +88,11 @@ public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseNoItem())) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseNoItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
if (plugin.getShopFile().getVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
+6
-5
@@ -12,8 +12,9 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@@ -31,11 +32,11 @@ public class VoteStreak extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteStreakTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteStreakLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("DailyStreak", "" + user.getDayVoteStreak());
|
||||
placeholders.put("WeeklyStreak", "" + user.getWeekVoteStreak());
|
||||
placeholders.put("MonthlyStreak", "" + user.getMonthVoteStreak());
|
||||
@@ -46,9 +47,9 @@ public class VoteStreak extends GUIHandler {
|
||||
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
|
||||
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
+26
-23
@@ -16,10 +16,10 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -44,7 +44,7 @@ public class VoteToday extends GUIHandler {
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
String[] voteToday = voteToday();
|
||||
|
||||
int maxPage = voteToday.length / pagesize;
|
||||
@@ -52,7 +52,7 @@ public class VoteToday extends GUIHandler {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("page", "" + page);
|
||||
placeholders.put("maxpage", "" + maxPage);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class VoteToday extends GUIHandler {
|
||||
msg.add(voteToday[i]);
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().colorize(ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders));
|
||||
return ArrayUtils.colorize(PlaceholderUtils.replacePlaceHolder(msg, placeholders));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,18 +91,18 @@ public class VoteToday extends GUIHandler {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
String msg = plugin.getGui().getChestVoteTodayLine();
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("VoteSite", voteSite.getDisplayName());
|
||||
placeholders.put("Time", timeString);
|
||||
msg = StringParser.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
|
||||
ItemBuilder item = null;
|
||||
if (plugin.getGui().isChestVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
|
||||
item = new ItemBuilder(user.getPlayerHead());
|
||||
} else {
|
||||
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
|
||||
}
|
||||
item.setName(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
|
||||
"player", user.getPlayerName()));
|
||||
item.setName(PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(), "player",
|
||||
user.getPlayerName()));
|
||||
item.setLore(msg);
|
||||
final UUID uuid = user.getUuid();
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
|
||||
@@ -116,7 +116,7 @@ public class VoteToday extends GUIHandler {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String guiPath = "VoteToday";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
@@ -130,6 +130,7 @@ public class VoteToday extends GUIHandler {
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@@ -145,28 +146,29 @@ public class VoteToday extends GUIHandler {
|
||||
}
|
||||
|
||||
public String[] voteToday() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", voteSite.getKey());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
|
||||
// timeString);
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
return ArrayUtils.convert(msg);
|
||||
}
|
||||
|
||||
public String[] voteTodayGUI() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
LocalDateTime mostRecent = null;
|
||||
@@ -180,16 +182,17 @@ public class VoteToday extends GUIHandler {
|
||||
if (mostRecent != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = mostRecent.format(formatter);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", mostRecentSite.getKey());
|
||||
placeholders.put("sitename", mostRecentSite.getDisplayName());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
return ArrayUtils.convert(msg);
|
||||
}
|
||||
|
||||
}
|
||||
+8
-8
@@ -20,8 +20,8 @@ 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.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
@@ -46,17 +46,17 @@ public class VoteTopVoter extends GUIHandler {
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterAllTime(page));
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterAllTime(page));
|
||||
case Daily:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterDaily(page));
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterDaily(page));
|
||||
case Monthly:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterMonthly(page));
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterMonthly(page));
|
||||
case Weekly:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterWeekly(page));
|
||||
return ArrayUtils.convert(plugin.getTopVoterHandler().topVoterWeekly(page));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +85,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
ConfigurationSection customization = plugin.getGui().getChestVoteTopCustomization();
|
||||
boolean customzationEnabled = false;
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<Integer>();
|
||||
Queue<Integer> playerSlots = new ConcurrentLinkedQueue<>();
|
||||
if (customization != null) {
|
||||
customzationEnabled = customization.getBoolean("Enabled");
|
||||
List<Integer> customizationPlayerSlots = customization.getIntegerList("PlayerSlots");
|
||||
@@ -109,7 +109,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
BInventoryButton button = new BInventoryButton(playerItem
|
||||
.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
+1
-1
@@ -65,7 +65,7 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
+149
@@ -0,0 +1,149 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.time.YearMonth;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
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.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class VoteTopVoterPreviousMonths extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
private int index = -1;
|
||||
|
||||
public VoteTopVoterPreviousMonths(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int index) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void next(int index) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
Set<YearMonth> months = plugin.getPreviousMonthsTopVoters().keySet();
|
||||
|
||||
List<YearMonth> yearMonthList = months.stream().sorted(Collections.reverseOrder()).collect(Collectors.toList());
|
||||
YearMonth yearMonth = null;
|
||||
|
||||
if (index < 0) {
|
||||
if (!yearMonthList.isEmpty()) {
|
||||
yearMonth = yearMonthList.get(0);
|
||||
}
|
||||
player.sendMessage(Component.text("Can't open previous months, no data", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
if (yearMonthList.size() <= index) {
|
||||
player.sendMessage(
|
||||
Component.text("Can't open previous months, no data for requested index", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
yearMonth = yearMonthList.get(index);
|
||||
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = null;
|
||||
if (!plugin.getPreviousMonthsTopVoters().containsKey(yearMonth)) {
|
||||
player.sendMessage(Component.text("Can't open previous months, no data", NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
users = plugin.getPreviousMonthsTopVoters().get(yearMonth).entrySet();
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", yearMonth.toString());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<>());
|
||||
|
||||
inv.addButton(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) {
|
||||
TopVoterPlayer user = (TopVoterPlayer) getData("User");
|
||||
new VoteGUI(plugin, player, user.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem())
|
||||
.addPlaceholder("Top", yearMonth.toString())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoterPreviousMonths(plugin, player, user, index + 1).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoterPreviousMonths(plugin, player, user, index - 1).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
+10
-10
@@ -8,13 +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.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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
@@ -32,7 +32,7 @@ public class VoteTotal extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
|
||||
int daily = user.getTotal(TopVoter.Daily);
|
||||
int weekly = user.getTotal(TopVoter.Weekly);
|
||||
@@ -40,15 +40,15 @@ public class VoteTotal extends GUIHandler {
|
||||
int all = user.getTotal(TopVoter.AllTime);
|
||||
|
||||
for (String s : plugin.getConfigFile().getFormatCommandsVoteTotal()) {
|
||||
String str = StringParser.getInstance().replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%player%", user.getPlayerName());
|
||||
String str = MessageAPI.replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
|
||||
str = MessageAPI.replaceIgnoreCase(str, "%player%", user.getPlayerName());
|
||||
msg.add(str);
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
+136
-88
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
import com.bencodez.advancedcore.api.bookgui.Layout;
|
||||
@@ -18,9 +19,9 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.MessageBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
@@ -50,8 +51,12 @@ public class VoteURL extends GUIHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return getChat(sender, false);
|
||||
}
|
||||
|
||||
public ArrayList<String> getChat(CommandSender sender, boolean bypassCanVote) {
|
||||
ArrayList<String> sites = new ArrayList<>();
|
||||
|
||||
List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
|
||||
if (title != null) {
|
||||
@@ -59,32 +64,41 @@ public class VoteURL extends GUIHandler {
|
||||
}
|
||||
if (plugin.getConfigFile().isFormatCommandsVoteAutoInputSites()) {
|
||||
int counter = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
counter++;
|
||||
String voteURL = voteSite.getVoteURL(json);
|
||||
MessageBuilder message = new MessageBuilder(plugin.getConfigFile().getFormatCommandsVoteURLS());
|
||||
message.replacePlaceholder("num", Integer.toString(counter)).replacePlaceholder("url", voteURL)
|
||||
.replacePlaceholder("SiteName", voteSite.getDisplayName());
|
||||
if (user != null && user.getPlayerName() != null) {
|
||||
message.replacePlaceholder("player", "" + user.getPlayerName()).replacePlaceholder("Next",
|
||||
"" + user.voteCommandNextInfo(voteSite));
|
||||
if (voteSite.getPermissionToView().isEmpty()
|
||||
|| sender.hasPermission(voteSite.getPermissionToView())) {
|
||||
if (!plugin.getConfigFile().isFormatCommandsVoteOnlyShowSitesToVote()
|
||||
|| user.canVoteSite(voteSite) || bypassCanVote) {
|
||||
counter++;
|
||||
String voteURL = voteSite.getVoteURL(json);
|
||||
MessageBuilder message = new MessageBuilder(
|
||||
plugin.getConfigFile().getFormatCommandsVoteURLS());
|
||||
message.replacePlaceholder("num", Integer.toString(counter))
|
||||
.replacePlaceholder("url", voteURL)
|
||||
.replacePlaceholder("SiteName", voteSite.getDisplayName());
|
||||
if (user != null && user.getPlayerName() != null) {
|
||||
message.replacePlaceholder("player", "" + user.getPlayerName())
|
||||
.replacePlaceholder("Next", "" + user.voteCommandNextInfo(voteSite));
|
||||
}
|
||||
|
||||
sites.add(message.colorize().getText());
|
||||
}
|
||||
}
|
||||
sites.add(message.colorize().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (user != null) {
|
||||
HashMap<String, String> phs = new HashMap<String, String>();
|
||||
HashMap<String, String> phs = new HashMap<>();
|
||||
phs.put("DailyTotal", "" + user.getTotal(TopVoter.Daily));
|
||||
phs.put("WeekTotal", "" + user.getTotal(TopVoter.Weekly));
|
||||
phs.put("MonthTotal", "" + user.getTotal(TopVoter.Monthly));
|
||||
phs.put("Total", "" + user.getTotal(TopVoter.AllTime));
|
||||
|
||||
sites = ArrayUtils.getInstance().replacePlaceHolder(sites, phs);
|
||||
sites = PlaceholderUtils.replacePlaceHolder(sites, phs);
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().colorize(sites);
|
||||
return ArrayUtils.colorize(sites);
|
||||
}
|
||||
|
||||
private ItemBuilder getItemAll() {
|
||||
@@ -117,13 +131,16 @@ public class VoteURL extends GUIHandler {
|
||||
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteItemSection());
|
||||
builder.setName(
|
||||
plugin.getGui().getChestVoteURLGUISiteNameCanVote().replace("%Name%", voteSite.getDisplayName()));
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteNameCanVote());
|
||||
} else {
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteName().replace("%Name%", voteSite.getDisplayName()));
|
||||
builder.addLoreLine(
|
||||
plugin.getGui().getChestVoteURLNextVote().replace("%Info%", user.voteCommandNextInfo(voteSite)));
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteName());
|
||||
builder.addLoreLine(plugin.getGui().getChestVoteURLNextVote());
|
||||
}
|
||||
builder.addPlaceholder("ServiceSite", voteSite.getServiceSite());
|
||||
builder.addPlaceholder("Name", voteSite.getDisplayName());
|
||||
builder.addPlaceholder("VoteDelay", "" + voteSite.getVoteDelay());
|
||||
builder.addPlaceholder("VoteHour", "" + voteSite.getVoteDelayDailyHour());
|
||||
builder.addPlaceholder("Info", user.voteCommandNextInfo(voteSite));
|
||||
|
||||
return builder;
|
||||
}
|
||||
@@ -137,21 +154,26 @@ public class VoteURL extends GUIHandler {
|
||||
book.addLayout(layout);
|
||||
}
|
||||
int i = 1;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
|
||||
site.getDisplayName());
|
||||
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
|
||||
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
|
||||
if (user.canVoteSite(site)) {
|
||||
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
|
||||
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
if (site.getPermissionToView().isEmpty() || player.hasPermission(site.getPermissionToView())) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout())
|
||||
.addPlaceholder("sitename", site.getDisplayName()).addPlaceholder("num", "" + i);
|
||||
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
|
||||
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
|
||||
if (user.canVoteSite(site)) {
|
||||
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
|
||||
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
|
||||
}
|
||||
String url = PlaceholderUtils.replacePlaceHolder(PlaceholderUtils.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++;
|
||||
}
|
||||
}
|
||||
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);
|
||||
@@ -164,60 +186,11 @@ public class VoteURL extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
// normal GUI
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLName());
|
||||
if (plugin.getGui().isChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builderAll, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
|
||||
json = true;
|
||||
user.sendMessage(getChat(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
ItemBuilder builder = getItemVoteSite(voteSite);
|
||||
if (startSlot >= 0) {
|
||||
builder.setSlot(startSlot);
|
||||
startSlot++;
|
||||
}
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
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", voteSite.getVoteURL()),
|
||||
"sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemVoteSite(voteSite);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
for (final String str : plugin.getGui().getChestVoteURLExtraItems()) {
|
||||
@@ -233,6 +206,81 @@ public class VoteURL extends GUIHandler {
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builderAll, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.closeInventory();
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(event.getPlayer());
|
||||
json = true;
|
||||
if (event.getClick().equals(ClickType.SHIFT_LEFT)
|
||||
|| event.getClick().equals(ClickType.SHIFT_RIGHT)) {
|
||||
user.sendMessage(getChat(player, true));
|
||||
} else {
|
||||
user.sendMessage(getChat(player, false));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int startSlot = plugin.getGui().getChestVoteURLAllUrlsButtonStartSlot();
|
||||
for (final VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
if (voteSite.getPermissionToView().isEmpty() || player.hasPermission(voteSite.getPermissionToView())) {
|
||||
ItemBuilder builder = getItemVoteSite(voteSite);
|
||||
if (startSlot >= 0) {
|
||||
if (inv.isSlotTaken(startSlot)) {
|
||||
boolean found = false;
|
||||
while (!found) {
|
||||
startSlot++;
|
||||
if (!inv.isSlotTaken(startSlot)) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
builder.setSlot(startSlot);
|
||||
startSlot++;
|
||||
}
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(plugin, builder, 5000, 5000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.closeInventory();
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
HashMap<String, String> placeholders = new HashMap<>();
|
||||
placeholders.put("voteurl", voteSite.getVoteURL());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("player", player.getName());
|
||||
placeholders.put("servicesite", voteSite.getServiceSite());
|
||||
placeholders.put("VoteDelay", "" + voteSite.getVoteDelay());
|
||||
placeholders.put("VoteHour", "" + voteSite.getVoteDelayDailyHour());
|
||||
user.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemVoteSite(voteSite);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
File renamed without changes.
+7
-7
@@ -10,8 +10,8 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.command.AdvancedCoreTabCompleteHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
@@ -32,15 +32,15 @@ public class AdminVoteTabCompleter implements TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
List<String> tab = new ArrayList<String>();
|
||||
List<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(),
|
||||
sender, args, args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
+9
-9
@@ -12,9 +12,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.command.TabCompleteHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
@@ -39,19 +39,19 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] argsIn) {
|
||||
ArrayList<String> msgArray = new ArrayList<String>();
|
||||
ArrayList<String> msgArray = new ArrayList<>();
|
||||
msgArray.add("");
|
||||
for (String arg : argsIn) {
|
||||
msgArray.add(arg);
|
||||
}
|
||||
|
||||
String[] args = ArrayUtils.getInstance().convert(msgArray);
|
||||
String[] args = ArrayUtils.convert(msgArray);
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
ArrayList<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<>();
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.getAdminVoteCommand());
|
||||
@@ -88,7 +88,7 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
}
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -10,8 +10,8 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.command.AdvancedCoreTabCompleteHandler;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -33,15 +33,15 @@ public class VoteTabCompleter implements TabCompleter {
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
ArrayList<String> tab = new ArrayList<>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
Set<String> cmds = new HashSet<>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
cmds.addAll(AdvancedCoreTabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender,
|
||||
args, args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
if (MessageAPI.startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
+39
-7
@@ -3,12 +3,12 @@ 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.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -39,6 +39,18 @@ public class BungeeSettings extends YMLFile {
|
||||
@Getter
|
||||
private String RedisUsername = "";
|
||||
|
||||
@ConfigDataString(path = "PluginMessageChannel")
|
||||
@Getter
|
||||
private String pluginMessagingChannel = "vp:vp";
|
||||
|
||||
@ConfigDataBoolean(path = "PluginMessageEncryption")
|
||||
@Getter
|
||||
private boolean pluginMessageEncryption = false;
|
||||
|
||||
@ConfigDataString(path = "Redis.Prefix")
|
||||
@Getter
|
||||
private String RedisPrefix = "";
|
||||
|
||||
@ConfigDataString(path = "Redis.Password")
|
||||
@Getter
|
||||
private String RedisPassword = "";
|
||||
@@ -46,6 +58,26 @@ public class BungeeSettings extends YMLFile {
|
||||
@ConfigDataInt(path = "Redis.Port")
|
||||
@Getter
|
||||
private int RedisPort = 6379;
|
||||
|
||||
@ConfigDataString(path = "MQTT.ClientID")
|
||||
@Getter
|
||||
private String mqttClientID = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.BrokerURL")
|
||||
@Getter
|
||||
private String mqttBrokerURL = "tcp://localhost:1883";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Username")
|
||||
@Getter
|
||||
private String mqttUsername = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Password")
|
||||
@Getter
|
||||
private String mqttPassword = "";
|
||||
|
||||
@ConfigDataString(path = "MQTT.Prefix")
|
||||
@Getter
|
||||
private String mqttPrefix = "";
|
||||
|
||||
@ConfigDataString(path = "BungeeServer.Host")
|
||||
@Getter
|
||||
@@ -113,7 +145,7 @@ public class BungeeSettings extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "BungeeVotePartyGlobalCommands")
|
||||
@Getter
|
||||
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<String>();
|
||||
private ArrayList<String> bungeeVotePartyGlobalCommands = new ArrayList<>();
|
||||
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
+298
-146
@@ -7,14 +7,15 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataLong;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.placeholders.PlaceholderCacheLevel;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
@@ -39,14 +40,26 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean addTotalsOffline = true;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadInteralExpansion")
|
||||
@Getter
|
||||
private boolean loadInteralExpansion = true;
|
||||
|
||||
@ConfigDataBoolean(path = "PerSiteCoolDownEvents")
|
||||
@Getter
|
||||
private boolean perSiteCoolDownEvents = false;
|
||||
|
||||
@ConfigDataInt(path = "LimitVotePoints")
|
||||
@Getter
|
||||
private int limitVotePoints = -1;
|
||||
|
||||
@ConfigDataBoolean(path = "QueueVotesDuringTimeChange")
|
||||
@Getter
|
||||
private boolean queueVotesDuringTimeChange = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AdvancedServiceSiteHandling")
|
||||
@Getter
|
||||
private boolean advancedServiceSiteHandling = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
@@ -55,6 +68,134 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean preloadSkulls = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVEnabled = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.AllTime.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterAllTimeEnabled = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.AllTime.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterAllTimeChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.AllTime.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterAllTimeTitle = "All Time Top Voters";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.AllTime.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterAllTimeRankDisplay = "%rank%: &6%player% - %votes% Votes";
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Monthly.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterMonthlyEnabled = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.Monthly.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterMonthlyChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Monthly.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterMonthlyTitle = "Top Voters of the Month";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Monthly.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterMonthlyRankDisplay = "%rank%: &6%player% - %votes% Votes";
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Weekly.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterWeeklyEnabled = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.Weekly.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterWeeklyChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Weekly.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterWeeklyTitle = "Top Voters of the Week";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Weekly.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterWeeklyRankDisplay = "%rank%: &6%player% - %votes% Votes";
|
||||
|
||||
@ConfigDataBoolean(path = "DiscordSRV.TopVoter.Daily.Enabled")
|
||||
@Getter
|
||||
private boolean discordSRVTopVoterDailyEnabled = false;
|
||||
|
||||
@ConfigDataLong(path = "DiscordSRV.TopVoter.Daily.Channel")
|
||||
@Getter
|
||||
private long discordSRVTopVoterDailyChannel = 0;
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Daily.Title")
|
||||
@Getter
|
||||
private String discordSRVTopVoterDailyTitle = "Top Voters of the Day";
|
||||
|
||||
@ConfigDataString(path = "DiscordSRV.TopVoter.Daily.RankDisplay")
|
||||
@Getter
|
||||
private String discordSRVTopVoterDailyRankDisplay = "%rank%: &6%player% - %votes% Votes";
|
||||
|
||||
public boolean isDiscordSRVTopVoterEnabled(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return isDiscordSRVTopVoterAllTimeEnabled();
|
||||
case Monthly:
|
||||
return isDiscordSRVTopVoterMonthlyEnabled();
|
||||
case Weekly:
|
||||
return isDiscordSRVTopVoterWeeklyEnabled();
|
||||
case Daily:
|
||||
return isDiscordSRVTopVoterDailyEnabled();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public long getDiscordSRVTopVoterChannel(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return getDiscordSRVTopVoterAllTimeChannel();
|
||||
case Monthly:
|
||||
return getDiscordSRVTopVoterMonthlyChannel();
|
||||
case Weekly:
|
||||
return getDiscordSRVTopVoterWeeklyChannel();
|
||||
case Daily:
|
||||
return getDiscordSRVTopVoterDailyChannel();
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public String getDiscordSRVTopVoterTitle(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return getDiscordSRVTopVoterAllTimeTitle();
|
||||
case Monthly:
|
||||
return getDiscordSRVTopVoterMonthlyTitle();
|
||||
case Weekly:
|
||||
return getDiscordSRVTopVoterWeeklyTitle();
|
||||
case Daily:
|
||||
return getDiscordSRVTopVoterDailyTitle();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getDiscordSRVTopVoterRankDisplay(TopVoter topVoter) {
|
||||
switch (topVoter) {
|
||||
case AllTime:
|
||||
return getDiscordSRVTopVoterAllTimeRankDisplay();
|
||||
case Monthly:
|
||||
return getDiscordSRVTopVoterMonthlyRankDisplay();
|
||||
case Weekly:
|
||||
return getDiscordSRVTopVoterWeeklyRankDisplay();
|
||||
case Daily:
|
||||
return getDiscordSRVTopVoterDailyRankDisplay();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
@@ -103,21 +244,25 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableActionBar")
|
||||
@Getter
|
||||
private boolean disableActionBar = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableCoolDownCheck")
|
||||
@Getter
|
||||
private boolean disableCoolDownCheck = false;
|
||||
|
||||
@ConfigDataListString(path = "DisabledCommands")
|
||||
@Getter
|
||||
private ArrayList<String> disabledCommands = new ArrayList<String>();
|
||||
private ArrayList<String> disabledCommands = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "DisabledDefaultPermissions")
|
||||
@Getter
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<String>();
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "CachedPlaceholders")
|
||||
@Getter
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<String>();
|
||||
private ArrayList<String> cachedPlaceholders = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "DisableInteractEvent")
|
||||
@Getter
|
||||
@@ -165,7 +310,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteForceLinks = true;
|
||||
private boolean formatCommandsVoteForceLinks = false;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.LastVoted")
|
||||
@Getter
|
||||
@@ -213,7 +358,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "Format.Commands.Vote.Today.Title")
|
||||
@Getter
|
||||
private ArrayList<String> formatCommandsVoteTodayTitle = ArrayUtils.getInstance()
|
||||
private ArrayList<String> formatCommandsVoteTodayTitle = ArrayUtils
|
||||
.convert(new String[] { "&cToday's Votes %page%/%maxpage%", "&cPlayerName : VoteSite : Time" });
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Disabled")
|
||||
@@ -325,45 +470,15 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "VotingBroadcastBlacklist")
|
||||
@Getter
|
||||
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<String>();
|
||||
|
||||
public Config(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the black list.
|
||||
*
|
||||
* @return the black list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getBlackList() {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
|
||||
}
|
||||
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<>();
|
||||
|
||||
@ConfigDataKeys(path = "CustomCommands")
|
||||
@Getter
|
||||
private Set<String> customCommands = new HashSet<String>();
|
||||
private Set<String> customCommands = new HashSet<>();
|
||||
|
||||
@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);
|
||||
}
|
||||
private Set<String> customPlaceholderReturns = new HashSet<>();
|
||||
|
||||
@ConfigDataString(path = "Format.BroadcastMsg")
|
||||
@Getter
|
||||
@@ -377,9 +492,13 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean formatCommandsVoteAutoInputSites = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.OnlyShowSitesToVote")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteOnlyShowSitesToVote = false;
|
||||
|
||||
@ConfigDataListString(path = "Format.Commands.Vote.Best.Lines")
|
||||
@Getter
|
||||
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<String>();
|
||||
private ArrayList<String> formatCommandsVoteBestLines = new ArrayList<>();
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Best.Title")
|
||||
@Getter
|
||||
@@ -425,10 +544,6 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String placeholderCacheLevelString = "AUTO";
|
||||
|
||||
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
|
||||
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Next.Layout")
|
||||
@Getter
|
||||
private String formatCommandsVoteNextLayout = "&3%SiteName%: &6%info%";
|
||||
@@ -437,69 +552,10 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private String formatCommandsVoteNextTitle = "&3&l%player% Next Votes:";
|
||||
|
||||
/**
|
||||
* Gets the commands vote party.
|
||||
*
|
||||
* @return the commands vote party
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteParty() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteStreakLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Streak.Title")
|
||||
@Getter
|
||||
private String formatCommandsVoteStreakTitle = "&3&l%player% Vote Streak";
|
||||
|
||||
/**
|
||||
* Gets the commands vote text.
|
||||
*
|
||||
* @return the commands vote text
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteText() {
|
||||
ArrayList<String> str = new ArrayList<String>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotal() {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total",
|
||||
new ArrayList<String>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&l%player% Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotalAll() {
|
||||
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
|
||||
new ArrayList<String>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&lServer Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Sites")
|
||||
@Getter
|
||||
private String formatCommandsVoteURLS = "&4%num%: &c&l%SiteName% - &c%url%";
|
||||
@@ -551,9 +607,11 @@ public class Config extends YMLFile {
|
||||
@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";
|
||||
@@ -593,40 +651,13 @@ public class Config extends YMLFile {
|
||||
@ConfigDataString(path = "Format.InvalidCommand.Vote")
|
||||
@Getter
|
||||
private String formatInvalidCommandVote = "&4No valid arguments, see /vote help!";
|
||||
|
||||
@ConfigDataString(path = "Format.InvalidCommand.AdminVote")
|
||||
@Getter
|
||||
private String formatInvalidCommandAdminVote = "&4No valid arguments, see /adminvote help!";
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
*
|
||||
* @return the vote help
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatVoteHelp() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "GiveDefaultPermission")
|
||||
@Getter
|
||||
private boolean giveDefaultPermission = true;
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return isLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return isLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return isLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return isLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "LoadTopVoter.AllTime")
|
||||
@Getter
|
||||
private boolean loadTopVoterAllTime = true;
|
||||
@@ -647,13 +678,17 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private int pointsOnVote = 1;
|
||||
|
||||
@ConfigDataInt(path = "PurgeMin")
|
||||
@ConfigDataBoolean(path = "PurgeNoDataOnStartup")
|
||||
@Getter
|
||||
private int purgeMin = 90;
|
||||
private boolean purgeNoDataOnStartup = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PurgeOldData")
|
||||
@ConfigDataBoolean(path = "StoreMonthTotalsWithDate")
|
||||
@Getter
|
||||
private boolean purgeOldData = false;
|
||||
private boolean storeMonthTotalsWithDate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseMonthDateTotalsAsPrimaryTotal")
|
||||
@Getter
|
||||
private boolean useMonthDateTotalsAsPrimaryTotal = false;
|
||||
|
||||
@ConfigDataString(path = "RequestAPI.DefaultMethod")
|
||||
@Getter
|
||||
@@ -661,7 +696,7 @@ public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "RequestAPI.DisabledMethods")
|
||||
@Getter
|
||||
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<String>();
|
||||
private ArrayList<String> requestAPIDisabledMethods = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "StoreTopVoters.Daily")
|
||||
@Getter
|
||||
@@ -695,6 +730,127 @@ public class Config extends YMLFile {
|
||||
@Getter
|
||||
private boolean voteRemindingRemindOnlyOnce = false;
|
||||
|
||||
@ConfigDataString(path = "VoteTopDefault")
|
||||
@Getter
|
||||
private String voteTopDefault = "Monthly";
|
||||
|
||||
public Config(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the black list.
|
||||
*
|
||||
* @return the black list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getBlackList() {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<>());
|
||||
}
|
||||
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
|
||||
public Set<String> getCustomPlaceholderReturns(String placeholder) {
|
||||
Set<String> str = getData().getConfigurationSection("CustomPlaceholderReturns." + placeholder).getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getCustomPlaceholderReturns(String placeholder, String returnString) {
|
||||
return getData().getString("CustomPlaceholderReturns." + placeholder + "." + returnString, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote party.
|
||||
*
|
||||
* @return the commands vote party
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteParty() {
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteStreakLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote text.
|
||||
*
|
||||
* @return the commands vote text
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteText() {
|
||||
ArrayList<String> str = new ArrayList<>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotal() {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total", new ArrayList<>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&l%player% Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotalAll() {
|
||||
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
|
||||
new ArrayList<>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&lServer Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
*
|
||||
* @return the vote help
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatVoteHelp() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<>());
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return isLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return isLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return isLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return isLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public PlaceholderCacheLevel getPlaceholderCacheLevel() {
|
||||
return PlaceholderCacheLevel.getCache(getPlaceholderCacheLevelString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
@@ -704,10 +860,6 @@ public class Config extends YMLFile {
|
||||
return "VoteReminding.Rewards";
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "VoteTopDefault")
|
||||
@Getter
|
||||
private String voteTopDefault = "Monthly";
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
+20
-17
@@ -7,16 +7,15 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
|
||||
@@ -41,14 +40,14 @@ public class ConfigVoteSites extends YMLFile {
|
||||
public void generateVoteSite(String siteName) {
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
siteName = siteName.replace(".", "_").replace(" ", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName + " does not exist with the servicesite '" + org
|
||||
+ "', creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
setEnabled(siteName, true);
|
||||
setServiceSite(siteName, org);
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
setVoteDelay(siteName, 24);
|
||||
set(siteName, "DisplayItem.Material", "GRASS");
|
||||
set(siteName, "DisplayItem.Material", "STONE");
|
||||
set(siteName, "DisplayItem.Amount", 1);
|
||||
set(siteName, "Rewards.Messages.Player", "&aThanks for voting on %ServiceSite%!");
|
||||
|
||||
@@ -103,8 +102,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission("VotingPlugin.Admin.GenerateServiceSite") || p.isOp()) {
|
||||
p.sendMessage(StringParser.getInstance().colorize("&cGenerating votesite for service site "
|
||||
+ siteName + ", please check console for details"));
|
||||
p.sendMessage(MessageAPI.colorize("&cGenerating votesite for service site " + siteName
|
||||
+ ", please check console for details"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,6 +137,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(site).getConfigurationSection("Item");
|
||||
}
|
||||
|
||||
public String getPermissionToView(String siteName) {
|
||||
return getData(siteName).getString("PermissionToView", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
@@ -168,10 +171,6 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
public int getVoteDelayDailyHour(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayDailyHour", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
@@ -182,6 +181,10 @@ public class ConfigVoteSites extends YMLFile {
|
||||
return getData(siteName).getDouble("VoteDelay", 24);
|
||||
}
|
||||
|
||||
public int getVoteDelayDailyHour(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayDailyHour", 0);
|
||||
}
|
||||
|
||||
public double getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getDouble("VoteDelayMin", 0);
|
||||
}
|
||||
@@ -209,7 +212,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(ChatColor.RED + "Could not create VoteSites/" + siteName + ".yml!");
|
||||
plugin.getLogger().severe("Could not create VoteSites/" + siteName + ".yml!");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -239,7 +242,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return the vote sites load
|
||||
*/
|
||||
public ArrayList<VoteSite> getVoteSitesLoad() {
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<>();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames(true);
|
||||
if (voteSiteNames != null) {
|
||||
for (String site : voteSiteNames) {
|
||||
@@ -276,9 +279,9 @@ public class ConfigVoteSites extends YMLFile {
|
||||
}
|
||||
|
||||
public ArrayList<String> getVoteSitesNames(boolean checkEnabled) {
|
||||
ArrayList<String> siteNames = new ArrayList<String>();
|
||||
ArrayList<String> siteNames = new ArrayList<>();
|
||||
if (getData().isConfigurationSection("VoteSites")) {
|
||||
siteNames = ArrayUtils.getInstance().convert(getData().getConfigurationSection("VoteSites").getKeys(false));
|
||||
siteNames = ArrayUtils.convert(getData().getConfigurationSection("VoteSites").getKeys(false));
|
||||
}
|
||||
|
||||
for (int i = siteNames.size() - 1; i >= 0; i--) {
|
||||
@@ -305,7 +308,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL(String siteName) {
|
||||
return getData(siteName).getString("VoteURL");
|
||||
return getData(siteName).getString("VoteURL", "");
|
||||
}
|
||||
|
||||
public boolean getWaitUntilVoteDelay(String siteName) {
|
||||
+93
-232
@@ -7,15 +7,15 @@ import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataConfigurationSection;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
@@ -45,45 +45,17 @@ public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.Layout")
|
||||
@Getter
|
||||
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils.getInstance()
|
||||
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils
|
||||
.convert(new String[] { "&c%Sitename%", "[UrlText]" });
|
||||
|
||||
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.TopLayout")
|
||||
@Getter
|
||||
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<String>();
|
||||
private ArrayList<String> bookVoteURLBookGUITopLayout = new ArrayList<>();
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.Title")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUITitle = "&cVoteURL";
|
||||
|
||||
@Getter
|
||||
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.NoItem")
|
||||
private ConfigurationSection chestShopConfirmPurchaseNoItem;
|
||||
|
||||
@Getter
|
||||
@ConfigDataString(path = "CHEST.ShopConfirmPurchase.Title")
|
||||
private String chestShopConfirmPurchaseTitle = "Confirm Purchase?";
|
||||
|
||||
@Getter
|
||||
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.YesItem")
|
||||
private ConfigurationSection chestShopConfirmPurchaseYesItem;
|
||||
|
||||
@Getter
|
||||
@ConfigDataString(path = "CHEST.VoteShopDisabled")
|
||||
private String chestVoteShopDisabled = "&cVote shop disabled";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopHideLimitedReached")
|
||||
@Getter
|
||||
private boolean chestVoteShopHideLimitedReached = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteShopLimitReached")
|
||||
@Getter
|
||||
private String chestVoteShopLimitReached = "&aYou reached your limit";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopRequireConfirmation")
|
||||
@Getter
|
||||
private boolean chestVoteShopRequireConfirmation = false;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteBest.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteBestBackButton = true;
|
||||
@@ -162,59 +134,10 @@ public class GUI extends YMLFile {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void createShop(String value) {
|
||||
ConfigurationSection shopData = getData().createSection("CHEST.Shop." + value);
|
||||
shopData.set("Identifier_Name", value);
|
||||
shopData.set("Material", "STONE");
|
||||
shopData.set("Amount", 1);
|
||||
shopData.set("Name", "&cPlaceholder item");
|
||||
shopData.set("Cost", 1);
|
||||
shopData.set("Permission", "");
|
||||
shopData.set("CloseGUI", true);
|
||||
shopData.set("RequireConfirmation", false);
|
||||
|
||||
shopData.set("Rewards.Items.Item1.Material", "STONE");
|
||||
shopData.set("Rewards.Items.Item1.Amount", 1);
|
||||
saveData();
|
||||
}
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.BackButton")
|
||||
@Getter
|
||||
private ConfigurationSection CHESTBackButton;
|
||||
|
||||
public int getChestShopIdentifierCost(String identifier) {
|
||||
return getData().getInt("CHEST.Shop." + identifier + ".Cost");
|
||||
}
|
||||
|
||||
public String getChestShopIdentifierIdentifierName(String identifier) {
|
||||
return getData().getString("CHEST.Shop." + identifier + ".Identifier_Name", identifier);
|
||||
}
|
||||
|
||||
public int getChestShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("CHEST.Shop." + identifier + ".Limit", -1);
|
||||
}
|
||||
|
||||
public String getChestShopIdentifierRewardsPath(String identifier) {
|
||||
return "CHEST.Shop." + identifier + ".Rewards";
|
||||
}
|
||||
|
||||
public Set<String> getChestShopIdentifiers() {
|
||||
ConfigurationSection shop = getData().getConfigurationSection("CHEST.Shop");
|
||||
if (shop != null) {
|
||||
return shop.getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestShopIdentifierSection(String identifier) {
|
||||
return getData().getConfigurationSection("CHEST.Shop." + identifier);
|
||||
}
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteBest.DayBest.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteBestDayBestItem;
|
||||
@@ -235,54 +158,14 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private String chestVoteGUIName = "&cVoteGUI: &c&l%player%";
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot command
|
||||
*/
|
||||
|
||||
public String getChestVoteGUISlotCommand(String slot) {
|
||||
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot lore.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot lore
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
@ConfigDataKeys(path = "CHEST.VoteGUI")
|
||||
@Getter
|
||||
private Set<String> chestVoteGUISlots = new HashSet<String>();
|
||||
|
||||
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
private Set<String> chestVoteGUISlots = new HashSet<>();
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTop.Customization")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTopCustomization;
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot slot
|
||||
*/
|
||||
public int getChestVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteLast.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteLastBackButton = false;
|
||||
@@ -307,63 +190,10 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private String chestVoteNextLine = "%time%";
|
||||
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteRewardName")
|
||||
@Getter
|
||||
private String chestVoteRewardName = "VoteReward";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopBackButton")
|
||||
@Getter
|
||||
private boolean chestVoteShopBackButton = 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 getChestVoteShopHideOnNoPermission(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".HideOnNoPermission", true);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopEnabled")
|
||||
@Getter
|
||||
private boolean chestVoteShopEnabled = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteShopName")
|
||||
@Getter
|
||||
private String chestVoteShopName = "VoteShop";
|
||||
|
||||
public boolean getChestVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".NotBuyable", false);
|
||||
}
|
||||
|
||||
public String getChestVoteShopPermission(String ident) {
|
||||
return getData().getString("CHEST.Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
public String getCHESTVoteShopPurchase(String identifier) {
|
||||
return getData().getString("CHEST.Shop." + identifier + ".PurchaseMessage",
|
||||
plugin.getConfigFile().getFormatShopPurchaseMsg());
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopResetDaily(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Daily", false);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopResetMonthly(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Monthly", false);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopResetWeekly(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Weekly", false);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteStreak.BackButton")
|
||||
@Getter
|
||||
private boolean chestVoteStreakBackButton = false;
|
||||
@@ -438,7 +268,7 @@ public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataListString(path = "CHEST.VoteTop.SwitchItem.TopVoters")
|
||||
@Getter
|
||||
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<String>();
|
||||
private ArrayList<String> chestVoteTopSwitchItemTopVoters = new ArrayList<>();
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.AllTimeTotal.Item")
|
||||
@Getter
|
||||
@@ -452,22 +282,6 @@ public class GUI extends YMLFile {
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalDayTotalItem;
|
||||
|
||||
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getChestVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getChestVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getChestVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteTotal.MonthTotal.Item")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTotalMonthTotalItem;
|
||||
@@ -510,30 +324,7 @@ public class GUI extends YMLFile {
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
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 ConfigurationSection getChestGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteShopExtraItems." + item);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
private Set<String> chestVoteURLExtraItems = new HashSet<>();
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.SiteName")
|
||||
@Getter
|
||||
@@ -561,15 +352,90 @@ public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteURL.URLText")
|
||||
@Getter
|
||||
private String chestVoteURLURLText = "%VoteUrl%";
|
||||
private String chestVoteURLURLText = "&3&lVote at &b&l[Text=\"&b&l%VoteUrl%\",hover=\"&aClick to open %sitename%\",url=\"%VoteUrl%\"]";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.ViewAllUrlsButtonEnabled")
|
||||
@Getter
|
||||
private boolean chestVoteURLViewAllUrlsButtonEnabled = false;
|
||||
|
||||
public boolean isChestVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
|
||||
isChestVoteShopRequireConfirmation());
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public Set<String> getChestGUIExtraItems(String gui) {
|
||||
if (getData().isConfigurationSection("CHEST." + gui + ".ExtraItems")) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems").getKeys(false);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestGUIExtraItemsItem(String gui, String item) {
|
||||
return getData().getConfigurationSection("CHEST." + gui + ".ExtraItems." + item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot command
|
||||
*/
|
||||
|
||||
public String getChestVoteGUISlotCommand(String slot) {
|
||||
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot lore.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot lore
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<>());
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot, String lastPath) {
|
||||
return "CHEST.VoteGUI." + slot + "." + lastPath;
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot slot
|
||||
*/
|
||||
public int getChestVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
public String getChestVoteNextCustomSiteNamesDisplays(String site) {
|
||||
return getData().getString("CHEST.VoteNext.CustomSiteNamesDisplays." + site, "");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getChestVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getChestVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getChestVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLExtraItemsItem(String item) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.ExtraItems." + item);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -581,9 +447,4 @@ public class GUI extends YMLFile {
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("GUI.yml", true);
|
||||
}
|
||||
|
||||
public void removeShop(String value) {
|
||||
getData().set("CHEST.Shop." + value, null);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataConfigurationSection;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class ShopFile extends YMLFile {
|
||||
|
||||
@Getter
|
||||
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.NoItem")
|
||||
private ConfigurationSection shopConfirmPurchaseNoItem;
|
||||
|
||||
@Getter
|
||||
@ConfigDataString(path = "ShopConfirmPurchase.Title")
|
||||
private String shopConfirmPurchaseTitle = "Confirm Purchase?";
|
||||
|
||||
@Getter
|
||||
@ConfigDataConfigurationSection(path = "ShopConfirmPurchase.YesItem")
|
||||
private ConfigurationSection shopConfirmPurchaseYesItem;
|
||||
|
||||
@Getter
|
||||
@ConfigDataString(path = "VoteShop.Disabled")
|
||||
private String voteShopDisabled = "&cVote shop disabled";
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.HideLimitedReached")
|
||||
@Getter
|
||||
private boolean voteShopHideLimitedReached = true;
|
||||
|
||||
@ConfigDataString(path = "VoteShop.LimitReached")
|
||||
@Getter
|
||||
private String voteShopLimitReached = "&aYou reached your limit";
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.RequireConfirmation")
|
||||
@Getter
|
||||
private boolean voteShopRequireConfirmation = false;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.BackButton")
|
||||
@Getter
|
||||
private boolean voteShopBackButton = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.ReopenGUIOnPurchase")
|
||||
@Getter
|
||||
private boolean voteShopReopenGUIOnPurchase = true;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteShop.Enabled")
|
||||
@Getter
|
||||
private boolean voteShopEnabled = true;
|
||||
|
||||
@ConfigDataString(path = "VoteShop.Name")
|
||||
@Getter
|
||||
private String voteShopName = "VoteShop";
|
||||
|
||||
@ConfigDataKeys(path = "ExtraItems")
|
||||
@Getter
|
||||
private Set<String> voteShopExtraItems = new HashSet<>();
|
||||
|
||||
public ShopFile(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Shop.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void convertFromGUIFile() {
|
||||
// booleans
|
||||
setValue("VoteShop.Enabled", plugin.getGui().getData().getBoolean("CHEST.VoteShopEnabled"));
|
||||
setValue("VoteShop.BackButton", plugin.getGui().getData().getBoolean("CHEST.VoteShopBackButton"));
|
||||
setValue("VoteShop.HideLimitReached", plugin.getGui().getData().getBoolean("CHEST.VoteShopHideLimitedReached"));
|
||||
setValue("VoteShop.RequireConfirmation",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopRequireConfirmation"));
|
||||
setValue("VoteShop.ReopenGUIOnPurchase",
|
||||
plugin.getGui().getData().getBoolean("CHEST.VoteShopReopenGUIOnPurchase"));
|
||||
|
||||
// strings
|
||||
setValue("VoteShop.Name", plugin.getGui().getData().getString("CHEST.VoteShopName"));
|
||||
setValue("VoteShop.LimitReached", plugin.getGui().getData().getString("CHEST.VoteShopLimitReached"));
|
||||
setValue("VoteShop.Disabled", plugin.getGui().getData().getString("CHEST.VoteShopDisabled"));
|
||||
|
||||
// sections
|
||||
setValue("Shop", plugin.getGui().getData().getConfigurationSection("CHEST.Shop"));
|
||||
setValue("ExtraItems", plugin.getGui().getData().getConfigurationSection("CHEST.VoteShopExtraItems"));
|
||||
setValue("ShopConfirmPurchase", plugin.getGui().getData().getConfigurationSection("CHEST.ShopConfirmPurchase"));
|
||||
saveData();
|
||||
|
||||
}
|
||||
|
||||
public void createShop(String value) {
|
||||
ConfigurationSection shopData = getData().createSection("Shop." + value);
|
||||
shopData.set("Identifier_Name", value);
|
||||
shopData.set("Material", "STONE");
|
||||
shopData.set("Amount", 1);
|
||||
shopData.set("Name", "&cPlaceholder item");
|
||||
shopData.set("Cost", 1);
|
||||
shopData.set("Permission", "");
|
||||
shopData.set("CloseGUI", true);
|
||||
shopData.set("RequireConfirmation", false);
|
||||
|
||||
shopData.set("Rewards.Items.Item1.Material", "STONE");
|
||||
shopData.set("Rewards.Items.Item1.Amount", 1);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public ConfigurationSection getGUIVoteShopExtraItems(String item) {
|
||||
return getData().getConfigurationSection("ExtraItems." + item);
|
||||
}
|
||||
|
||||
public int getShopIdentifierCost(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Cost");
|
||||
}
|
||||
|
||||
public String getShopIdentifierIdentifierName(String identifier) {
|
||||
return getData().getString("Shop." + identifier + ".Identifier_Name", identifier);
|
||||
}
|
||||
|
||||
public int getShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("Shop." + identifier + ".Limit", -1);
|
||||
}
|
||||
|
||||
public String getShopIdentifierRewardsPath(String identifier) {
|
||||
return "Shop." + identifier + ".Rewards";
|
||||
}
|
||||
|
||||
public Set<String> getShopIdentifiers() {
|
||||
ConfigurationSection shop = getData().getConfigurationSection("Shop");
|
||||
if (shop != null) {
|
||||
return shop.getKeys(false);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getShopIdentifierSection(String identifier) {
|
||||
return getData().getConfigurationSection("Shop." + identifier);
|
||||
}
|
||||
|
||||
public boolean getVoteShopCloseGUI(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".CloseGUI", true);
|
||||
}
|
||||
|
||||
public boolean getVoteShopHideOnNoPermission(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".HideOnNoPermission", true);
|
||||
}
|
||||
|
||||
public boolean getVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".NotBuyable", false);
|
||||
}
|
||||
|
||||
public String getVoteShopPermission(String ident) {
|
||||
return getData().getString("Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
public String getVoteShopPurchase(String identifier) {
|
||||
return getData().getString("Shop." + identifier + ".PurchaseMessage",
|
||||
plugin.getConfigFile().getFormatShopPurchaseMsg());
|
||||
}
|
||||
|
||||
public boolean getVoteShopResetDaily(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".Reset.Daily", false);
|
||||
}
|
||||
|
||||
public boolean getVoteShopResetMonthly(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".Reset.Monthly", false);
|
||||
}
|
||||
|
||||
public boolean getVoteShopResetWeekly(String shop) {
|
||||
return getData().getBoolean("Shop." + shop + ".Reset.Weekly", false);
|
||||
}
|
||||
|
||||
public boolean isVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("Shop." + identifier + ".RequireConfirmation", isVoteShopRequireConfirmation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("Shop.yml", true);
|
||||
}
|
||||
|
||||
public void removeShop(String value) {
|
||||
getData().set("Shop." + value, null);
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
+130
-114
@@ -6,14 +6,15 @@ 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.simpleapi.file.YMLFile;
|
||||
import com.bencodez.simpleapi.file.annotation.AnnotationHandler;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataDouble;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataKeys;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListInt;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataListString;
|
||||
import com.bencodez.simpleapi.file.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
@@ -66,7 +67,7 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesWeekly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesWeekly = false;
|
||||
@@ -75,13 +76,13 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private String votePartyVoteReminderBroadcast = "%votesrequired% left to go, go vote!";
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.VoteReminderAtVotes")
|
||||
@ConfigDataListInt(path = "VoteParty.VoteReminderAtVotes")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyVoteReminderAtVotes = new ArrayList<String>();
|
||||
private ArrayList<Integer> votePartyVoteReminderAtVotes = new ArrayList<>();
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalRandomCommand")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<String>();
|
||||
private ArrayList<String> votePartyGlobalRandomCommand = new ArrayList<>();
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
@@ -102,119 +103,29 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private double voteStreakRequirementWeek = 50;
|
||||
|
||||
public SpecialRewardsConfig(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean getCumulativeRewardEnabled(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Enabled");
|
||||
}
|
||||
|
||||
public String getCumulativeRewardsPath(int cumulative) {
|
||||
return "Cumulative." + cumulative + ".Rewards";
|
||||
}
|
||||
|
||||
public List<Integer> getCumulativeBlackList(int cumulative) {
|
||||
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameMonth(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameWeek(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
public String getCumulativeVotesTotal(int cumulative) {
|
||||
String str = getData().getString("Cumulative." + cumulative + ".TotalToUse", "");
|
||||
if (str.isEmpty()) {
|
||||
if (getCumulativeVotesInSameMonth(cumulative)) {
|
||||
return TopVoter.Monthly.toString();
|
||||
} else if (getCumulativeVotesInSameWeek(cumulative)) {
|
||||
return TopVoter.Weekly.toString();
|
||||
} else if (getCumulativeVotesInSameDay(cumulative)) {
|
||||
return TopVoter.Daily.toString();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
private Set<String> cumulativeVotes = new HashSet<>();
|
||||
|
||||
@ConfigDataKeys(path = "DailyAwards")
|
||||
@Getter
|
||||
private Set<String> dailyPossibleRewardPlaces = new HashSet<String>();
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone reward enabled
|
||||
*/
|
||||
public boolean getMilestoneRewardEnabled(int milestones) {
|
||||
return getData().getBoolean("MileStones." + milestones + ".Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone rewards.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone rewards
|
||||
*/
|
||||
public String getMilestoneRewardsPath(int milestones) {
|
||||
return "MileStones." + milestones + ".Rewards";
|
||||
}
|
||||
private Set<String> dailyPossibleRewardPlaces = new HashSet<>();
|
||||
|
||||
@ConfigDataKeys(path = "MileStones")
|
||||
@Getter
|
||||
private Set<String> milestoneVotes = new HashSet<String>();
|
||||
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
* @return the monthly possible reward places
|
||||
*/
|
||||
public Set<String> getMonthlyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
private Set<String> milestoneVotes = new HashSet<>();
|
||||
|
||||
@ConfigDataBoolean(path = "ResetMilestonesMonthly")
|
||||
@Getter
|
||||
private boolean resetMilestonesMonthly = false;
|
||||
|
||||
@ConfigDataString(path = "VoteParty.Broadcast")
|
||||
@Getter
|
||||
private String votePartyBroadcast = "";
|
||||
|
||||
@ConfigDataListString(path = "VoteParty.GlobalCommands", secondPath = "VoteParty.Commands")
|
||||
@Getter
|
||||
private ArrayList<String> votePartyGlobalCommands = new ArrayList<String>();
|
||||
private ArrayList<String> votePartyGlobalCommands = new ArrayList<>();
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.CountFakeVotes")
|
||||
@Getter
|
||||
@@ -232,8 +143,13 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@Getter
|
||||
private boolean votePartyGiveAllPlayers = false;
|
||||
|
||||
@Deprecated
|
||||
@ConfigDataInt(path = "VoteParty.IncreaseVotesRquired")
|
||||
@Getter
|
||||
private int votePartyIncreaseVotesRquired = 0;
|
||||
|
||||
@ConfigDataInt(path = "VoteParty.IncreaseVotesRequired")
|
||||
@Getter
|
||||
private int votePartyIncreaseVotesRequired = 0;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.OnlyOncePerDay")
|
||||
@@ -259,11 +175,115 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
@ConfigDataInt(path = "VoteParty.UserVotesRequired")
|
||||
@Getter
|
||||
private int votePartyUserVotesRequired = 0;
|
||||
|
||||
@ConfigDataInt(path = "VoteParty.VotesRequired")
|
||||
@Getter
|
||||
private int votePartyVotesRequired = 0;
|
||||
|
||||
@ConfigDataKeys(path = "WeeklyAwards")
|
||||
@Getter
|
||||
private Set<String> weeklyPossibleRewardPlaces = new HashSet<>();
|
||||
|
||||
public SpecialRewardsConfig(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public List<Integer> getCumulativeBlackList(int cumulative) {
|
||||
return getData().getIntegerList("Cumulative." + cumulative + ".BlackList");
|
||||
}
|
||||
|
||||
public boolean getCumulativeRecurring(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Recurring", true);
|
||||
}
|
||||
|
||||
public boolean getCumulativeRewardEnabled(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Enabled");
|
||||
}
|
||||
|
||||
public String getCumulativeRewardsPath(int cumulative) {
|
||||
return "Cumulative." + cumulative + ".Rewards";
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameDay(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameMonth(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean getCumulativeVotesInSameWeek(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
public String getCumulativeVotesTotal(int cumulative) {
|
||||
String str = getData().getString("Cumulative." + cumulative + ".TotalToUse", "");
|
||||
if (str.isEmpty()) {
|
||||
if (getCumulativeVotesInSameMonth(cumulative)) {
|
||||
return TopVoter.Monthly.toString();
|
||||
}
|
||||
if (getCumulativeVotesInSameWeek(cumulative)) {
|
||||
return TopVoter.Weekly.toString();
|
||||
}
|
||||
if (getCumulativeVotesInSameDay(cumulative)) {
|
||||
return TopVoter.Daily.toString();
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone reward enabled
|
||||
*/
|
||||
public boolean getMilestoneRewardEnabled(int milestones) {
|
||||
return getData().getBoolean("MileStones." + milestones + ".Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone rewards.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone rewards
|
||||
*/
|
||||
public String getMilestoneRewardsPath(int milestones) {
|
||||
return "MileStones." + milestones + ".Rewards";
|
||||
}
|
||||
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
* @return the monthly possible reward places
|
||||
*/
|
||||
public Set<String> getMonthlyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRequiredWithTypo() {
|
||||
int increase = getVotePartyIncreaseVotesRequired();
|
||||
if (increase > 0) {
|
||||
return increase;
|
||||
}
|
||||
return getVotePartyIncreaseVotesRquired();
|
||||
}
|
||||
|
||||
public boolean getVoteStreakRewardEnabled(String type, String s) {
|
||||
return getData().getBoolean("VoteStreak." + type + "." + s + ".Enabled");
|
||||
}
|
||||
@@ -278,9 +298,9 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<String>();
|
||||
return new HashSet<>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,10 +308,6 @@ public class SpecialRewardsConfig extends YMLFile {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
@ConfigDataKeys(path = "WeeklyAwards")
|
||||
@Getter
|
||||
private Set<String> weeklyPossibleRewardPlaces = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
+151
-134
@@ -16,7 +16,7 @@ import org.bukkit.event.Listener;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.user.AdvancedCoreUser;
|
||||
import com.bencodez.advancedcore.api.user.UserStartup;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.Column;
|
||||
import com.bencodez.simpleapi.sql.Column;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
@@ -29,156 +29,40 @@ public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<>();
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
private boolean cooldownCheckEnabled = false;
|
||||
|
||||
public void checkEnabled() {
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
|
||||
cooldownCheckEnabled = true;
|
||||
} else {
|
||||
cooldownCheckEnabled = false;
|
||||
}
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
public void check(UUID uuid) {
|
||||
check(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
}
|
||||
|
||||
public void checkPerSite(UUID uuid) {
|
||||
checkPerSite(plugin.getVotingPluginUserManager().getVotingPluginUser(uuid));
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
schedule(user);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.dontCache();
|
||||
}
|
||||
check(user);
|
||||
}
|
||||
|
||||
public synchronized void check(VotingPluginUser user) {
|
||||
boolean coolDownCheck = user.getCoolDownCheck();
|
||||
if (user.canVoteAll() && coolDownCheck) {
|
||||
user.setCoolDownCheck(false);
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
allSiteTasks.remove(user.getJavaUUID());
|
||||
} else if (!coolDownCheck) {
|
||||
schedule(user);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void checkPerSite(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
boolean changed = false;
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
if (!coolDownChecks.containsKey(site.getKey()) || !coolDownChecks.get(site.getKey()).booleanValue()) {
|
||||
if (user.canVoteSite(site)) {
|
||||
coolDownChecks.put(site.getKey(), Boolean.TRUE);
|
||||
changed = true;
|
||||
plugin.extraDebug("Triggering votesitecooldownend event for " + user.getUUID());
|
||||
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
user.setCoolDownCheckSite(coolDownChecks);
|
||||
if (coolDownCheck) {
|
||||
if (user.canVoteAll()) {
|
||||
user.setCoolDownCheck(false);
|
||||
PlayerVoteCoolDownEndEvent event = new PlayerVoteCoolDownEndEvent(user);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
allSiteTasks.remove(user.getJavaUUID());
|
||||
} else {
|
||||
schedulePerSite(user, false);
|
||||
}
|
||||
}
|
||||
|
||||
schedulePerSite(user);
|
||||
|
||||
}
|
||||
|
||||
public void schedulePerSite(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeFirstSiteAvailable();
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time + " seconds");
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void schedule(VotingPluginUser user) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
check(uuid);
|
||||
}
|
||||
}
|
||||
}, time+2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
checkPerSite(user);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void checkAllVoteSite(VoteSite site) {
|
||||
@@ -206,6 +90,75 @@ public class CoolDownCheck implements Listener {
|
||||
plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey());
|
||||
}
|
||||
|
||||
public void checkEnabled() {
|
||||
if (!plugin.getConfigFile().isDisableCoolDownCheck() && plugin.getRewardHandler()
|
||||
.hasRewards(plugin.getSpecialRewardsConfig().getData(), "VoteCoolDownEndedReward")) {
|
||||
cooldownCheckEnabled = true;
|
||||
} else {
|
||||
cooldownCheckEnabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void checkPerSite(UUID uuid) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.dontCache();
|
||||
}
|
||||
checkPerSite(user);
|
||||
}
|
||||
|
||||
public synchronized void checkPerSite(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
HashMap<String, Boolean> coolDownChecks = user.getCoolDownCheckSiteList();
|
||||
boolean changed = false;
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
if (!coolDownChecks.containsKey(site.getKey()) || !coolDownChecks.get(site.getKey()).booleanValue()) {
|
||||
if (user.canVoteSite(site)) {
|
||||
coolDownChecks.put(site.getKey(), Boolean.TRUE);
|
||||
changed = true;
|
||||
plugin.extraDebug("Triggering votesitecooldownend event for " + user.getUUID());
|
||||
PlayerVoteSiteCoolDownEndEvent event = new PlayerVoteSiteCoolDownEndEvent(user, site);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
user.setCoolDownCheckSite(coolDownChecks);
|
||||
}
|
||||
|
||||
schedulePerSite(user, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void load() {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
user.dontCache();
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
checkPerSite(user);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
@@ -219,4 +172,68 @@ public class CoolDownCheck implements Listener {
|
||||
event.getSite().getVoteURL(false)));
|
||||
}
|
||||
|
||||
public void schedule(VotingPluginUser user, boolean force) {
|
||||
if (user.getSitesVotedOn() > 0 || force) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeAllSitesAvailable();
|
||||
if (allSiteTasks.containsKey(uuid)) {
|
||||
allSiteTasks.get(uuid).cancel(false);
|
||||
allSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
user.setCoolDownCheck(true);
|
||||
ScheduledFuture<?> scheduledFuture = timer.schedule(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
check(uuid);
|
||||
}
|
||||
}
|
||||
}, time + 2, TimeUnit.SECONDS);
|
||||
allSiteTasks.put(uuid, scheduledFuture);
|
||||
} else {
|
||||
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void schedulePerSite(VotingPluginUser user, boolean force) {
|
||||
if (user.getSitesVotedOn() > 0 || force) {
|
||||
final UUID uuid = UUID.fromString(user.getUUID());
|
||||
long time = user.getNextTimeFirstSiteAvailable();
|
||||
if (perSiteTasks.containsKey(uuid)) {
|
||||
perSiteTasks.get(uuid).cancel(false);
|
||||
perSiteTasks.remove(uuid);
|
||||
}
|
||||
if (time > 0) {
|
||||
plugin.devDebug("PerSiteCoolDownEvent schedule time: " + time + " seconds");
|
||||
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);
|
||||
} else {
|
||||
plugin.extraDebug(user.getUUID() + "/" + user.getPlayerName() + " not scheduling cooldown check");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
schedule(user, true);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+110
-92
@@ -12,10 +12,11 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
import com.bencodez.votingplugin.timequeue.VoteTimeQueue;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -32,57 +33,18 @@ public class ServerData {
|
||||
public void addAutoCachedPlaceholder(String placeholder) {
|
||||
List<String> p = getAutoCachedPlaceholder();
|
||||
|
||||
if (!ArrayUtils.getInstance().containsIgnoreCase(p, placeholder)) {
|
||||
if (!ArrayUtils.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();
|
||||
}
|
||||
|
||||
public List<String> getAutoCachedPlaceholder() {
|
||||
return getData().getStringList("AutoCachePlaceholders");
|
||||
}
|
||||
|
||||
public List<String> getDisabledReminders() {
|
||||
return getData().getStringList("DisabledReminders");
|
||||
}
|
||||
|
||||
public synchronized void addServiceSite(String site) {
|
||||
ArrayList<String> l = getServiceSites();
|
||||
if (!getServiceSites().contains(site)) {
|
||||
l.add(site);
|
||||
}
|
||||
setServiceSites(ArrayUtils.getInstance().removeDuplicates(l));
|
||||
setServiceSites(ArrayUtils.removeDuplicates(l));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,6 +69,34 @@ public class ServerData {
|
||||
getSignSkullLocation("" + count), getSignData("" + count), getSignPosition("" + count)));
|
||||
}
|
||||
|
||||
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 void addVoteShopPurchase(String ident) {
|
||||
setVoteShopPurchases(ident, (getVoteShopPurchases(ident) + 1));
|
||||
}
|
||||
|
||||
public void clearTimedVoteCache() {
|
||||
getData().set("TimedVoteCache", null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public List<String> getAutoCachedPlaceholder() {
|
||||
return getData().getStringList("AutoCachePlaceholders");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyRequired() {
|
||||
return getData().getInt("BungeeVotePartyRequired");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
@@ -121,9 +111,13 @@ public class ServerData {
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<String> getDisabledReminders() {
|
||||
return getData().getStringList("DisabledReminders");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getServiceSites() {
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<String>());
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +161,7 @@ public class ServerData {
|
||||
try {
|
||||
return getData().getConfigurationSection("Signs").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,10 +180,25 @@ public class ServerData {
|
||||
getData().getDouble("Signs." + sign + ".Skull.Z"));
|
||||
}
|
||||
|
||||
public Set<String> getTimedVoteCacheKeys() {
|
||||
if (getData().isConfigurationSection("TimedVoteCache")) {
|
||||
return getData().getConfigurationSection("TimedVoteCache").getKeys(false);
|
||||
}
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getTimedVoteCacheSection(String num) {
|
||||
return getData().getConfigurationSection("TimedVoteCache." + num);
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
public int getVoteShopPurchases(String ident) {
|
||||
return getData().getInt("VoteShopPurchases." + ident);
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num == plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
@@ -207,6 +216,10 @@ public class ServerData {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVoteShopConverted() {
|
||||
return getData().getBoolean("VoteShopConverted");
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
@@ -232,6 +245,15 @@ public class ServerData {
|
||||
plugin.getServerDataFile().reloadData();
|
||||
}
|
||||
|
||||
public long getTopVoterMessageId(TopVoter top) {
|
||||
return getData().getLong("DiscordSRV.TopVoterMessageId." + top.toString(), 0);
|
||||
}
|
||||
|
||||
public void setTopVoterMessageId(TopVoter top, long messageId) {
|
||||
getData().set("DiscordSRV.TopVoterMessageId." + top.toString(), messageId);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*
|
||||
@@ -259,11 +281,40 @@ public class ServerData {
|
||||
plugin.getServerDataFile().saveData();
|
||||
}
|
||||
|
||||
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
|
||||
ArrayList<String> uuids = new ArrayList<>();
|
||||
for (UUID uuid : disabledReminders) {
|
||||
uuids.add(uuid.toString());
|
||||
}
|
||||
getData().set("DisabledReminders", uuids);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setAutoCachedPlaceholder(List<String> placeholders) {
|
||||
getData().set("AutoCachePlaceholders", placeholders);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyCurrent(int current) {
|
||||
getData().set("BungeeVotePartyCurrent", current);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyRequired(int required) {
|
||||
getData().set("BungeeVotePartyRequired", required);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setServiceSites(ArrayList<String> list) {
|
||||
getData().set("ServiceSites", list);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setShopConverted(boolean value) {
|
||||
getData().set("VoteShopConverted", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setSign(String count, Location location, Location skullLocation, String data, int position) {
|
||||
|
||||
getData().set("Signs." + count + ".World", location.getWorld().getName());
|
||||
@@ -303,6 +354,11 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVoteShopPurchases(String ident, int amount) {
|
||||
getData().set("VoteShopPurchases." + ident, amount);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void updateLastVoteParty() {
|
||||
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
|
||||
saveData();
|
||||
@@ -314,31 +370,17 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyCurrent() {
|
||||
return getData().getInt("BungeeVotePartyCurrent");
|
||||
}
|
||||
|
||||
public int getBungeeVotePartyRequired() {
|
||||
return getData().getInt("BungeeVotePartyRequired");
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyCurrent(int current) {
|
||||
getData().set("BungeeVotePartyCurrent", current);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBungeeVotePartyRequired(int required) {
|
||||
getData().set("BungeeVotePartyRequired", required);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void saveDisabledReminders(ArrayList<UUID> disabledReminders) {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
for (UUID uuid : disabledReminders) {
|
||||
uuids.add(uuid.toString());
|
||||
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();
|
||||
}
|
||||
getData().set("DisabledReminders", uuids);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -347,28 +389,4 @@ 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
package com.bencodez.votingplugin.discord;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.Reward;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInjectConfigurationSection;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoterPlayer;
|
||||
|
||||
import github.scarsz.discordsrv.DiscordSRV;
|
||||
import github.scarsz.discordsrv.api.Subscribe;
|
||||
import github.scarsz.discordsrv.api.events.DiscordReadyEvent;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.EmbedBuilder;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.JDA;
|
||||
import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel;
|
||||
import github.scarsz.discordsrv.util.DiscordUtil;
|
||||
import lombok.Getter;
|
||||
|
||||
public class DiscordHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
@Getter
|
||||
private final HashMap<TopVoter, Long> topVoterMessageIds = new HashMap<TopVoter, Long>();
|
||||
private final AtomicBoolean discordReady = new AtomicBoolean(false);
|
||||
|
||||
public DiscordHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
long savedId = plugin.getServerData().getTopVoterMessageId(top);
|
||||
topVoterMessageIds.put(top, savedId);
|
||||
}
|
||||
}
|
||||
|
||||
/** Call this early, e.g. from onEnable() in main plugin class */
|
||||
public void load() {
|
||||
DiscordSRV.api.subscribe(this);
|
||||
plugin.getLogger().info("DiscordHandler loaded; awaiting Discord readiness.");
|
||||
|
||||
// if DiscordSRV is already up and running, mark it ready now
|
||||
if (DiscordUtil.getJda().getStatus() == JDA.Status.CONNECTED) {
|
||||
discordReady.set(true);
|
||||
plugin.getLogger().info("DiscordSRV was already ready; manual update now available.");
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().addInjectedReward(new RewardInjectConfigurationSection("DiscordSRV") {
|
||||
|
||||
@Override
|
||||
public String onRewardRequested(Reward arg0, com.bencodez.advancedcore.api.user.AdvancedCoreUser user,
|
||||
ConfigurationSection section, HashMap<String, String> placeholders) {
|
||||
if (section.getBoolean("Enabled")) {
|
||||
String msg = PlaceholderUtils
|
||||
.replacePlaceHolder(section.getString("Message", "Please set a message"), placeholders);
|
||||
msg = PlaceholderUtils.replacePlaceHolders(user.getOfflinePlayer(), msg);
|
||||
sendRewardMessage(msg, section.getString("ChannelID", "0"));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** Fired once JDA is fully initialized */
|
||||
@Subscribe
|
||||
public void onDiscordReady(DiscordReadyEvent event) {
|
||||
discordReady.set(true);
|
||||
plugin.getLogger().info("DiscordSRV is ready; manual update now available.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Public method to update the Top Voter message on demand. Checks Discord
|
||||
* readiness internally.
|
||||
*/
|
||||
public void updateDiscordLeaderboard() {
|
||||
if (!discordReady.get()) {
|
||||
plugin.getLogger().warning("DiscordSRV not ready yet; cannot update Top Voters.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
if (plugin.getConfigFile().isDiscordSRVTopVoterEnabled(top)) {
|
||||
plugin.debug("Updating Discord Top Voter: " + top.toString());
|
||||
updateTopVoterMessageId(top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void updateTopVoterMessageId(TopVoter top) {
|
||||
long channelId = plugin.getConfigFile().getDiscordSRVTopVoterChannel(top);
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topVoters = plugin.getTopVoter(top);
|
||||
|
||||
String title = plugin.getConfigFile().getDiscordSRVTopVoterTitle(top);
|
||||
String rankDisplay = plugin.getConfigFile().getDiscordSRVTopVoterRankDisplay(top);
|
||||
|
||||
EmbedBuilder eb = new EmbedBuilder().setTitle(title).setColor(Color.CYAN).setTimestamp(Instant.now());
|
||||
|
||||
int rank = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : topVoters.entrySet()) {
|
||||
if (rank > 10)
|
||||
break;
|
||||
String line = rankDisplay.replace("%rank%", String.valueOf(rank))
|
||||
.replace("%player%", entry.getKey().getPlayerName())
|
||||
.replace("%votes%", String.valueOf(entry.getValue()));
|
||||
eb.addField("", line, false);
|
||||
rank++;
|
||||
}
|
||||
|
||||
TextChannel channel = DiscordUtil.getJda().getTextChannelById(channelId);
|
||||
if (channel == null) {
|
||||
plugin.getLogger().warning("Discord channel ID " + channelId + " not found: " + top.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
if (topVoterMessageIds.get(top) <= 0) {
|
||||
channel.sendMessageEmbeds(eb.build()).queue(msg -> {
|
||||
long newId = msg.getIdLong();
|
||||
topVoterMessageIds.put(top, newId);
|
||||
plugin.getServerData().setTopVoterMessageId(top, newId);
|
||||
plugin.getLogger().info("Posted new Top Voters " + top.toString() + " (ID: " + newId + ")");
|
||||
}, err -> plugin.getLogger()
|
||||
.warning("Error sending Top Voters " + top.toString() + ": " + err.getMessage()));
|
||||
} else {
|
||||
channel.editMessageEmbedsById(topVoterMessageIds.get(top), eb.build())
|
||||
.queue(m -> plugin.getLogger()
|
||||
.info("Edited Top Voters " + top.toString() + " (ID: " + topVoterMessageIds.get(top) + ")"),
|
||||
err -> plugin.getLogger()
|
||||
.warning("Error editing Top Voters" + top.toString() + ": " + err.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
public void sendRewardMessage(String message, String channelId) {
|
||||
TextChannel channel = DiscordUtil.getJda().getTextChannelById(channelId);
|
||||
if (channel != null) {
|
||||
channel.sendMessage(message).queue();
|
||||
} else {
|
||||
plugin.getLogger().warning("Discord channel ID " + channelId + " not found for reward message.");
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -3,8 +3,8 @@ package com.bencodez.votingplugin.events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
@@ -55,7 +55,7 @@ public class PlayerPostVoteEvent extends Event {
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long voteTime = 0;
|
||||
@@ -64,7 +64,8 @@ public class PlayerPostVoteEvent extends Event {
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee, long voteTime) {
|
||||
public PlayerPostVoteEvent(VoteSite voteSite, VotingPluginUser user, boolean realVote, boolean forceBungee,
|
||||
long voteTime) {
|
||||
super(true);
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
+1
-1
@@ -3,8 +3,8 @@ package com.bencodez.votingplugin.events;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.proxy.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,95 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
// Reports whether a player is currently inside a minigame.
|
||||
//
|
||||
// A minigame owns the player's inventory for the duration of a match and puts it back afterwards from a snapshot
|
||||
// it took on entry. A reward delivered in between lands in the match kit and is destroyed by that restore, with
|
||||
// the bank already marked as delivered, so rewards have to wait until the player is back on the SMP.
|
||||
//
|
||||
// Everything here is reflective and optional: no minigame is a dependency, and an absent or changed plugin simply
|
||||
// reports "not in a minigame" rather than breaking vote delivery.
|
||||
final class MinigameCheck {
|
||||
|
||||
private static final String SPLEEF_PLUGIN = "Spleef-OG";
|
||||
private static final String SPLEEF_API = "net.trueog.spleefog.api.SpleefAPI";
|
||||
private static final String SPLEGG_PLUGIN = "Splegg-OG";
|
||||
private static final String DUELS_PLUGIN = "Duels-OG";
|
||||
|
||||
private MinigameCheck() {
|
||||
}
|
||||
|
||||
static boolean inMinigame(Player player) {
|
||||
return player != null && (inSpleef(player) || inSplegg(player) || inDuel(player));
|
||||
}
|
||||
|
||||
private static boolean inSpleef(Player player) {
|
||||
Plugin plugin = enabled(SPLEEF_PLUGIN);
|
||||
if (plugin == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Class<?> api = Class.forName(SPLEEF_API, true, plugin.getClass().getClassLoader());
|
||||
Method query = api.getMethod("isInSpleef", Player.class);
|
||||
return Boolean.TRUE.equals(query.invoke(null, player));
|
||||
} catch (ReflectiveOperationException | RuntimeException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Splegg keeps its games in worlds it owns rather than in the SMP worlds, so the player's world answers this.
|
||||
private static boolean inSplegg(Player player) {
|
||||
Plugin plugin = enabled(SPLEGG_PLUGIN);
|
||||
if (plugin == null) {
|
||||
return false;
|
||||
}
|
||||
String world = player.getWorld().getName();
|
||||
try {
|
||||
Object configured = plugin.getClass().getMethod("getInGameWorlds").invoke(plugin);
|
||||
if (configured instanceof List<?> worlds) {
|
||||
for (Object name : worlds) {
|
||||
if (name != null && world.equalsIgnoreCase(name.toString())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Object prefix = plugin.getClass().getMethod("getGameWorldPrefix").invoke(plugin);
|
||||
// Per-game worlds are named <prefix><gameId>-<map>.
|
||||
return prefix != null && !prefix.toString().isEmpty()
|
||||
&& world.toLowerCase(Locale.ROOT).startsWith(prefix.toString().toLowerCase(Locale.ROOT));
|
||||
} catch (ReflectiveOperationException | RuntimeException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean inDuel(Player player) {
|
||||
Plugin plugin = enabled(DUELS_PLUGIN);
|
||||
if (plugin == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
Object arenaManager = plugin.getClass().getMethod("getArenaManager").invoke(plugin);
|
||||
if (arenaManager == null) {
|
||||
return false;
|
||||
}
|
||||
Method query = arenaManager.getClass().getMethod("isInMatch", Player.class);
|
||||
query.setAccessible(true);
|
||||
return Boolean.TRUE.equals(query.invoke(arenaManager, player));
|
||||
} catch (ReflectiveOperationException | RuntimeException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static Plugin enabled(String name) {
|
||||
Plugin plugin = Bukkit.getPluginManager().getPlugin(name);
|
||||
return plugin != null && plugin.isEnabled() ? plugin : null;
|
||||
}
|
||||
|
||||
}
|
||||
+7
-6
@@ -9,7 +9,8 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerManager;
|
||||
import com.bencodez.simpleapi.player.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
|
||||
@@ -55,19 +56,19 @@ public class PlayerInteract implements Listener {
|
||||
.sendMessage(sign.getRightClickMessage());
|
||||
|
||||
if (!sign.isSkullSet()) {
|
||||
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
if (PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Sign.Create")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
|| PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Admin")) {
|
||||
player.sendMessage("Skull not set, click to set skull");
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", sign.getSign());
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "skullset", sign.getSign());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getClickedBlock().getState() instanceof Skull) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "skullset");
|
||||
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "skullset");
|
||||
if (ob != null) {
|
||||
String sign1 = (String) ob;
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
@@ -78,7 +79,7 @@ public class PlayerInteract implements Listener {
|
||||
player.sendMessage("Skull set");
|
||||
}
|
||||
}
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", null);
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "skullset", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-7
@@ -8,7 +8,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.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -42,15 +41,15 @@ public class PlayerJoinEvent implements Listener {
|
||||
if (data) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
} else {
|
||||
plugin.debug("No data detected for " + player.getUniqueId().toString() + "/" + player.getName());
|
||||
}
|
||||
|
||||
user.loginRewards();
|
||||
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("Login", user.getPlayerName(),
|
||||
user.getUUID(), plugin.getBungeeSettings().getServer());
|
||||
}
|
||||
@@ -74,14 +73,14 @@ public class PlayerJoinEvent implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
final Player player = event.getPlayer();
|
||||
plugin.getLoginTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(player.getUniqueId());
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
plugin.getPlaceholders().onLogout(user);
|
||||
+37
-30
@@ -3,6 +3,7 @@ package com.bencodez.votingplugin.listeners;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -10,10 +11,9 @@ 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.api.misc.PlayerManager;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
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;
|
||||
@@ -50,7 +50,28 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
String playerName = event.getPlayer();
|
||||
plugin.debug("Processing PlayerVoteEvent: " + playerName + "/" + event.getServiceSite());
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
|
||||
// check for name casing
|
||||
playerName = plugin.getUserManager().getProperName(playerName);
|
||||
|
||||
boolean notValid = false;
|
||||
if (!PlayerManager.getInstance().isValidUser(playerName, plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
if (!playerName.startsWith(plugin.getOptions().getBedrockPlayerPrefix())
|
||||
&& !plugin.getOptions().getBedrockPlayerPrefix().isEmpty()) {
|
||||
if (!event.isBungee() && PlayerManager.getInstance().isValidUser(
|
||||
plugin.getOptions().getBedrockPlayerPrefix() + playerName,
|
||||
plugin.getConfigFile().isAllowUnJoinedCheckServer())) {
|
||||
plugin.debug("Detected a bedrock user without bedrock prefix, adjusting");
|
||||
playerName = plugin.getOptions().getBedrockPlayerPrefix() + playerName;
|
||||
} else {
|
||||
notValid = true;
|
||||
}
|
||||
} else {
|
||||
notValid = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (notValid) {
|
||||
if (!plugin.getConfigFile().isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
@@ -86,12 +107,11 @@ public class PlayerVoteListener implements Listener {
|
||||
if (!plugin.getConfigFile().isDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + event.getServiceSite() + "'");
|
||||
|
||||
ArrayList<String> services = new ArrayList<String>();
|
||||
ArrayList<String> services = new ArrayList<>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger()
|
||||
.warning("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
plugin.getLogger().warning("Currently set service sites: " + ArrayUtils.makeStringList(services));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -110,22 +130,21 @@ public class PlayerVoteListener implements Listener {
|
||||
// player online
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
} else {
|
||||
// attempt to get exact name from cache matching casing
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(playerName);
|
||||
}
|
||||
}
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
if (!event.isRealVote()) {
|
||||
plugin.getLogger()
|
||||
.info(user.getPlayerName() + " did a not real vote, bypassing WaitUntilVoteDelay");
|
||||
plugin.getLogger().info(user.getPlayerName() + " did a not real vote, bypassing WaitUntilVoteDelay");
|
||||
} else {
|
||||
if (user.hasPermission("VotingPlugin.BypassWaitUntilVoteDelay")) {
|
||||
plugin.getLogger()
|
||||
.info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing");
|
||||
} else {
|
||||
if (!user.hasPermission("VotingPlugin.BypassWaitUntilVoteDelay")) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
}
|
||||
plugin.getLogger()
|
||||
.info(user.getPlayerName() + " has bypass permission for WaitUntilVoteDelay, bypassing");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,8 +247,11 @@ public class PlayerVoteListener implements Listener {
|
||||
}
|
||||
LocalDateTime cTime = plugin.getTimeChecker().getTime();
|
||||
int days = cTime.getDayOfMonth();
|
||||
if (value >= days * plugin.getVoteSites().size()) {
|
||||
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSites().size());
|
||||
plugin.extraDebug("Current day of month: " + days + " Current total: " + value);
|
||||
if (value >= days * plugin.getVoteSitesEnabled().size()) {
|
||||
plugin.debug("Detected higher month total, changing. Current Total: " + value + " Days: " + days
|
||||
+ " New Total: " + days * plugin.getVoteSitesEnabled().size());
|
||||
user.setTotal(TopVoter.Monthly, days * plugin.getVoteSitesEnabled().size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,21 +262,6 @@ public class PlayerVoteListener implements Listener {
|
||||
plugin.getSpecialRewards().checkMilestone(user, event.getBungeeTextTotals(), event.isForceBungee());
|
||||
plugin.getCoolDownCheck().vote(user, voteSite);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
if (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.MYSQL)) {
|
||||
|
||||
plugin.getBukkitScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
|
||||
PlayerPostVoteEvent postVoteEvent = new PlayerPostVoteEvent(voteSite, user, event.isRealVote(),
|
||||
event.isForceBungee(), voteTime);
|
||||
plugin.getServer().getPluginManager().callEvent(postVoteEvent);
|
||||
+7
-8
@@ -4,8 +4,8 @@ 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.api.misc.PlayerManager;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
@@ -34,8 +34,8 @@ public class SignChange implements Listener {
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
if (event.getLine(0).equalsIgnoreCase("[VotingPlugin]")) {
|
||||
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(), "VotingPlugin.Sign.Create")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
if (PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(), "VotingPlugin.Sign.Create")
|
||||
|| PlayerManager.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Admin")) {
|
||||
String data = event.getLine(2);
|
||||
if (!data.equalsIgnoreCase("all") && !data.equalsIgnoreCase("monthly")
|
||||
@@ -45,7 +45,7 @@ public class SignChange implements Listener {
|
||||
try {
|
||||
plugin.getServerData().addSign(event.getBlock().getLocation(), event.getLine(2),
|
||||
Integer.parseInt(event.getLine(1)));
|
||||
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&aAdded sign!"));
|
||||
event.getPlayer().sendMessage(MessageAPI.colorize("&aAdded sign!"));
|
||||
plugin.getBukkitScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
@@ -55,12 +55,11 @@ public class SignChange implements Listener {
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&cError on sign creation!"));
|
||||
event.getPlayer().sendMessage(MessageAPI.colorize("&cError on sign creation!"));
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
event.getPlayer()
|
||||
.sendMessage(StringParser.getInstance().colorize(plugin.getConfigFile().getFormatNoPerms()));
|
||||
event.getPlayer().sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatNoPerms()));
|
||||
}
|
||||
}
|
||||
|
||||
Loaded 100 of 169 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user