mirror of
https://github.com/BenCodez/VotingPlugin.git
synced 2026-11-04 09:02:00 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fe401f1988 | ||
|
|
14feedf4f0 | ||
|
|
1aa360d844 | ||
|
|
4b899c2175 | ||
|
|
8bea5b70ec | ||
|
|
6e986f0e3a | ||
|
|
09fcb7f926 | ||
|
|
920e243fc4 | ||
|
|
02b8d013ab | ||
|
|
2193fa4e1a | ||
|
|
6e6986a373 | ||
|
|
121cca6a97 | ||
|
|
c633baa12b | ||
|
|
b3aec70ebc | ||
|
|
bf08a03059 | ||
|
|
b6542debaf | ||
|
|
549686fd37 | ||
|
|
1166db03ec | ||
|
|
e4bbd982a2 | ||
|
|
3112e76227 | ||
|
|
e3088f5e70 | ||
|
|
7137de2ce3 | ||
|
|
2c97bc171f | ||
|
|
df950984c3 | ||
|
|
11f54ef959 | ||
|
|
213623835d | ||
|
|
2dc6af10b1 | ||
|
|
8e8c10c7a2 | ||
|
|
35dc993bf1 | ||
|
|
425374a757 | ||
|
|
a74a7e35b8 | ||
|
|
49d8020fd1 | ||
|
|
4db6239653 | ||
|
|
71f3894a5d | ||
|
|
ded0b93880 | ||
|
|
dcb29e3cca | ||
|
|
6c24ae9397 | ||
|
|
285a19c422 | ||
|
|
55fc3dc0b1 | ||
|
|
0516a4f679 | ||
|
|
b73a82cba9 | ||
|
|
f89ad455cb | ||
|
|
5cc9650728 | ||
|
|
14f0197bc3 | ||
|
|
13e59f3c6b | ||
|
|
8f5ed0c95e | ||
|
|
1a6da05234 | ||
|
|
8193c255c2 | ||
|
|
3b664e7fa7 | ||
|
|
11439f16da | ||
|
|
57ff828998 | ||
|
|
8bb0fec810 | ||
|
|
de18c48c5f | ||
|
|
79f41ec605 | ||
|
|
796978fbf2 | ||
|
|
bbd77d1686 | ||
|
|
00da2b575d | ||
|
|
261187abc4 | ||
|
|
671b7c7add | ||
|
|
279b71c4b5 | ||
|
|
cd6289ab47 | ||
|
|
bdb520af09 | ||
|
|
6891a79c66 | ||
|
|
0e91c94cc8 | ||
|
|
f3d914e60c | ||
|
|
a5758435f9 | ||
|
|
e35bb0fe74 | ||
|
|
1b96deb150 | ||
|
|
1fe998afaf | ||
|
|
4ea6abcd1a | ||
|
|
c49d040473 | ||
|
|
3cd181636b | ||
|
|
43494bef1d | ||
|
|
6fe027223b | ||
|
|
d7dbcb4f44 | ||
|
|
f37a0671c7 | ||
|
|
47bdadfe27 | ||
|
|
10842a8d51 | ||
|
|
8e1d0024db | ||
|
|
bd119f3ac1 | ||
|
|
d0a207606e | ||
|
|
e594b42000 | ||
|
|
f59b4cc0f1 | ||
|
|
1aefbf77f5 | ||
|
|
b84658d130 | ||
|
|
72348add0c | ||
|
|
b3c631db9c | ||
|
|
46eb737296 | ||
|
|
64c335bd3b | ||
|
|
bde1f74223 | ||
|
|
42af35ae43 | ||
|
|
ffa9234bf2 | ||
|
|
398318d25f | ||
|
|
498c323ce7 | ||
|
|
eb73987ff0 | ||
|
|
0d7134e0e7 | ||
|
|
61ca4776e7 | ||
|
|
300f9fd928 | ||
|
|
cc035116e3 | ||
|
|
583b510636 | ||
|
|
bfd3d69704 | ||
|
|
8af2dc75cd | ||
|
|
d85640ec3c | ||
|
|
a1def65f2d | ||
|
|
d7387a7182 | ||
|
|
6d389c0408 | ||
|
|
3a419b5250 | ||
|
|
0a5c731b55 | ||
|
|
eb6faba7a5 | ||
|
|
6f828b6928 | ||
|
|
c43eb697e3 | ||
|
|
9917c85de4 | ||
|
|
5796e0401b | ||
|
|
3cc643e501 | ||
|
|
99935133e1 | ||
|
|
cb90e607aa | ||
|
|
0887810ce1 | ||
|
|
eef95ceea5 | ||
|
|
1611fc6cd2 | ||
|
|
6591f3a625 | ||
|
|
b74820d1a8 | ||
|
|
3a1fdf1f35 | ||
|
|
00875b7e6f | ||
|
|
0bd2801825 | ||
|
|
71e7f5c753 | ||
|
|
7392da2c04 | ||
|
|
e49c3f2476 | ||
|
|
e9e964ca7f | ||
|
|
5f51ccb749 | ||
|
|
ce7ee1da3b | ||
|
|
a8c57e1b78 | ||
|
|
6c2ab687bf | ||
|
|
3af59056a7 | ||
|
|
dd3bcae15f | ||
|
|
499e4c9bd9 | ||
|
|
59bd7895d1 | ||
|
|
be78d4a717 | ||
|
|
16fce5f132 | ||
|
|
0b1c192315 | ||
|
|
139122be62 | ||
|
|
de0f511e9e | ||
|
|
73bba25977 | ||
|
|
83ca134649 | ||
|
|
06a74371e7 | ||
|
|
365f08861f | ||
|
|
9fa553e417 | ||
|
|
8b2d3b7f63 | ||
|
|
0f1ccea630 | ||
|
|
d116fa11f7 | ||
|
|
de75dff8df | ||
|
|
1a5f8cdc0f | ||
|
|
9674921fe3 | ||
|
|
ff21a233fe | ||
|
|
e19a50e64a | ||
|
|
d69d08461d | ||
|
|
d9aaeda303 | ||
|
|
b3cc94965a | ||
|
|
a1033555fb | ||
|
|
8ef8aa26ff | ||
|
|
ad8699cf15 | ||
|
|
84705f29f5 | ||
|
|
058fbdfd9e | ||
|
|
c3b7747cbc | ||
|
|
2230bd45b9 | ||
|
|
d7a35d845a | ||
|
|
0e48aae457 | ||
|
|
0c94ba89a5 | ||
|
|
0b8ddaccdc | ||
|
|
68ee77eab3 | ||
|
|
3c38932feb | ||
|
|
8594f0f51d | ||
|
|
c77fdb1b69 | ||
|
|
236812bcac | ||
|
|
0bb6d57494 | ||
|
|
5e5988d0b3 | ||
|
|
77a190574d | ||
|
|
a8bf92786f | ||
|
|
7510981f60 | ||
|
|
5dfd9481bc | ||
|
|
403579d7bf | ||
|
|
d019e54860 | ||
|
|
34b5b34a2f | ||
|
|
535e2201d5 | ||
|
|
e305e6c97c | ||
|
|
564de3d653 | ||
|
|
88050c903e | ||
|
|
901d900932 | ||
|
|
d33063dd50 | ||
|
|
a5d85f4cbc | ||
|
|
8e03f6e9c0 | ||
|
|
d761238eab | ||
|
|
7a4a7ec1b5 | ||
|
|
fdb3793145 | ||
|
|
8c758a3410 | ||
|
|
9564e00460 | ||
|
|
28d4f5482d | ||
|
|
5fe9bd1377 | ||
|
|
474553b4fe | ||
|
|
609e31c16c | ||
|
|
71ed79b819 | ||
|
|
7f1e1e1e72 | ||
|
|
e22b1885ab | ||
|
|
c3291e4f46 | ||
|
|
60a1428496 | ||
|
|
17c098f1ee | ||
|
|
fb78dc1313 | ||
|
|
382bba9990 | ||
|
|
8594cb8238 | ||
|
|
1f3a4b84a1 | ||
|
|
17574f6c50 | ||
|
|
60377deb44 | ||
|
|
34614e13fa | ||
|
|
bc98630388 | ||
|
|
302cc980d8 | ||
|
|
4342fc5458 | ||
|
|
90b981af7b | ||
|
|
32879956ec | ||
|
|
2b166c7760 | ||
|
|
9848172a49 | ||
|
|
9775d06ba9 | ||
|
|
9584bc0e66 | ||
|
|
00ec202140 | ||
|
|
bd57f003dd | ||
|
|
23788be684 | ||
|
|
9b33b1cde7 | ||
|
|
02fb353dac | ||
|
|
a4c470887f | ||
|
|
e844a1eb63 | ||
|
|
1787595ea2 | ||
|
|
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 |
No files matched your search
@@ -0,0 +1,41 @@
|
||||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
|
||||
|
||||
# This workflow uses actions that are not certified by GitHub.
|
||||
# They are provided by a third-party and are governed by
|
||||
# separate terms of service, privacy policy, and support documentation.
|
||||
|
||||
name: Java CI with Maven
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
permissions:
|
||||
contents: write # required for dependency submission
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '21'
|
||||
distribution: 'temurin'
|
||||
cache: maven
|
||||
|
||||
- name: Build with Maven
|
||||
run: mvn -B -f VotingPlugin/pom.xml package
|
||||
|
||||
# Only submit dependency snapshot on push (not on pull_request)
|
||||
- name: Submit Dependency Snapshot
|
||||
if: github.event_name == 'push'
|
||||
uses: advanced-security/maven-dependency-submission-action@v5
|
||||
with:
|
||||
directory: VotingPlugin # path to pom.xml
|
||||
# optional: maven-args: "-DskipTests"
|
||||
@@ -16,9 +16,9 @@ jobs:
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
javadoc-branch: gh-pages
|
||||
java-version: 17
|
||||
java-version: 21
|
||||
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'
|
||||
javadoc-source-folder: 'VotingPlugin/target/reports/apidocs'
|
||||
@@ -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>
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
description: Describe what this custom agent does and when to use it.
|
||||
tools: []
|
||||
---
|
||||
Write instructions for this custom agent. These will guide Copilot on how to respond when this mode is selected.
|
||||
@@ -6,3 +6,4 @@
|
||||
/.settings/
|
||||
/.classpath
|
||||
/.factorypath
|
||||
/.apt_generated_tests/
|
||||
@@ -1,128 +0,0 @@
|
||||
##########################################
|
||||
# Bungee Setup
|
||||
# Only if using votingplugin bungee to send votes
|
||||
# REQUIRES RESTART FOR CHANGES TO TAKE EFFECT
|
||||
##########################################
|
||||
|
||||
# Plugin using bungee, requires plugin on bungee server
|
||||
UseBungeecord: false
|
||||
|
||||
# What type of bungee setup
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
# REDIS (2nd Most Recommended)
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
|
||||
Redis:
|
||||
Host: localhost
|
||||
Port: 6379
|
||||
# To get the user name, run redis-cli, if you set a password, run "auth <your password>" and if the out put is "OK" run "ACL USERS"
|
||||
Username: 'default'
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using multi-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
# Enables more debug messages for communication between servers
|
||||
# Use /votingpluginbungee status for testing communication
|
||||
BungeeDebug: false
|
||||
|
||||
# Get the plugin to broadcast to all servers
|
||||
# If false you need to enable
|
||||
# Only use for global rewards (one per network), otherwise you will get double broadcasts
|
||||
BungeeBroadcast: false
|
||||
|
||||
# For pluginmessaging method only
|
||||
# Whether to broadcast on cached votes
|
||||
BungeeBroadcastAlways: false
|
||||
|
||||
# If true, the server won't broadcast votes
|
||||
# To be used in conjuction with Broadcast setting on bungee
|
||||
DisableBroadcast: false
|
||||
|
||||
# If true, offline rewards will be stored per server, rather than global
|
||||
# This shouldn't need to be set unless you get alot of cross server rewards issues
|
||||
# You can also specify the server within the rewards
|
||||
# Requires server name below to be correct
|
||||
PerServerRewards: false
|
||||
|
||||
# If true, milestones work per server
|
||||
# Please note totals still sync, but milestones can be claimed on each server
|
||||
# Needs to be set across all needed servers
|
||||
PerServerMilestones: false
|
||||
|
||||
# If true, points will be given on a per server level
|
||||
# Points will be added when server gets vote from bungee
|
||||
PerServerPoints: false
|
||||
|
||||
# If true, plugin will trigger VotifierEvent
|
||||
# Should allow some compability with other plugins
|
||||
TriggerVotifierEvent: false
|
||||
|
||||
# If enabled plugin will give extra allsites reward if deterimned that it should
|
||||
# E.g. user votes offline for 7 days, they will only get 1 allsites reward by default
|
||||
# When enabled, they should get 7
|
||||
# Only applies to PLUGINMESSAGING
|
||||
# Recommend enabling ExtraAllSitesCheck in config.yml as well
|
||||
GiveExtraAllSitesRewards: false
|
||||
|
||||
# What server this is in bungee (must match)
|
||||
# Also can be applied to rewards
|
||||
Server: PleaseSet
|
||||
|
||||
# Rewards from bungee vote party
|
||||
# Gives to only players only
|
||||
# Use regular voteparty rewards otherwise
|
||||
# Can edit via /av gui
|
||||
BungeeVotePartyRewards: {}
|
||||
|
||||
# List of commands to run on bungee party
|
||||
# This runs a one time command only
|
||||
BungeeVotePartyGlobalCommands: []
|
||||
|
||||
####################################################################################
|
||||
# Global mysql data handle for between server commmunications
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
# This will create a different table then from users storing server info to process
|
||||
#
|
||||
# If you use this you need to enable this on BungeeSettings.yml on each server with votingplugin
|
||||
# Make sure server name is set correctly in BungeeSettings.yml or this will not work correctly
|
||||
#
|
||||
# Please use PLUGINMESSAGING for this, SOCKETS should work as well, but not fully tested
|
||||
#
|
||||
# This will make votes cache until time change has finished processing
|
||||
# In the event a server is offline or time change fails, the time change process
|
||||
# will continue after a set amount of time (in essense skipping a specific server)
|
||||
# This will also respect blocked servers in bungeeconfig.yml
|
||||
GlobalData:
|
||||
Enabled: false
|
||||
# Use existing mysql connection from config.yml
|
||||
UseMainMySQL: true
|
||||
# Mysql settings only used if above is false
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Must be the same on all servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
##########################################
|
||||
# For socket setup
|
||||
# Recommend to try PLUGINMESSAGING setup first
|
||||
# Options hidden by default to avoid confusion
|
||||
##########################################
|
||||
# Options available here:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungee-Setup-SOCKETS
|
||||
@@ -1,762 +0,0 @@
|
||||
# VotingPlugin by BenCodez
|
||||
# Main Config
|
||||
# See wiki for help:
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki
|
||||
# Config is sorted in sections
|
||||
# Use Control + F to search with Notepad++
|
||||
|
||||
|
||||
###########################################
|
||||
# User storage
|
||||
###########################################
|
||||
# Valid Options:
|
||||
# - SQLITE
|
||||
# - MYSQL
|
||||
DataStorage: SQLITE
|
||||
|
||||
# Information for mysql
|
||||
# See the end of the config for cache options
|
||||
MySQL:
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
# Don't use with PLUGINMESSAGING bungee setup
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#MaxLifeTime: -1
|
||||
#Additional info on connection string
|
||||
#Line: ''
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
|
||||
###########################################
|
||||
# VoteReminding
|
||||
###########################################
|
||||
|
||||
# Configuration for VoteReminding
|
||||
# By default this should be all setup to work
|
||||
# as long as vote delays are done properly in votesites.yml
|
||||
VoteReminding:
|
||||
# Enable vote reminding
|
||||
# This will remind player when he can vote on all sites
|
||||
# Requires VoteDelays to be setup properly
|
||||
# Use /vote next to see when you can be reminded
|
||||
# Players require the perm "VotingPlugin.Login.RemindVotes" or "VotingPlugin.Player"
|
||||
# To remind if all votesites are available (rather than any) use the permission "VotingPlugin.Login.RemindVotes.All"
|
||||
Enabled: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
RemindOnLogin: true
|
||||
|
||||
# Whether or not to remind only once when the player can vote
|
||||
# Does not apply to login reminds.
|
||||
RemindOnlyOnce: true
|
||||
|
||||
# Delay to remind votes in minutes
|
||||
# Set to -1 to disable
|
||||
RemindDelay: 30
|
||||
|
||||
# Run rewards
|
||||
# and have the default message
|
||||
# Can add titles and more in the reward
|
||||
# This can also be edited via /av gui
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou have %sitesavailable% sites to vote on still!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
SubTitle: '&aType /vote'
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
ActionBar:
|
||||
Message: '&cRemember to vote'
|
||||
Delay: 30
|
||||
|
||||
###########################################
|
||||
# Format options
|
||||
###########################################
|
||||
|
||||
# Common PlacesHolders:
|
||||
# Special PlaceHolders will be commented where available
|
||||
# %player% = player name
|
||||
# %SiteName% = vote site name
|
||||
#
|
||||
# Set Message to '' (2 ') to disable message
|
||||
|
||||
Format:
|
||||
# CommandHandler help message
|
||||
# Mainly used in admin help page, see below for /vote help
|
||||
HelpLine: '&6%Command% - &6%HelpMessage%'
|
||||
|
||||
# Broadcast vote message
|
||||
# Set to an empty message to disable
|
||||
# Use %NewLine% for a new line
|
||||
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
|
||||
# If true uses broadcast setting below for offline votes
|
||||
OnlyOneOfflineBroadcast: false
|
||||
OfflineBroadcast: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %numberofvotes% times!'
|
||||
|
||||
# Broadcast only when player is online
|
||||
BroadcastWhenOnline: false
|
||||
|
||||
# Broadcast every x number of minutes with number of players that voted
|
||||
AlternateBroadcast:
|
||||
Enabled: false
|
||||
# Use %players% for all players names
|
||||
# Use %numberofplayers% for number of players that voted
|
||||
Broadcast: '&6[&4Broadcast&6] &2%numberofplayers% voted in the last half hour! /vote'
|
||||
# Delay in minutes
|
||||
Delay: 30
|
||||
|
||||
Commands:
|
||||
# Format for /vote
|
||||
# %num% = the number of the site, for a numbered list
|
||||
# %url% = site URL
|
||||
Vote:
|
||||
Text:
|
||||
- '&3&lVote for our server!'
|
||||
|
||||
# If you want to want to use the feature below where the plugin will
|
||||
# automaticly list the sites then set the message in the text above
|
||||
AutoInputSites: true
|
||||
# For each VoteSite
|
||||
# make sure to set VoteURL in your VoteSites
|
||||
# Requires above to be true
|
||||
# Text will be sent before this
|
||||
Sites: '&3%num%: &6&l%SiteName% &6- %url%'
|
||||
|
||||
# If true, links will always be forced as urls
|
||||
ForceLinks: true
|
||||
|
||||
# Format for /vote next
|
||||
Next:
|
||||
# First line
|
||||
Title: '&3&l%player% Next Votes:'
|
||||
|
||||
# How each line is setup for each vote site
|
||||
# %info% = Info - See Below
|
||||
# %SiteName% = site name from vote
|
||||
Layout: '&3%SiteName%: &6%info%'
|
||||
|
||||
Info:
|
||||
# Message when player can vote
|
||||
CanVote: 'Go Vote!'
|
||||
# Time until vote msg
|
||||
# %hours% = hours until next vote
|
||||
# %minutes% = minutes until next vote
|
||||
TimeUntilVote: '%hours% Hours and %minutes% Minutes'
|
||||
# If there is an error finding out time until next vote
|
||||
Error: '&cCould not caculate time until next vote!'
|
||||
# For sites that have this, requires votedelaydaily to be set to true in the site
|
||||
VoteDelayDaily: '%hours% Hours and %minutes% Minutes'
|
||||
|
||||
# Format for /vote last
|
||||
Last:
|
||||
# First line
|
||||
Title: '&3&l%player% Last Vote Times:'
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
# %timesince% = time since vote
|
||||
Line: '&3%SiteName%: &6%timeSince%'
|
||||
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
LastVoted: '%times% ago'
|
||||
NeverVoted: 'Never voted'
|
||||
# Whether or not to include seconds into last voted time
|
||||
IncludeSeconds: true
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
- '&3&l%player% Total Votes:'
|
||||
- '&3&lDaily Total: &6&l%DailyTotal%'
|
||||
- '&3&lWeekly Total: &6&l%WeeklyTotal%'
|
||||
- '&3&lMonthly Total: &6&l%MonthlyTotal%'
|
||||
- '&3&lAllTime Total: &6&l%AllTimeTotal%'
|
||||
|
||||
# Format for /vote total all
|
||||
TotalAll:
|
||||
- '&3&lServer Total Votes:'
|
||||
- '&3&lDaily Total: &6&l%DailyTotal%'
|
||||
- '&3&lWeekly Total: &6&l%WeeklyTotal%'
|
||||
- '&3&lMonthly Total: &6&l%MonthlyTotal%'
|
||||
- '&3&lAllTime Total: &6&l%AllTimeTotal%'
|
||||
|
||||
# Format for /vote top
|
||||
Top:
|
||||
# First line
|
||||
# %page% = current page
|
||||
# %maxpages% = max number of pages
|
||||
# %Top% = Monthly/Weekly/Daily (depending on command)
|
||||
Title: '&3Top %Top% Voters %page%/%maxpages%'
|
||||
# Line for each player in that page
|
||||
Line: '&c%num%: &6%player%, %votes%'
|
||||
|
||||
# Format for /vote help
|
||||
Help:
|
||||
# Title of /vote help
|
||||
Title: '&6&lVoting Player Help'
|
||||
# Format for help message in /v help
|
||||
Line: '&6%Command% - &6%HelpMessage%'
|
||||
# Hover color for help message
|
||||
# Hex format: #HEXCOLOR
|
||||
HoverColor: AQUA
|
||||
# Require permission to see command in /v help or /av help
|
||||
RequirePermission: true
|
||||
|
||||
Best:
|
||||
Title: '&3&l%player% Best Votes'
|
||||
Lines:
|
||||
- '&3Highest Daily Total: &3&l%HighestDailyTotal%'
|
||||
- '&3Highest Week Total: &3&l%HighestWeeklyTotal%'
|
||||
- '&3Highest Month Total: &3&l%HighestMonthlyTotal%'
|
||||
|
||||
Streak:
|
||||
Title: '&3&l%player% Vote Streak'
|
||||
Lines:
|
||||
- '&3Current Daily Streak: &3&l%DailyStreak%'
|
||||
- '&3Current Week Streak: &3&l%WeeklyStreak%'
|
||||
- '&3Current Month Streak: &3&l%MonthlyStreak%'
|
||||
- '&3&lHighest Streaks:'
|
||||
- '&3Highest Daily Streak: &3&l%BestDailyStreak%'
|
||||
- '&3Highest Week Streak: &3&l%BestWeeklyStreak%'
|
||||
- '&3Highest Month Streak: &3&l%BestMonthlyStreak%'
|
||||
|
||||
Today:
|
||||
Title:
|
||||
- "&cToday's Votes %page%/%maxpage%"
|
||||
- '&cPlayerName : VoteSite : Time'
|
||||
Line: '&6%player% : %VoteSite% : %Time%'
|
||||
|
||||
# PlaceHolders:
|
||||
# %VotesRequired% = VotesRequired
|
||||
# %NeededVotes% = Number of votes needed to reach VotesRequired
|
||||
# %Votes% = Number of votes
|
||||
Party:
|
||||
- '&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%'
|
||||
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
# /vote givepoints command
|
||||
# Transfer between players command
|
||||
# Enable command below
|
||||
GivePoints:
|
||||
NotEnoughPoints: '&cNot enough points'
|
||||
NotJoinedServer: '&c%player% has not joined the server'
|
||||
NumberLowerThanZero: '&cNumber of points needs to be greater than 0'
|
||||
TransferFrom: '&c%transfer% points given to %touser%'
|
||||
TransferTo: '&cYou received %transfer% points from %fromuser%'
|
||||
|
||||
ToggleBroadcasts:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
ToggleReminders:
|
||||
Enabled: '&cVote reminders enabled'
|
||||
Disabled: '&cVote reminders disabled'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
TopVoterAwardMsg: '&aYou came in %place% in top voters of the month! Here is an award!'
|
||||
|
||||
# Time Format
|
||||
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
TimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
# Reward time format for %date% placeholder (Time of giving reward)
|
||||
RewardTimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
TimeFormats:
|
||||
Day: 'Day'
|
||||
Days: 'Days'
|
||||
Hour: 'Hour'
|
||||
Hours: 'Hours'
|
||||
Minute: 'Minute'
|
||||
Minutes: 'Minutes'
|
||||
Second: 'Second'
|
||||
Seconds: 'Seconds'
|
||||
|
||||
# Format for signs
|
||||
# SiteName may be all, depending on sign
|
||||
# %position% = position of player, set by sign
|
||||
# %votes% = Number of votes
|
||||
Signs:
|
||||
TopVoterSign:
|
||||
Line1: 'TopVoter: %SiteName%'
|
||||
Line2: '#%position%'
|
||||
Line3: '%player%'
|
||||
Line4: '%votes% Votes'
|
||||
# Message when right clicking sign, uses same placeholders as above
|
||||
RightClickMessage: '&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cvotes in &c&l%SiteName%'
|
||||
|
||||
# Message when player tries to run command without required permissions
|
||||
NoPerms: '&cYou do not have enough permission!'
|
||||
|
||||
# Message when player types a command but does not input a number where needed
|
||||
NotNumber: '&cError on &6%arg%&c, number expected!'
|
||||
|
||||
# Shop messages when using the /vote shop
|
||||
ShopPurchase: '&aYou bought the %Identifier% for %Points% Points!'
|
||||
ShopFailed: '&cYou do not have %Points% points to purchase this!'
|
||||
ShopNotPurchasable: '&cThis item is not buyable!'
|
||||
|
||||
# User not exist message, from commands such as /vote next (player)
|
||||
UserNotExist: '&cUser does not exist: %player%'
|
||||
|
||||
# Prev/Next page tems in GUIs
|
||||
PrevItem:
|
||||
Material: 'BLACK_STAINED_GLASS_PANE'
|
||||
Amount: 1
|
||||
Name: '&aPrevious Page'
|
||||
|
||||
NextItem:
|
||||
Material: 'BLACK_STAINED_GLASS_PANE'
|
||||
Amount: 1
|
||||
Name: '&aNext Page'
|
||||
|
||||
InvFull: '&cInventory full'
|
||||
|
||||
# Display text
|
||||
# Used in /vote top (GUI)
|
||||
TopVoter:
|
||||
Daily: 'Daily'
|
||||
Weekly: 'Weekly'
|
||||
Monthly: 'Monthly'
|
||||
AllTime: 'AllTime'
|
||||
|
||||
# Invalid command messages
|
||||
InvalidCommand:
|
||||
Vote: '&4No valid arguments, see /vote help!'
|
||||
AdminVote: '&4No valid arguments, see /adminvote help!'
|
||||
|
||||
# Playernames to not be broadcasted when voting
|
||||
# case sensitive
|
||||
VotingBroadcastBlacklist: []
|
||||
|
||||
# Playernames to not be broadcasted when broadcast comes from reward file
|
||||
# case sensitive
|
||||
BroadcastBlacklist: []
|
||||
|
||||
###########################################
|
||||
# Top Voter
|
||||
# Top voter rewards available in specialrewards.yml
|
||||
###########################################
|
||||
|
||||
# Top voter blacklist
|
||||
# Hide these names from top voter lists
|
||||
BlackList:
|
||||
- 'Notch'
|
||||
|
||||
# If true players with the permission 'VotingPlugin.TopVoter.Ignore' will act
|
||||
# as if there name was added on the the blacklist above
|
||||
# This also applies for players with op
|
||||
TopVoterIgnorePermission: false
|
||||
|
||||
# /vote top default data displayed
|
||||
# Valid Options: AllTime, Monthly, Weekly, Daily
|
||||
VoteTopDefault: Monthly
|
||||
|
||||
# Whether or not to have ties on top voter rewards
|
||||
TopVoterAwardsTies: true
|
||||
|
||||
# These are required to be enabled in order for top voter awards to work
|
||||
LoadTopVoter:
|
||||
AllTime: true
|
||||
Monthly: true
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# Maxium number of players to show on top voter
|
||||
# Set to -1 for no limit
|
||||
MaxiumNumberOfTopVotersToLoad: 1000
|
||||
|
||||
# When top voter awards are given (even if there are none listed) it will store top voters
|
||||
# Files will created in TopVoters folder.
|
||||
# Monthly top voters are always saved by default now
|
||||
StoreTopVoters:
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# Limit monthly votes to number of days of a month multipled by the number of sites
|
||||
LimitMonthlyVotes: false
|
||||
|
||||
###########################################
|
||||
# Debug
|
||||
###########################################
|
||||
|
||||
# Debug levels:
|
||||
# NONE
|
||||
# INFO
|
||||
# EXTRA
|
||||
DebugLevel: NONE
|
||||
|
||||
# Debug info ingame
|
||||
# Players with permission "VotingPlugin.Debug"
|
||||
# will see debug info if debug is true
|
||||
DebugInGame: false
|
||||
|
||||
# Will log debug messages to VotingPlugin/Log/log.txt
|
||||
# Only needed for extreme cases
|
||||
#LogDebugToFile: false
|
||||
|
||||
# Whether or not to log every vote to a file
|
||||
# Use this if you wanna track player votes
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
###########################################
|
||||
# Placeholderapi placeholders settings
|
||||
###########################################
|
||||
|
||||
# When enabled the command /vote setprimaryaccount (playername)
|
||||
# will be shown (after restart)
|
||||
# Primary account will be used instead of the players account to get
|
||||
# placeholder and other data such as vote reminding
|
||||
# Mainly to be used for alts and such
|
||||
UsePrimaryAccountForPlaceholders: false
|
||||
|
||||
# Valid Options:
|
||||
# AUTOALL - Auto cache placeholders after they have been used and cache all players placeholder all the time
|
||||
# AUTO - Auto cache after they have been used and cache online players placeholders (Recommended)
|
||||
# SPECIFIC - Only cache certain placeholders for online players
|
||||
# SPECIFICALL - Only cache certain placeholders for all players
|
||||
# NONE - Don't cache any placeholders
|
||||
PlaceholderCacheLevel: AUTO
|
||||
|
||||
# Placeholder controls
|
||||
# Add _process to end of placeholder to force a return value rather than . or .. if no cached value is ready
|
||||
# Add _nocache to end of placeholder to skip cache and retrive a live value, uses a direct mysql connection, do not use on main thread
|
||||
#
|
||||
|
||||
# Set which placeholders to cache at all times
|
||||
# Use for placeholders to are pulled constantly or on the main thread
|
||||
# Mainly aimed for scoreboards that pull placeholders often
|
||||
# Placeholders may auto cache in certain conditions (if enabled above)
|
||||
# Will use additional memory, but not a lot
|
||||
# Still in early stages, please report bugs
|
||||
# Please remove VotingPlugin_ from the placeholder listed here
|
||||
CachedPlaceholders: []
|
||||
#- Total_AllTime
|
||||
|
||||
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
|
||||
# Custom placeholder returns
|
||||
# For the example below use %votingplugin_custom_enoughpoints_5%
|
||||
# DO NOT USE ON MAIN THREAD IF POSSIBLE
|
||||
# Keep everything lowercase
|
||||
# Example:
|
||||
#CustomPlaceholderReturns:
|
||||
# 'enoughpoints_5':
|
||||
# 'true': 'User has enough points'
|
||||
# 'false': 'User does not have enough points'
|
||||
CustomPlaceholderReturns: {}
|
||||
|
||||
###########################################
|
||||
# Login options
|
||||
###########################################
|
||||
|
||||
# If true vanished players are treated as if they are offline
|
||||
TreatVanishAsOffline: false
|
||||
|
||||
# Delays login event, delays vote reminding and more
|
||||
# In miliseconds, 1000 = 1 second
|
||||
DelayLoginEvent: 0
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe or LoginSecurity
|
||||
WaitUntilLoggedIn: true
|
||||
|
||||
###########################################
|
||||
# Disable/Enable features
|
||||
###########################################
|
||||
|
||||
# If true, cooldown check is disabled
|
||||
DisableCoolDownCheck: false
|
||||
|
||||
# If true, disable PlayerInteractEvent (for clicking signs and skulls)
|
||||
DisableInteractEvent: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
# Will also disable a few other warnings about vote sites
|
||||
DisableNoServiceSiteMessage: false
|
||||
|
||||
# Count fake votes
|
||||
# If true fake votes will give points and totals
|
||||
CountFakeVotes: true
|
||||
|
||||
# Whether or not to disable update checks
|
||||
DisableUpdateChecking: false
|
||||
|
||||
# Enable per site cooldown events, requires more resources to use
|
||||
# Requires restart
|
||||
PerSiteCoolDownEvents: false
|
||||
|
||||
# Queue votes during a time change (doesn't apply to bungee voting)
|
||||
# Votes will be given when time change is completed
|
||||
QueueVotesDuringTimeChange: false
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Experiemtental feature
|
||||
# Uses https://github.com/BenCodez/VotingPlugin/wiki/Minecraft-Server-Lists
|
||||
# Not all voting sites use the domain name as the service sites
|
||||
# This feature is an attempt to ease setup for new users by matching domain name to actual service site
|
||||
AdvancedServiceSiteHandling: false
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# Disabling this prevents offline votes from adding totals to users
|
||||
AddTotalsOffline: true
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
UseVoteStreaks: true
|
||||
|
||||
# If false, storing best totals will be disabled
|
||||
UseHighestTotals: true
|
||||
|
||||
# Geyser/Bedrock player support
|
||||
# Set prefix used for voting
|
||||
# Players should vote with prefix
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bedrock-Player-Support
|
||||
BedrockPlayerPrefix: '.'
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note: It takes 30-40 minutes before being able to download the latest build
|
||||
# You can also use /av download
|
||||
AutoDownload: false
|
||||
|
||||
# If false plugin will use offline player UUIDs
|
||||
OnlineMode: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
#DisableCheckOnWorldChange: false
|
||||
|
||||
# Disable javascript processing in messages/rewards
|
||||
DisableJavascript: false
|
||||
|
||||
# If true, number of vote shop purchases will be tracked
|
||||
# Data will be tracked in serverdata.yml, may change in the future
|
||||
# No commands to view data currently
|
||||
TrackShopPurchases: false
|
||||
|
||||
# Limits about of offline votesites
|
||||
# Does not currently work with bungee votes from votingplugin
|
||||
OfflineVotesLimit:
|
||||
# Enable or disable
|
||||
Enabled: false
|
||||
# Limit of votes per votesite
|
||||
Amount: 5
|
||||
|
||||
# Default worlds set for all rewards
|
||||
DefaultRewardWorlds: []
|
||||
|
||||
# Default blackedlisted worlds set for all rewards
|
||||
DefaultRewardBlackListedWorlds: []
|
||||
|
||||
###########################################
|
||||
# Skull settings
|
||||
###########################################
|
||||
|
||||
# Preload skulls to improve performance for vote top
|
||||
# when using skulls as the item to display players
|
||||
# If false, skulls will be cached as they are used
|
||||
# assuming loadskulls is enabled
|
||||
PreloadSkulls: false
|
||||
|
||||
# Setting to false disables saving skulls in a cache to improve speeds
|
||||
# Will reduce ram usage (very little) if disabled, but slow GUI speeds when using skulls
|
||||
LoadSkulls: true
|
||||
|
||||
###########################################
|
||||
# Extra checks on vote
|
||||
###########################################
|
||||
|
||||
# If true, allsites will have an extra check to prevent duplicate allsites from being given
|
||||
ExtraAllSitesCheck: false
|
||||
|
||||
# This is an extra safe guard to prevent milestones
|
||||
# from being executed more than once
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
|
||||
# May need to enable this for bungee setups
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
##############################################
|
||||
# Command/Permission settings
|
||||
##############################################
|
||||
|
||||
# Give VotingPlugin.Player by default
|
||||
# Requires restart to take affect
|
||||
GiveDefaultPermission: true
|
||||
|
||||
# Permissions given by VotingPlugin.Player by default
|
||||
# Permissions listed here will no be accessible with the default permission
|
||||
DisabledDefaultPermissions: []
|
||||
|
||||
# If true, /vote will open /vote gui by default
|
||||
UseVoteGUIMainCommand: false
|
||||
|
||||
# Disable checking permissions on tab complete
|
||||
# Could increase performance slightly, but probably not
|
||||
DisableAdvancedTab: false
|
||||
|
||||
# Load command aliases, such as /avgui
|
||||
# Requires restart to take effect
|
||||
LoadCommandAliases: true
|
||||
|
||||
# Use vault for permission checks
|
||||
# May not work on some plugins
|
||||
UseVaultPermissions: false
|
||||
|
||||
# List of disabled commands from /vote
|
||||
# List the specific permission
|
||||
# E.g:
|
||||
# - PERMISSION
|
||||
DisabledCommands: []
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
# Allow transfer of vote points between players
|
||||
# Requires restart for command to load
|
||||
# Command: /vote givepoints (player) (points)
|
||||
AllowVotePointTransfers: false
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
# Requires AddCustomCommand: true to be set
|
||||
CustomCommands:
|
||||
# identifier, not specific name
|
||||
command1:
|
||||
Args:
|
||||
- token
|
||||
# Message to send on command
|
||||
Message: 'token message'
|
||||
# Permission for this command
|
||||
Permission: 'votingplugin.commands.vote.token'
|
||||
# help message
|
||||
HelpMessage: 'See tokens'
|
||||
# Forces player to run this command
|
||||
Commands:
|
||||
- tokencommand
|
||||
|
||||
##############################################
|
||||
# Background task settings
|
||||
##############################################
|
||||
|
||||
# Only update in the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Enable to true for extra player checks
|
||||
# Recommend leaving this to false
|
||||
ExtraBackgroundUpdate: false
|
||||
|
||||
##########################################
|
||||
# Inventory controls
|
||||
##########################################
|
||||
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# If true, items given for rewards are dropped on the ground
|
||||
# If false, items will be given when there is space
|
||||
DropOnFullInv: true
|
||||
|
||||
# This will prevent spam clicking GUI's to prevent exploits
|
||||
# Number is time in between clicking in milliseconds
|
||||
SpamClickTime: 100
|
||||
# Message to send when inventory forced closed when spam clicking
|
||||
# Uncomment to use
|
||||
#SpamClickMessage: '&cDetected spam clicking GUI, closing to prevent exploits'
|
||||
|
||||
# Will force GUI's to close on every click
|
||||
AlwaysCloseInventory: false
|
||||
|
||||
# Close inventory on player vote
|
||||
# This is to prevent any possible exploits
|
||||
CloseInventoryOnVote: true
|
||||
|
||||
# This will close GUI's if you shift click them rather than a regular
|
||||
# This can help prevent exploits
|
||||
CloseGUIOnShiftClick: false
|
||||
|
||||
###########################################
|
||||
# Purge settings
|
||||
###########################################
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
##########################################
|
||||
# Extra options
|
||||
# Options below don't need to be touched
|
||||
##########################################
|
||||
|
||||
# If enabled, data is repulled from storage on vote shop purchase
|
||||
# This prevents possible exploits with vote shop
|
||||
ExtraVoteShopCheck: true
|
||||
|
||||
# Options for request api
|
||||
# Current methods:
|
||||
# ANVIL
|
||||
# BOOK
|
||||
# CHAT
|
||||
# This is mainly used for admin gui's to type in values
|
||||
RequestAPI:
|
||||
DefaultMethod: 'Anvil'
|
||||
DisabledMethods: []
|
||||
|
||||
@@ -1,243 +0,0 @@
|
||||
# To disable reward set value to {}
|
||||
# or remove entirely
|
||||
# Eg:
|
||||
# FirstVote: {} (All in one line)
|
||||
# Rewards will be given if there is a reward to give, otherwise they will be ignored
|
||||
|
||||
# First vote rewards
|
||||
FirstVote:
|
||||
Messages:
|
||||
Player: '&aYou voted for your first time!'
|
||||
|
||||
# First vote of the day reward
|
||||
FirstVoteToday: {}
|
||||
|
||||
# All vote rewards
|
||||
# One time reward for voting on all sites in one day
|
||||
# Enable ExtraAllSitesCheck if you get double rewards
|
||||
AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
# Give a reward for voting on all sites minus 1
|
||||
# Similar to allsites
|
||||
#AlmostAllSites:
|
||||
# Messages:
|
||||
# Player: '&aYou almost voted on all sites in 1 day!'
|
||||
|
||||
|
||||
# If true only cumulative reward at a time can be given
|
||||
# The cumulative rewards will go in order as listed under Cumulative, so if true
|
||||
# the first cumulative (in the order as listed) that can be given will, then will ignore the rest
|
||||
OnlyOneCumulative: false
|
||||
# NOTE: This is not a 1 time reward, that's what milestones are for!
|
||||
# If total votes (Can be changed) divided by cumulative amount
|
||||
# and with no remainder (So divides perfectly) then a reward is given
|
||||
Cumulative:
|
||||
# Number of votes required
|
||||
# Allows multiple cumulative rewards
|
||||
# Number be be around ' (E.g. '1')
|
||||
# Can have multiple listed here
|
||||
'20':
|
||||
Enabled: false
|
||||
# Whether or not votes must be made in same day/week
|
||||
# Useful if you want to require a certain number of voting sites to be voted on
|
||||
# for a daily/weekly reward instead of all of them
|
||||
# Valid options
|
||||
# AllTime
|
||||
# Monthly
|
||||
# Weekly
|
||||
# Daily
|
||||
TotalToUse: AllTime
|
||||
# Blacklist recurring votes
|
||||
#BlackList:
|
||||
#- 40
|
||||
# Whether or not to gives cumulative reward for every x number of votes, default: true
|
||||
#Recurring: true
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %cumulative% cumulative votes!'
|
||||
|
||||
# Vote party configuration
|
||||
VoteParty:
|
||||
# Wether or not vote party is enabled
|
||||
Enabled: false
|
||||
# Number of votes required to give rewards
|
||||
VotesRequired: 20
|
||||
# Increase the amount of votes required on each vote party reached
|
||||
#IncreaseVotesRquired: 10
|
||||
# If true, players who did not vote to reach the votes required will
|
||||
# recieve the reward
|
||||
# If false, only players who voted get rewards
|
||||
GiveAllPlayers: false
|
||||
# If true, give online players the vote party reward
|
||||
# Can also use RewardType: ONLINE if you wanted
|
||||
GiveOnlinePlayersOnly: true
|
||||
# If true, the vote count will reset each day
|
||||
ResetEachDay: false
|
||||
# If true, the vote count will reset each week
|
||||
ResetWeekly: false
|
||||
# Reset at the end of the month
|
||||
ResetMonthly: false
|
||||
# If true, will give voteparty only once per day
|
||||
OnlyOncePerDay: false
|
||||
# If true, will give voteparty once per week only
|
||||
OnlyOncePerWeek: false
|
||||
# Reset extra votes weekly
|
||||
ResetExtraVotesWeekly: false
|
||||
# Reset extra votes monthly
|
||||
ResetExtraVotesMonthly: false
|
||||
# Count votes from /av vote?
|
||||
CountFakeVotes: true
|
||||
# Number of user votes that apply to vote party total the user needs to get rewards
|
||||
UserVotesRequired: 0
|
||||
# Count offline votes
|
||||
CountOfflineVotes: true
|
||||
# Broadcast when vote party reached
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# Send a broadcast at a certain number of votes left and send a vote reminder
|
||||
VoteReminderBroadcast: '%votesrequired% left to go, go vote!'
|
||||
# List of votes required amounts for when to send vote party reminders
|
||||
VoteReminderAtVotes: []
|
||||
# List of commands to execute, these only execute once.
|
||||
# %player% does not work here
|
||||
GlobalCommands: []
|
||||
# List of commands to execute once
|
||||
# Only run will run
|
||||
GlobalRandomCommand: []
|
||||
# Rewards to give per player
|
||||
Rewards:
|
||||
# Uncomment below for online players to be rewarded only
|
||||
#RewardType: ONLINE
|
||||
Commands:
|
||||
- say %player%
|
||||
Items:
|
||||
DIAMOND:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Reset milestones at end of the month
|
||||
ResetMilestonesMonthly: false
|
||||
|
||||
# One time reward to be given (unless you reset it somehow)
|
||||
MileStones:
|
||||
# Number of votes required
|
||||
# Allows multiple milestones
|
||||
# Number be around ' (E.g. '1')
|
||||
# Can have multiple listed here
|
||||
'20':
|
||||
Enabled: false
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %milestone% milestone votes!'
|
||||
|
||||
VoteStreak:
|
||||
# Valid options: Day, Week, Month
|
||||
Day:
|
||||
# Number of days in a row
|
||||
# Each day requires one vote
|
||||
# Add a - to give a reward for every multiple (e.g. 2- = 2,4,6,8, and so on)
|
||||
# This may not work perfectly on bungee setups at this time
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
# Rewards to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: "&aYou voted for %Streak% %Type%'s in a row!"
|
||||
Week:
|
||||
# Number of weeks in a row
|
||||
# Requires atleast one vote per week
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
# Rewards to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: "&aYou voted for %Streak% %Type%'s in a row!"
|
||||
Month:
|
||||
# Number of months in a row
|
||||
# Requires atleast 1 vote per month
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
# Rewards to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: "&aYou voted for %Streak% %Type%'s in a row!"
|
||||
Requirement:
|
||||
# Require certain percentage of votes
|
||||
UsePercentage: false
|
||||
# Percentage requirements of votes
|
||||
# 50 = %50
|
||||
Day: 50
|
||||
Week: 50
|
||||
Month: 50
|
||||
|
||||
# Reward given when all votesites are available to vote on
|
||||
# Don't use this unless you really need it
|
||||
# Little performance intensive
|
||||
# Recommend add RewardType: ONLINE for it to only work online
|
||||
VoteCoolDownEndedReward: []
|
||||
|
||||
# ONLY USE THIS FOR TITLES/SOUNDS AND OTHER EFFECTS
|
||||
# IT WILL ONLY RUN ONE TIME FOR ANY NUMBER OF OFFLINE VOTES (3 offline votes = 1 AnySiteReward)
|
||||
# Any reward files listed here are ran on vote of any site
|
||||
# It is recommended to add rewards to each site instead of here
|
||||
# Using forceoffline won't work here
|
||||
# Use EverySiteReward in VoteSites.yml for a global reward for each site
|
||||
AnySiteRewards: {}
|
||||
|
||||
# Rewards to run when player logs in
|
||||
LoginRewards: {}
|
||||
|
||||
# Rewards to run when player logs off
|
||||
# Will queue until player logs in unless forceoffline is enabled
|
||||
LogoutRewards: {}
|
||||
|
||||
EnableMonthlyAwards: true
|
||||
|
||||
# TopVoter Placeholders:
|
||||
#%place% - place in topvoter
|
||||
#%topvoter% - topvoter type
|
||||
#%votes% - current total votes related to top voter
|
||||
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
# Using 1-10 will reward players in first to tenth place with the same reward
|
||||
1:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in first place in %TopVoter%!'
|
||||
2:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in second place in %TopVoter%!'
|
||||
|
||||
EnableWeeklyAwards: false
|
||||
# Rewards to give on weekly top voter
|
||||
WeeklyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
1:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in first place in %TopVoter%!'
|
||||
2:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in second place in %TopVoter%!'
|
||||
|
||||
EnableDailyRewards: false
|
||||
# Rewards to give on daily top voter
|
||||
DailyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
1:
|
||||
# Reward files to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in first place in %TopVoter%!'
|
||||
2:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in second place in %TopVoter%!'
|
||||
@@ -1,134 +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
|
||||
# Must set a value on VoteDelay if you plan on only using this setting
|
||||
#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,225 +0,0 @@
|
||||
# Set bungeecoord to true on servers on the network (In VotingPlugin)
|
||||
# Set server name in each server related to what it is on bungee
|
||||
#
|
||||
# MYSQL Required on all setups
|
||||
# MYSQL INFO --------------------------
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
# Don't use with PLUGINMESSAGING bungee setup
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
|
||||
####################################################################################
|
||||
# Global mysql data handle for between server commmunications
|
||||
# This is NOT required for bungee voting to work
|
||||
# This is still a WIP, use with caution
|
||||
# This will create a different table then from users storing server info to process
|
||||
#
|
||||
# If you use this you need to enable this on BungeeSettings.yml on each server with votingplugin
|
||||
# Make sure server name is set correctly in BungeeSettings.yml or this will not work correctly
|
||||
#
|
||||
# Please use PLUGINMESSAGING for this, SOCKETS should work as well, but not fully tested
|
||||
#
|
||||
# This will make votes cache until time change has finished processing
|
||||
# In the event a server is offline or time change fails, the time change process
|
||||
# will continue after a set amount of time (in essense skipping a specific server)
|
||||
# This will also respect blocked servers
|
||||
GlobalData:
|
||||
Enabled: false
|
||||
# Use existing connection above
|
||||
UseMainMySQL: true
|
||||
# Mysql settings only used if above is false
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Must be the same on all servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
#Attempt to use mariadb driver
|
||||
#UseMariaDB: false
|
||||
|
||||
# Time offset for time changes
|
||||
# Must match on all servers
|
||||
TimeHourOffSet: 0
|
||||
|
||||
####################################################################################
|
||||
|
||||
Debug: false
|
||||
# Have a reward on each server
|
||||
# If false, will send to online server only
|
||||
SendVotesToAllServers: true
|
||||
# List of servers the plugin won't send the vote to
|
||||
# Uses names from bungeecoord config, only needed for non SOCKETS setup
|
||||
BlockedServers:
|
||||
- hub
|
||||
|
||||
|
||||
# Similar to BlockServers
|
||||
# If a server is listed then blockedservers is ignored
|
||||
WhiteListedServers: []
|
||||
|
||||
# What type of bungee setup
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING (Recommended)
|
||||
# MYSQL
|
||||
# REDIS
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
# Use Redis for between server communication, set BungeeMethod to REDIS to use this
|
||||
Redis:
|
||||
Host: localhost
|
||||
Port: 6379
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Set a prefix from an entire proxy network if using mutli-proxy setup below
|
||||
Prefix: ''
|
||||
|
||||
# If false, votes will be checked if user is a valid player that has joined to server
|
||||
# Works for PLUGINMESSAGING and SOCKETS methods only
|
||||
# This requires spigot servers AllowUnJoined to be set to true in Config.yml
|
||||
AllowUnJoined: false
|
||||
|
||||
# Points to give on vote
|
||||
PointsOnVote: 1
|
||||
|
||||
# If true, bungee will handle adding totals
|
||||
# If false, spigot servers will EACH set their own totals
|
||||
# If false, AllowUnJoined should be enabled on bungee, spigot servers will handle that
|
||||
# Recommeneded to leave enabled, setups with this disabled are currently unsupported
|
||||
BungeeManageTotals: true
|
||||
|
||||
# Tell servers to broadcast
|
||||
# Set DisableBroadcast to true on spigot servers (BungeeSettings.yml) as well
|
||||
Broadcast: true
|
||||
|
||||
# Geyser/bedrock player settings
|
||||
# https://github.com/BenCodez/VotingPlugin/wiki/Bedrock-Player-Support
|
||||
BedrockPlayerPrefix: '.'
|
||||
|
||||
# Time votes will be cached on proxy
|
||||
# -1 means no time limit
|
||||
# Time in days
|
||||
VoteCacheTime: -1
|
||||
|
||||
# Maxium number of votes possible per day
|
||||
# Usually matches the amount of votesites
|
||||
# Will limit vote totals to match accordingly
|
||||
# Only applies for month total
|
||||
# Set to -1 to disable
|
||||
MaxAmountOfVotesPerDay: -1
|
||||
|
||||
VoteParty:
|
||||
# If enabled, will trigger vote party reward
|
||||
# in BungeeSettings.yml under BungeeVotePartyReward
|
||||
# Only runs rewards for online players
|
||||
Enabled: false
|
||||
# Votes required
|
||||
VotesRequired: 100
|
||||
# Increase amount required on each vote party
|
||||
IncreaseVotesRequired: 0
|
||||
# If false, will only send to servers listed below
|
||||
SendToAllServers: true
|
||||
# Servers to send to, if SendToAllServers is false
|
||||
ServersToSend: []
|
||||
# List of commands to run on bungee server
|
||||
# Set spigot commands in BungeeSettings.yml
|
||||
BungeeCommands: []
|
||||
Broadcast: '&aVote party has been reached!'
|
||||
|
||||
# Online mode for UUIDS
|
||||
# Offline mode setups are not fully tested and are not supported currently
|
||||
OnlineMode: true
|
||||
|
||||
##########################################
|
||||
# PLUGINMESSAGING Settings
|
||||
##########################################
|
||||
|
||||
# Applies to PLUGINMESSAGING only
|
||||
# Votes will be forwarded when specific player is online
|
||||
# If set to false, rewards should still reward when player logs in (by default)
|
||||
WaitForUserOnline: false
|
||||
|
||||
|
||||
##########################################
|
||||
# Multi-proxy setup
|
||||
# This is still a WIP, use with caution
|
||||
# Primary server needs votifier and config option enabled
|
||||
# Set socket host on each proxy and primary server set sub proxies
|
||||
# All servers should be on pluginmessaging or sockets setup
|
||||
##########################################
|
||||
|
||||
# Support for multiple proxies
|
||||
MultiProxySupport: false
|
||||
|
||||
# Enable on primary proxy server with votifier
|
||||
PrimaryServer: false
|
||||
|
||||
# If enabled, player will only get 1 reward on a server on the network
|
||||
# Must be enabled on all proxies for this to work
|
||||
# Must also disable sendtoallservers
|
||||
MultiProxyOneGlobalReward: false
|
||||
|
||||
# Multi-proxy available methods:
|
||||
# SOCKET
|
||||
# REDIS
|
||||
MultiProxyMethod: SOCKET
|
||||
|
||||
##########################################
|
||||
# REDIS Settings
|
||||
##########################################
|
||||
|
||||
# Set multiproxymethod to REDIS to use redis
|
||||
MultiProxyRedis:
|
||||
# If true the plugin will use the exsiting connection set above
|
||||
# Must be on REDIS method to use this setting
|
||||
UseExistingConnection: false
|
||||
Host: localhost
|
||||
Port: 6379
|
||||
Username: ''
|
||||
Password: ''
|
||||
|
||||
# Set each server it's own proxy name here (can be anything)
|
||||
ProxyServerName: proxy1
|
||||
|
||||
# Set names of other proxy servers
|
||||
# Must match what's set as the proxy server name above from other servers
|
||||
# On non primary proxy server just set the primary proxy server name here
|
||||
ProxyServers:
|
||||
- proxy2
|
||||
- proxy3
|
||||
|
||||
##########################################
|
||||
# SOCKET settings for mutli-proxy
|
||||
##########################################
|
||||
|
||||
# Set this for each proxy
|
||||
MultiProxySocketHost:
|
||||
Host: 0.0.0.0
|
||||
Port: 1234
|
||||
|
||||
# Set other sub proxies here
|
||||
# On non primary proxy only set primary proxy
|
||||
MultiProxyServers:
|
||||
secondproxy:
|
||||
Host: 0.0.0.0
|
||||
Port: 1235
|
||||
+659
-555
File diff suppressed because it is too large.
Load diff
@@ -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,889 +0,0 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.advancedcore.api.time.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.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.bungee.BungeeVersion;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeHandler implements Listener {
|
||||
@Getter
|
||||
private ClientHandler clientHandler;
|
||||
|
||||
private EncryptionHandler encryptionHandler;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyCurrent = -2;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyRequired = -2;
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private GlobalDataHandler globalDataHandler;
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
@Getter
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Getter
|
||||
private GlobalMessageHandler globalMessageHandler;
|
||||
|
||||
private Thread redisThread;
|
||||
|
||||
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());
|
||||
|
||||
if (data.containsKey("ForceUpdate")) {
|
||||
boolean b = checkGlobalDataTimeValue(data.get("ForceUpdate"));
|
||||
if (b) {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "ForceUpdate", false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean forceUpdate = false;
|
||||
|
||||
if (checkGlobalDataTime(TimeType.MONTH, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.WEEK, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.DAY, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<String, DataValue>();
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(true));
|
||||
dataToSet.put("Processing", new DataValueBoolean(false));
|
||||
globalDataHandler.setData(plugin.getBungeeSettings().getServer(), dataToSet);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
|
||||
public boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
|
||||
boolean isProcessing = false;
|
||||
if (data.containsKey(type.toString())) {
|
||||
|
||||
DataValue value = data.get(type.toString());
|
||||
boolean b = checkGlobalDataTimeValue(value);
|
||||
if (b) {
|
||||
long lastUpdated = Long.valueOf(data.get("LastUpdated").getString()).longValue();
|
||||
plugin.debug("LastUpdated: " + lastUpdated);
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastUpdated > 1000 * 60 * 60
|
||||
* 2) {
|
||||
plugin.getLogger().warning("Ignoring bungee time change since it was more than 2 hours ago");
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
return false;
|
||||
}
|
||||
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "Processing", true);
|
||||
isProcessing = true;
|
||||
|
||||
plugin.debug("Detected time change from bungee: " + type.toString());
|
||||
plugin.getTimeChecker().forceChanged(type, false, true, true);
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
}
|
||||
}
|
||||
return isProcessing;
|
||||
}
|
||||
|
||||
public void loadGlobalMysql() {
|
||||
if (plugin.getBungeeSettings().isGloblalDataEnabled()) {
|
||||
if (timer != null) {
|
||||
timer.shutdown();
|
||||
try {
|
||||
timer.awaitTermination(5, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
timer.shutdownNow();
|
||||
}
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkGlobalData();
|
||||
}
|
||||
}, 60, 10, TimeUnit.SECONDS);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
globalDataHandler.setString(plugin.getBungeeSettings().getServer(), "LastOnline",
|
||||
"" + LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli());
|
||||
}
|
||||
}, 1, 60, TimeUnit.MINUTES);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
if (plugin.getBungeeSettings().isGloblalDataUseMainMySQL()
|
||||
&& plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", plugin.getMysql().getMysql()) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
globalDataHandler = new GlobalDataHandler(
|
||||
new GlobalMySQL("VotingPlugin_GlobalData", new MysqlConfigSpigot(
|
||||
plugin.getBungeeSettings().getData().getConfigurationSection("GlobalData"))) {
|
||||
|
||||
@Override
|
||||
public void warning(String text) {
|
||||
plugin.getLogger().warning(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void severe(String text) {
|
||||
plugin.getLogger().severe(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(Exception e) {
|
||||
plugin.debug(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String text) {
|
||||
plugin.debug(text);
|
||||
}
|
||||
});
|
||||
}
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("IgnoreTime", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("MONTH", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("WEEK", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("DAY", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("FinishedProcessing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("Processing", "VARCHAR(5)");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("LastUpdated", "MEDIUMTEXT");
|
||||
globalDataHandler.getGlobalMysql().alterColumnType("ForceUpdate", "VARCHAR(5)");
|
||||
plugin.getTimeChecker().setProcessingEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void load() {
|
||||
plugin.debug("Loading bungee handler");
|
||||
|
||||
method = BungeeMethod.getByName(plugin.getBungeeSettings().getBungeeMethod());
|
||||
|
||||
plugin.getLogger().info("Using BungeeMethod: " + method.toString());
|
||||
|
||||
loadGlobalMysql();
|
||||
|
||||
globalMessageHandler = new GlobalMessageHandler() {
|
||||
|
||||
@Override
|
||||
public void sendMessage(String subChannel, String... messageData) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendPluginMessage(subChannel, messageData);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
sendData(ArrayUtils.convert(list));
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
list.add(subChannel);
|
||||
list.addAll(ArrayUtils.convert(messageData));
|
||||
redisHandler.sendMessage(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
|
||||
ArrayUtils.convert(list));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("Vote") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 8) {
|
||||
int bungeeVersion = Integer.parseInt(args.get(8));
|
||||
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers"
|
||||
+ bungeeVersion + ":" + BungeeVersion.getPluginMessageVersion());
|
||||
return;
|
||||
}
|
||||
|
||||
String player = args.get(0);
|
||||
String uuid = args.get(1);
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
plugin.debug("pluginmessaging vote received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), player);
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
boolean setTotals = Boolean.valueOf(args.get(7));
|
||||
|
||||
user.cache();
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteOnline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 8) {
|
||||
int bungeeVersion = Integer.parseInt(args.get(8));
|
||||
if (bungeeVersion != BungeeVersion.getPluginMessageVersion()) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
return;
|
||||
}
|
||||
String player = args.get(0);
|
||||
String uuid = args.get(1);
|
||||
String service = args.get(2);
|
||||
long time = Long.parseLong(args.get(3));
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getPlaceholders().onBungeeVotePartyUpdate();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
plugin.debug("pluginmessaging voteonline received from " + player + "/" + uuid + " on " + service);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.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));
|
||||
|
||||
boolean broadcast = true;
|
||||
boolean bungeeBroadcast = false;
|
||||
|
||||
if (args.size() > 9) {
|
||||
bungeeBroadcast = Boolean.valueOf(args.get(9));
|
||||
}
|
||||
|
||||
int num = 1;
|
||||
if (args.size() > 10) {
|
||||
num = Integer.valueOf(args.get(10));
|
||||
}
|
||||
|
||||
int numberOfVotes = 1;
|
||||
if (args.size() > 11) {
|
||||
numberOfVotes = Integer.valueOf(args.get(11));
|
||||
}
|
||||
|
||||
if (!bungeeBroadcast) {
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()
|
||||
&& !plugin.getBungeeSettings().isDisableBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
if (plugin.getConfigFile().isFormatOnlyOneOfflineBroadcast() && !wasOnline) {
|
||||
if (num == 1) {
|
||||
user.offlineBroadcast(user, plugin.getBungeeSettings().isUseBungeecoord(),
|
||||
numberOfVotes);
|
||||
}
|
||||
} else {
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
broadcast = false;
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
broadcast = false;
|
||||
}
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text, !setTotals, wasOnline, broadcast, num);
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
plugin.getSpecialRewards().bungeeAllSitesCheck(user, numberOfVotes, num);
|
||||
|
||||
if (Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
} else {
|
||||
plugin.getLogger().warning("Incompatible version with bungee, please update all servers");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteUpdate") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(player));
|
||||
user.cache();
|
||||
|
||||
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));
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("BungeeTimeChange") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
VoteSite site = plugin.getVoteSite(service, true);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VoteBroadcastOffline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
if (args.size() > 2) {
|
||||
String uuid = args.get(0);
|
||||
String votes = args.get(2);
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), args.get(1));
|
||||
user.offlineBroadcast(user, false, Integer.parseInt(votes));
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("Status") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String server = args.get(0);
|
||||
sendMessage(globalMessageHandler, "statusokay", server);
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("ServerName") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String server = args.get(0);
|
||||
if (!plugin.getOptions().getServer().equals(server)) {
|
||||
plugin.getLogger().warning("Server name doesn't match in BungeeSettings.yml, should be " + server);
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBungee") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(ArrayList<String> args) {
|
||||
String broadcast = args.get(0);
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
} 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.makeStringList(ArrayUtils.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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
redisThread = new Thread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.isEnabled()) {
|
||||
redisHandler.loadListener(
|
||||
new RedisListener(redisHandler, plugin.getBungeeSettings().getRedisPrefix()
|
||||
+ "VotingPlugin_" + plugin.getBungeeSettings().getServer()));
|
||||
}
|
||||
}
|
||||
});
|
||||
redisThread.start();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
|
||||
bungeeVotePartyCurrent = plugin.getServerData().getBungeeVotePartyCurrent();
|
||||
bungeeVotePartyRequired = plugin.getServerData().getBungeeVotePartyRequired();
|
||||
|
||||
plugin.getPluginMessaging().setDebug(plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
globalMessageHandler.onMessage("Vote", 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"));
|
||||
|
||||
clientHandler = new ClientHandler(plugin.getBungeeSettings().getBungeeServerHost(),
|
||||
plugin.getBungeeSettings().getBungeeServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
socketHandler = new SocketHandler(plugin.getVersion(), plugin.getBungeeSettings().getSpigotServerHost(),
|
||||
plugin.getBungeeSettings().getSpigotServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
plugin.getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevote") {
|
||||
|
||||
@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]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeTimeChange") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevoteonline") {
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendData(String... strings) {
|
||||
clientHandler.sendMessage(strings);
|
||||
}
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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>();
|
||||
|
||||
public BroadcastHandler(VotingPluginMain plugin, int delay) {
|
||||
this.plugin = plugin;
|
||||
schedule(delay);
|
||||
}
|
||||
|
||||
public void check() {
|
||||
int size = votedPlayers.size();
|
||||
if (size > 0) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
votedPlayers.poll();
|
||||
}
|
||||
String bc = MessageAPI.colorize(plugin.getConfigFile().getFormatAlternateBroadcastBroadcast());
|
||||
String playersText = "";
|
||||
while (!votedPlayers.isEmpty()) {
|
||||
playersText += votedPlayers.remove();
|
||||
if (!votedPlayers.isEmpty()) {
|
||||
playersText += ", ";
|
||||
}
|
||||
}
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("numberofplayers", "" + size);
|
||||
placeholders.put("players", playersText);
|
||||
bc = PlaceholderUtils.replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!plugin.getVotingPluginUserManager().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
MiscUtils.getInstance().broadcast(bc, players);
|
||||
}
|
||||
}
|
||||
|
||||
public void onVote(String player) {
|
||||
votedPlayers.add(player);
|
||||
}
|
||||
|
||||
public void schedule(int delay) {
|
||||
if (timer != null) {
|
||||
timer.shutdownNow();
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
} else {
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
check();
|
||||
}
|
||||
}, 60, 60 * delay, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class BungeeMessageData {
|
||||
|
||||
// Message string
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount//votepartycurrent//votepartyrequired
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int allTimeTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int dailyTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int milestoneCount = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int monthTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int points = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int weeklyTotal = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int votePartyCurrent = 0;
|
||||
@Getter
|
||||
@Setter
|
||||
private int votePartyRequired = 0;
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
int milestoneCount, int votePartyCurrent, int votePartyRequired) {
|
||||
this.allTimeTotal = allTimeTotal;
|
||||
this.monthTotal = monthTotal;
|
||||
this.weeklyTotal = weeklyTotal;
|
||||
this.dailyTotal = dailyTotal;
|
||||
this.points = points;
|
||||
this.milestoneCount = milestoneCount;
|
||||
this.votePartyCurrent = votePartyCurrent;
|
||||
this.votePartyRequired = votePartyRequired;
|
||||
}
|
||||
|
||||
public BungeeMessageData(String str) {
|
||||
String[] data = str.split(Pattern.quote("//"));
|
||||
if (data.length >= 6) {
|
||||
allTimeTotal = Integer.parseInt(data[0]);
|
||||
monthTotal = Integer.parseInt(data[1]);
|
||||
weeklyTotal = Integer.parseInt(data[2]);
|
||||
dailyTotal = Integer.parseInt(data[3]);
|
||||
points = Integer.parseInt(data[4]);
|
||||
milestoneCount = Integer.parseInt(data[5]);
|
||||
}
|
||||
if (data.length >= 8) {
|
||||
votePartyCurrent = Integer.parseInt(data[6]);
|
||||
votePartyRequired = Integer.parseInt(data[7]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allTimeTotal + "//" + monthTotal + "//" + weeklyTotal + "//" + dailyTotal + "//" + points + "//"
|
||||
+ milestoneCount + "//" + votePartyCurrent + "//" + votePartyRequired;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
public enum BungeeMethod {
|
||||
MYSQL, PLUGINMESSAGING, SOCKETS, REDIS;
|
||||
|
||||
public static BungeeMethod getByName(String str) {
|
||||
for (BungeeMethod method : values()) {
|
||||
if (method.toString().equalsIgnoreCase(str)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return PLUGINMESSAGING;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
public class BungeeVersion {
|
||||
public static int getPluginMessageVersion() {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,247 +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 getRedisPrefix() {
|
||||
return getData().getString("Redis.Prefix", "");
|
||||
}
|
||||
|
||||
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 String getMultiProxyMethod() {
|
||||
return getData().getString("MultiProxyMethod", "SOCKET");
|
||||
}
|
||||
|
||||
public String getProxyServerName() {
|
||||
return getData().getString("ProxyServerName", "SOCKET");
|
||||
}
|
||||
|
||||
public List<String> getProxyServers() {
|
||||
return getData().getStringList("ProxyServers");
|
||||
}
|
||||
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getData().getBoolean("MultiProxyRedis.UseExistingConnection", false);
|
||||
}
|
||||
|
||||
public List<String> getVotePartyServersToSend() {
|
||||
return getData().getStringList("VoteParty.ServersToSend");
|
||||
}
|
||||
|
||||
public List<String> getVotePartyBungeeCommands() {
|
||||
return getData().getStringList("VoteParty.BungeeCommands");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getData().getString("MultiProxyRedis.Host", "");
|
||||
}
|
||||
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getData().getInt("MultiProxyRedis.Port", 6379);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getData().getString("MultiProxyRedis.Username", "");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getData().getString("MultiProxyRedis.Password", "");
|
||||
}
|
||||
|
||||
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,34 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class OfflineBungeeVote {
|
||||
|
||||
@Getter
|
||||
private String playerName;
|
||||
@Getter
|
||||
private boolean realVote;
|
||||
@Getter
|
||||
private String service;
|
||||
@Getter
|
||||
private String text;
|
||||
@Getter
|
||||
private long time;
|
||||
@Getter
|
||||
private String uuid;
|
||||
|
||||
public OfflineBungeeVote(String playerName, String uuid, String service, long time, boolean realVote, String text) {
|
||||
this.playerName = playerName;
|
||||
this.uuid = uuid;
|
||||
this.service = service;
|
||||
this.time = time;
|
||||
this.realVote = realVote;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VoteCache:" + playerName + "/" + uuid + "/" + service + "/" + time + "/" + realVote + "/" + text;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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.getMultiProxyHandler().sendMultiProxyServerMessage("Status");
|
||||
sender.sendMessage(new TextComponent("Sending 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
-229
@@ -1,229 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
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 lombok.Getter;
|
||||
|
||||
public abstract class MultiProxyHandler {
|
||||
public abstract boolean getMultiProxySupportEnabled();
|
||||
|
||||
public abstract EncryptionHandler getEncryptionHandler();
|
||||
|
||||
public abstract File getPluginDataFolder();
|
||||
|
||||
public abstract void setEncryptionHandler(EncryptionHandler encryptionHandler);
|
||||
|
||||
public abstract void logInfo(String msg);
|
||||
|
||||
public abstract boolean getDebug();
|
||||
|
||||
public abstract String getVersion();
|
||||
|
||||
private HashMap<String, ClientHandler> multiproxyClientHandles;
|
||||
|
||||
private SocketHandler multiproxySocketHandler;
|
||||
|
||||
@Getter
|
||||
private RedisHandler multiProxyRedis;
|
||||
|
||||
public MultiProxyHandler() {
|
||||
|
||||
}
|
||||
|
||||
public void sendMultiProxyServerMessage(String... messageData) {
|
||||
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
|
||||
for (ClientHandler h : multiproxyClientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
} else if (getMultiProxyMethod().equals(MultiProxyMethod.REDIS)) {
|
||||
for (String server : getProxyServers()) {
|
||||
multiProxyRedis.sendMessage("VotingPluginProxy_" + server, messageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract List<String> getProxyServers();
|
||||
|
||||
public void close() {
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
if (multiProxyRedis != null && !getMultiProxyRedisUseExistingConnection()) {
|
||||
multiProxyRedis.close();
|
||||
}
|
||||
}
|
||||
|
||||
public void loadMultiProxySupport() {
|
||||
if (getMultiProxySupportEnabled()) {
|
||||
if (getMultiProxyMethod().equals(MultiProxyMethod.SOCKETS)) {
|
||||
if (getEncryptionHandler() == null) {
|
||||
setEncryptionHandler(new EncryptionHandler(new File(getPluginDataFolder(), "secretkey.key")));
|
||||
}
|
||||
|
||||
if (multiproxySocketHandler != null) {
|
||||
multiproxySocketHandler.closeConnection();
|
||||
multiproxySocketHandler = null;
|
||||
}
|
||||
multiproxySocketHandler = new SocketHandler(getVersion(), getMultiProxySocketHostHost(),
|
||||
getMultiProxySocketHostPort(), getEncryptionHandler(), getDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
logInfo(str);
|
||||
}
|
||||
};
|
||||
|
||||
multiproxySocketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 0) {
|
||||
if (data[0].equalsIgnoreCase("Status")) {
|
||||
logInfo("Multi-proxy status message received");
|
||||
} else if (data[0].equalsIgnoreCase("ClearVote")) {
|
||||
clearVote(data[2]);
|
||||
if (getPrimaryServer()) {
|
||||
sendMultiProxyServerMessage("ClearVotePrimary", data[1], data[2]);
|
||||
}
|
||||
} else if (data[0].equalsIgnoreCase("ClearVotePrimary")) {
|
||||
clearVote(data[2]);
|
||||
} else if (data[0].equalsIgnoreCase("login")) {
|
||||
addNonVotedPlayerCache(data[1], data[2]);
|
||||
// nonVotedPlayersCache.addPlayer(data[1], data[2]);
|
||||
}
|
||||
}
|
||||
if (data.length > 8) {
|
||||
if (data[0].equalsIgnoreCase("Vote")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
multiproxyClientHandles = new HashMap<String, ClientHandler>();
|
||||
for (String s : getMultiProxyServers()) {
|
||||
MultiProxyServerSocketConfiguration d = getMultiProxyServersConfiguration(s);
|
||||
multiproxyClientHandles.put(s,
|
||||
new ClientHandler(d.getHost(), d.getPort(), getEncryptionHandler(), getDebug()));
|
||||
}
|
||||
|
||||
} else {
|
||||
if (getMultiProxyRedisUseExistingConnection() && getRedisHandler() != null) {
|
||||
multiProxyRedis = getRedisHandler();
|
||||
} else {
|
||||
multiProxyRedis = new RedisHandler(getMultiProxyRedisHost(), getMultiProxyRedisPort(),
|
||||
getMultiProxyUsername(), getMultiProxyPassword()) {
|
||||
|
||||
@Override
|
||||
public void onMessage(String channel, String[] data) {
|
||||
if (data.length > 0) {
|
||||
if (data[0].equalsIgnoreCase("Status")) {
|
||||
logInfo("Multi-proxy status message received");
|
||||
} else if (data[0].equalsIgnoreCase("ClearVote")) {
|
||||
clearVote(data[2]);
|
||||
if (getPrimaryServer()) {
|
||||
sendMultiProxyServerMessage("ClearVotePrimary", data[1], data[2]);
|
||||
}
|
||||
} else if (data[0].equalsIgnoreCase("ClearVotePrimary")) {
|
||||
clearVote(data[2]);
|
||||
} else if (data[0].equalsIgnoreCase("login")) {
|
||||
addNonVotedPlayerCache(data[1], data[2]);
|
||||
// nonVotedPlayersCache.addPlayer(data[1], data[2]);
|
||||
}
|
||||
}
|
||||
if (data.length > 8) {
|
||||
if (data[0].equalsIgnoreCase("Vote")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
} else if (data[0].equalsIgnoreCase("VoteOnline")) {
|
||||
triggerVote(data[2], data[3], Boolean.valueOf(data[7]), true, 0,
|
||||
new BungeeMessageData(data[8]), data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (getDebug()) {
|
||||
logInfo("MultiProxyRedis: " + message);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
runAsnc(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
multiProxyRedis.loadListener(
|
||||
new RedisListener(multiProxyRedis, "VotingPluginProxy_" + getMultiProxyServerName()));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
logInfo("Loaded multi-proxy support: " + getMultiProxyMethod().toString());
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void runAsnc(Runnable runnable);
|
||||
|
||||
public abstract MultiProxyMethod getMultiProxyMethod();
|
||||
|
||||
public abstract RedisHandler getRedisHandler();
|
||||
|
||||
public abstract boolean getMultiProxyRedisUseExistingConnection();
|
||||
|
||||
public abstract String getMultiProxyPassword();
|
||||
|
||||
public abstract String getMultiProxyUsername();
|
||||
|
||||
public abstract String getMultiProxyServerName();
|
||||
|
||||
public abstract int getMultiProxyRedisPort();
|
||||
|
||||
public abstract String getMultiProxyRedisHost();
|
||||
|
||||
public abstract boolean getPrimaryServer();
|
||||
|
||||
public void login(String uuid, String playerName) {
|
||||
if (!getMultiProxySupportEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (getPrimaryServer()) {
|
||||
return;
|
||||
}
|
||||
sendMultiProxyServerMessage("Login", uuid, playerName);
|
||||
}
|
||||
|
||||
public abstract int getMultiProxySocketHostPort();
|
||||
|
||||
public abstract String getMultiProxySocketHostHost();
|
||||
|
||||
public abstract MultiProxyServerSocketConfiguration getMultiProxyServersConfiguration(String s);
|
||||
|
||||
public abstract Collection<String> getMultiProxyServers();
|
||||
|
||||
public abstract void triggerVote(String player, String service, boolean realVote, boolean timeQueue, long queueTime,
|
||||
BungeeMessageData text, String uuid);
|
||||
|
||||
public abstract void addNonVotedPlayerCache(String string, String string2);
|
||||
|
||||
public abstract void clearVote(String string);
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
public enum MultiProxyMethod {
|
||||
SOCKETS, REDIS;
|
||||
|
||||
public static MultiProxyMethod getByName(String str) {
|
||||
for (MultiProxyMethod method : values()) {
|
||||
if (method.toString().equalsIgnoreCase(str)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return MultiProxyMethod.SOCKETS;
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
public interface MultiProxyServerSocketConfiguration {
|
||||
String getServerName();
|
||||
|
||||
String getHost();
|
||||
|
||||
int getPort();
|
||||
}
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.global.multiproxy;
|
||||
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
public class MultiProxyServerSocketConfigurationBungee implements MultiProxyServerSocketConfiguration {
|
||||
private String server;
|
||||
private String host;
|
||||
private int port;
|
||||
|
||||
public MultiProxyServerSocketConfigurationBungee(String s, Configuration config) {
|
||||
server = s;
|
||||
host = config.getString("Host", "");
|
||||
port = config.getInt("Port", 1234);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,220 +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.simpleapi.file.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 getRedisPrefix() {
|
||||
return getString(getNode("Redis", "Prefix"), "");
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public String getMultiProxyMethod() {
|
||||
return getString(getNode("MultiProxyMethod"), "SOCKET");
|
||||
}
|
||||
|
||||
public String getProxyServerName() {
|
||||
return getString(getNode("ProxyServerName"), "SOCKET");
|
||||
}
|
||||
|
||||
public List<String> getProxyServers() {
|
||||
return getStringList(getNode("ProxyServers"), new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getMultiProxyRedisUseExistingConnection() {
|
||||
return getBoolean(getNode("MultiProxyRedis", "UseExistingConnection"), false);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisHost() {
|
||||
return getString(getNode("MultiProxyRedis", "Host"), "");
|
||||
}
|
||||
|
||||
public int getMultiProxyRedisPort() {
|
||||
return getInt(getNode("MultiProxyRedis", "Port"), 6379);
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisUsername() {
|
||||
return getString(getNode("MultiProxyRedis", "Username"), "");
|
||||
}
|
||||
|
||||
public String getMultiProxyRedisPassword() {
|
||||
return getString(getNode("MultiProxyRedis", "Password"), "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bencodez.simpleapi.file.velocity.VelocityJSONFile;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
|
||||
public class NonVotedPlayersCache extends VelocityJSONFile {
|
||||
|
||||
private VotingPluginVelocity plugin;
|
||||
|
||||
public NonVotedPlayersCache(File file, VotingPluginVelocity plugin) {
|
||||
super(file);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
if (!plugin.getMysql().containsKeyQuery(player.getUniqueId().toString())) {
|
||||
addPlayer(player.getUniqueId().toString(), player.getUsername());
|
||||
}
|
||||
}
|
||||
|
||||
public void addPlayer(String uuid, String playerName) {
|
||||
getNode("NonVotedPlayers", playerName, "UUID").setValue(uuid);
|
||||
getNode("NonVotedPlayers", playerName, "LastTime").setValue(System.currentTimeMillis());
|
||||
save();
|
||||
}
|
||||
|
||||
public void addPlayerCheck(String uuid, String playerName) {
|
||||
if (!plugin.getMysql().containsKeyQuery(uuid)) {
|
||||
addPlayer(uuid, playerName);
|
||||
}
|
||||
}
|
||||
|
||||
public void check() {
|
||||
for (String player : getKeys(getNode("NonVotedPlayers"))) {
|
||||
long time = getNode("NonVotedPlayers", player, "LastTime").getLong(0);
|
||||
if ((System.currentTimeMillis() - time) > 1000 * 60 * 60 * 24 * 5) {
|
||||
remove(player);
|
||||
} else {
|
||||
String uuid = getNode("NonVotedPlayers", player, "UUID").getString("");
|
||||
if (!uuid.isEmpty()) {
|
||||
if (plugin.getMysql().containsKeyQuery(uuid)) {
|
||||
remove(player);
|
||||
}
|
||||
} else {
|
||||
remove(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
save();
|
||||
}
|
||||
|
||||
public String playerExists(String playerName) {
|
||||
if (!getNode("NonVotedPlayers", playerName).isEmpty()) {
|
||||
return getNode("NonVotedPlayers", playerName, "UUID").getString("");
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private void remove(String player) {
|
||||
plugin.debug("Removing nonvotedplayer: " + player);
|
||||
|
||||
getNode("NonVotedPlayers", player).setValue(null);
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package com.bencodez.votingplugin.bungee.velocity;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.bencodez.simpleapi.file.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);
|
||||
}
|
||||
|
||||
}
|
||||
-1726
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.getMultiProxyHandler().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");
|
||||
}
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.cumulative;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.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 {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteCumulative(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit Cumulative");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.Cumulative");
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cEdit existing cumulative rewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
if (MessageAPI.isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
}
|
||||
}
|
||||
Number[] options = new Number[nums.size()];
|
||||
for (int i = 0; i < nums.size(); i++) {
|
||||
options[i] = nums.get(i);
|
||||
}
|
||||
new ValueRequestBuilder(new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler()
|
||||
.getDirectlyDefined("Cumulative." + value.intValue() + ".Rewards"));
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
|
||||
.request(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd cumulative reward")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ValueRequest().requestNumber(player, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
plugin.getSpecialRewardsConfig().setCumulative(value.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove cumulative")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteCumulativeRemove(plugin, clickEvent.getPlayer()).open();
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-78
@@ -1,78 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.cumulative;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.commands.gui.admin.AdminVoteConfirmation;
|
||||
|
||||
public class AdminVoteCumulativeRemove extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteCumulativeRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Remove cumulative");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.Cumulative");
|
||||
for (final String votes : plugin.getSpecialRewardsConfig().getCumulativeVotes()) {
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(Material.PAPER, 1).setName(votes).addLoreLine("&c&lClick to remove")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteConfirmation(plugin, clickEvent.getPlayer(), "Remove cumulative " + votes + "?") {
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getSpecialRewardsConfig().removeCumulative(votes);
|
||||
p.sendMessage("Removed cumulative " + votes);
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteCumulative(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.milestones;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.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 {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteMilestones(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit MileStones");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.MileStones");
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&cEdit existing milestone rewards")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
for (String num : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
if (MessageAPI.isInt(num)) {
|
||||
nums.add(Integer.parseInt(num));
|
||||
}
|
||||
}
|
||||
Number[] options = new Number[nums.size()];
|
||||
for (int i = 0; i < nums.size(); i++) {
|
||||
options[i] = nums.get(i);
|
||||
}
|
||||
new ValueRequestBuilder(new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler()
|
||||
.getDirectlyDefined("MileStones." + value.intValue() + ".Rewards"));
|
||||
}
|
||||
}, options).allowCustomOption(false).usingMethod(InputMethod.INVENTORY)
|
||||
.request(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd milestone")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ValueRequest().requestNumber(player, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
plugin.getSpecialRewardsConfig().setMilestone(value.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove milestone")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteMilestoneRemove(plugin, clickEvent.getPlayer()).open();
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,213 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.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;
|
||||
|
||||
public class VoteShop extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteShop(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (!plugin.getGui().isChestVoteShopEnabled()) {
|
||||
player.sendMessage(MessageAPI.colorize(plugin.getGui().getChestVoteShopDisabled()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
/*
|
||||
* if (!plugin.getConfigFile().isExtraVoteShopCheck()) { user.cacheAsync(); }
|
||||
*/
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("sitesavailable", "" + user.getSitesNotVotedOn());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
|
||||
String perm = plugin.getGui().getChestVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
if (perm.startsWith("!")) {
|
||||
hasPerm = !player.hasPermission(perm.substring(1));
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
}
|
||||
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
|
||||
if ((hasPerm || !plugin.getGui().getChestVoteShopHideOnNoPermission(identifier))
|
||||
&& (limitPass || !plugin.getGui().isChestVoteShopHideLimitedReached())) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
if (plugin.getConfigFile().isExtraVoteShopCheck()) {
|
||||
user.cache();
|
||||
}
|
||||
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
// if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
// event.closeInventory();
|
||||
// }
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (limitPass) {
|
||||
if (!plugin.getGui().isChestVoteShopRequireConfirmation(identifier)) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier",
|
||||
plugin.getGui().getChestShopIdentifierIdentifierName(identifier));
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points, true)) {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/"
|
||||
+ user.getUUID() + " bought " + identifier + " for " + points);
|
||||
if (plugin.getConfigFile().isTrackShopPurchases()) {
|
||||
plugin.getServerData().addVoteShopPurchase(identifier);
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui().getCHESTVoteShopPurchase(identifier),
|
||||
placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
} else {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new VoteShopConfirm(plugin, player, user, identifier)
|
||||
.open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
}
|
||||
plugin.getCommandLoader().processSlotClick(player, user, identifier);
|
||||
if (plugin.getGui().isChestVoteShopReopenGUIOnPurchase()) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, "shop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
} else {
|
||||
if (hasPerm) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestShopIdentifierSection(identifier));
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.sendMessage(plugin.getConfigFile().getFormatShopNotPurchasable());
|
||||
}
|
||||
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final String str : plugin.getGui().getChestGUIVoteShopExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIVoteShopExtraItems(str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, user, str);
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteShopExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteShopBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.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;
|
||||
|
||||
public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
private String identifier;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteShopConfirm(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, String identifier) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "ident", identifier);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
|
||||
inv.dontClose();
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.cache();
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points, true)) {
|
||||
plugin.getLogger().info("VoteShop: " + user.getPlayerName() + "/" + user.getUUID() + " bought "
|
||||
+ identifier + " for " + points);
|
||||
if (plugin.getConfigFile().isTrackShopPurchases()) {
|
||||
plugin.getServerData().addVoteShopPurchase(identifier);
|
||||
}
|
||||
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseNoItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user).open();
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.bookgui.BookWrapper;
|
||||
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.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.MessageBuilder;
|
||||
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;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class VoteURL extends GUIHandler {
|
||||
|
||||
private boolean json;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteURL(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, boolean json) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.json = json;
|
||||
if (user == null && player instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) player);
|
||||
}
|
||||
if (player != null && user != null && player.getName().equals(user.getPlayerName())) {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
|
||||
List<String> title = plugin.getConfigFile().getFormatCommandsVoteText();
|
||||
if (title != null) {
|
||||
sites.addAll(title);
|
||||
}
|
||||
if (plugin.getConfigFile().isFormatCommandsVoteAutoInputSites()) {
|
||||
int counter = 0;
|
||||
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));
|
||||
}
|
||||
sites.add(message.colorize().getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (user != null) {
|
||||
HashMap<String, String> phs = new HashMap<String, String>();
|
||||
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 = PlaceholderUtils.replacePlaceHolder(sites, phs);
|
||||
}
|
||||
|
||||
return ArrayUtils.colorize(sites);
|
||||
}
|
||||
|
||||
private ItemBuilder getItemAll() {
|
||||
ItemBuilder builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedAllUrlsButtonItemSection());
|
||||
if (plugin.getGui().isChestVoteURLAllUrlsButtonrequireAllSitesVoted()) {
|
||||
if (user.canVoteAny()) {
|
||||
builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
} else {
|
||||
if (user.canVoteAll()) {
|
||||
builderAll = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
}
|
||||
|
||||
if (!builderAll.hasCustomDisplayName()) {
|
||||
builderAll.setName("&4All Voting Sites");
|
||||
}
|
||||
if (!builderAll.hasCustomLore()) {
|
||||
builderAll.setLore("&cClick Me");
|
||||
}
|
||||
int slot = plugin.getGui().getChestVoteURLAllUrlsButtonSlot();
|
||||
if (slot >= 0) {
|
||||
builderAll.setSlot(slot);
|
||||
}
|
||||
return builderAll;
|
||||
}
|
||||
|
||||
private ItemBuilder getItemVoteSite(VoteSite voteSite) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedItemSection());
|
||||
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteItemSection());
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteNameCanVote());
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
if (plugin.getGui().isBookVoteURLBookGUIManual()) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUITopLayout());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
int i = 1;
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
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();
|
||||
}
|
||||
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++;
|
||||
}
|
||||
|
||||
book.open(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@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.getVoteSitesEnabled()) {
|
||||
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);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
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);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (final String str : plugin.getGui().getChestVoteURLExtraItems()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteURLExtraItemsItem(str))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST.VoteURL.ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodURL().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,239 +0,0 @@
|
||||
package com.bencodez.votingplugin.cooldown;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
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.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteSiteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> perSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
private HashMap<UUID, ScheduledFuture<?>> allSiteTasks = new HashMap<UUID, ScheduledFuture<?>>();
|
||||
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
this.timer = Executors.newScheduledThreadPool(1);
|
||||
}
|
||||
|
||||
@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 void check(UUID uuid) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.dontCache();
|
||||
}
|
||||
check(user);
|
||||
}
|
||||
|
||||
public void checkPerSite(UUID uuid) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
if (!user.isOnline()) {
|
||||
user.dontCache();
|
||||
}
|
||||
checkPerSite(user);
|
||||
}
|
||||
|
||||
public void vote(VotingPluginUser user, VoteSite site) {
|
||||
if (cooldownCheckEnabled) {
|
||||
schedule(user, true);
|
||||
}
|
||||
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
user.setCoolDownCheckSite(site, Boolean.FALSE);
|
||||
schedulePerSite(user, true);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void check(VotingPluginUser user) {
|
||||
boolean coolDownCheck = user.getCoolDownCheck();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 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 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 load() {
|
||||
plugin.addUserStartup(new UserStartup() {
|
||||
|
||||
@Override
|
||||
public void onStartUp(AdvancedCoreUser advancedcoreUser) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(advancedcoreUser);
|
||||
user.dontCache();
|
||||
if (cooldownCheckEnabled) {
|
||||
check(user);
|
||||
}
|
||||
if (plugin.getConfigFile().isPerSiteCoolDownEvents()) {
|
||||
checkPerSite(user);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinish() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void checkAllVoteSite(VoteSite site) {
|
||||
plugin.getLogger().info("Checking vote cooldown rewards for all players: " + site.getKey());
|
||||
HashMap<UUID, ArrayList<Column>> cols = plugin.getUserManager().getAllKeys();
|
||||
for (Entry<UUID, ArrayList<Column>> playerData : cols.entrySet()) {
|
||||
|
||||
String uuid = playerData.getKey().toString();
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(uuid), false);
|
||||
user.dontCache();
|
||||
user.updateTempCacheWithColumns(playerData.getValue());
|
||||
cols.put(playerData.getKey(), null);
|
||||
checkPerSite(user);
|
||||
user.clearTempCache();
|
||||
user = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
cols.clear();
|
||||
cols = null;
|
||||
|
||||
plugin.getLogger().info("Finished checking vote cooldown rewards for all players: " + site.getKey());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward", new RewardOptions());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteSiteCoolDownEndEvent event) {
|
||||
plugin.getRewardHandler().giveReward(event.getPlayer(), event.getSite().getSiteData(), "CoolDownEndRewards",
|
||||
new RewardOptions().addPlaceholder("sitename", event.getSite().getDisplayName()).addPlaceholder("url",
|
||||
event.getSite().getVoteURL(false)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, FIRSTVOTETODAY, MILESTONE, VOTESTREAK, ALMOSTALLSITES;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@Getter
|
||||
private String type = "";
|
||||
|
||||
public SpecialRewardType setAmount(int num) {
|
||||
amount = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpecialRewardType setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.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
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
private void login(Player player) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
if (player.isOp() && plugin.isYmlError()) {
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
|
||||
}
|
||||
|
||||
boolean data = user.getData().hasData();
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
if (data) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
}
|
||||
|
||||
user.loginRewards();
|
||||
|
||||
plugin.getPlaceholders().onUpdate(user, true);
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()
|
||||
&& (plugin.getBungeeHandler().getMethod().equals(BungeeMethod.PLUGINMESSAGING)
|
||||
|| plugin.getBungeeHandler().getMethod().equals(BungeeMethod.REDIS))) {
|
||||
plugin.getBungeeHandler().getGlobalMessageHandler().sendMessage("Login", user.getPlayerName(),
|
||||
user.getUUID(), plugin.getBungeeSettings().getServer());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* On player login.
|
||||
*
|
||||
* @param event the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(AdvancedCoreLoginEvent event) {
|
||||
if (event.getPlayer() == null || !plugin.isMySQLOkay()) {
|
||||
return;
|
||||
}
|
||||
|
||||
login(event.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
plugin.getLoginTimer().execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
VotingPluginMain.plugin.getAdvancedTab().remove(uuid);
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
user.dontCache();
|
||||
user.logoutRewards();
|
||||
plugin.getPlaceholders().onLogout(user);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.bencodez.votingplugin.placeholders;
|
||||
|
||||
public enum PlaceholderCacheLevel {
|
||||
NONE, SPECIFIC, AUTO, AUTOALL, SPECIFICALL;
|
||||
|
||||
public static PlaceholderCacheLevel getCache(String str) {
|
||||
for (PlaceholderCacheLevel v : PlaceholderCacheLevel.values()) {
|
||||
if (v.toString().equalsIgnoreCase(str)) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
return AUTO;
|
||||
}
|
||||
|
||||
public boolean onlineOnly() {
|
||||
if (this == AUTOALL) {
|
||||
return false;
|
||||
}
|
||||
if (this == SPECIFICALL) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean shouldCache() {
|
||||
switch (this) {
|
||||
case AUTO:
|
||||
return true;
|
||||
case NONE:
|
||||
return false;
|
||||
case SPECIFIC:
|
||||
return false;
|
||||
case SPECIFICALL:
|
||||
return false;
|
||||
case AUTOALL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.bencodez.votingplugin.servicesites;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class ServiceSiteHandler {
|
||||
@Getter
|
||||
private HashMap<String, String> serviceSites = new HashMap<String, String>();
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public String match(String service) {
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase(service)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
public String matchReverse(String service) {
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
if (entry.getValue().equalsIgnoreCase(service)) {
|
||||
return entry.getKey();
|
||||
}
|
||||
}
|
||||
return service;
|
||||
}
|
||||
|
||||
public ServiceSiteHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
loadFromGithub();
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
plugin.extraDebug(entry.getKey() + " - " + entry.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void readFromWeb(String webURL) throws IOException {
|
||||
serviceSites.clear();
|
||||
URL url = new URL(webURL);
|
||||
InputStream is = url.openStream();
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(is))) {
|
||||
String line;
|
||||
boolean rawFound = false;
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (line.contains("<ul>")) {
|
||||
rawFound = true;
|
||||
} else if (!line.contains(" - ")) {
|
||||
rawFound = false;
|
||||
} else if (rawFound) {
|
||||
String data = line.replaceAll("<li>", "").replaceAll("</li>", "");
|
||||
String[] split = data.split(" - ");
|
||||
if (split.length > 0) {
|
||||
serviceSites.put(split[0], split[1]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
plugin.debug(e);
|
||||
// e.printStackTrace();
|
||||
// throw new MalformedURLException("URL is malformed!!");
|
||||
} catch (IOException e) {
|
||||
plugin.debug(e);
|
||||
// e.printStackTrace();
|
||||
// throw new IOException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void loadFromGithub() {
|
||||
try {
|
||||
readFromWeb("https://github.com/BenCodez/VotingPlugin/wiki/Minecraft-Server-Lists");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean contains(String service) {
|
||||
for (Entry<String, String> entry : serviceSites.entrySet()) {
|
||||
if (entry.getKey().equalsIgnoreCase(service)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,398 +0,0 @@
|
||||
package com.bencodez.votingplugin.specialrewards;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
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.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.events.PlayerSpecialRewardEvent;
|
||||
import com.bencodez.votingplugin.events.SpecialRewardType;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OtherVoteReward.
|
||||
*/
|
||||
public class SpecialRewards {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public SpecialRewards(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean checkAllSites(VotingPluginUser user, boolean forceBungee) {
|
||||
boolean checkAllVotes = user.checkAllVotes();
|
||||
if (checkAllVotes
|
||||
&& (plugin.getConfigFile().isExtraAllSitesCheck() || plugin.getBungeeSettings().isUseBungeecoord())) {
|
||||
int currentDay = LocalDateTime.now().getDayOfYear();
|
||||
int day = user.getGottenAllSitesDay();
|
||||
if (currentDay == day) {
|
||||
checkAllVotes = false;
|
||||
plugin.debug("Not giving allsites, already gotten today");
|
||||
} else {
|
||||
user.setGottenAllSitesDay(currentDay);
|
||||
}
|
||||
|
||||
}
|
||||
if (checkAllVotes) {
|
||||
giveAllSitesRewards(user, user.isOnline(), forceBungee);
|
||||
}
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public void bungeeAllSitesCheck(VotingPluginUser user, int numberOfVotes, int num) {
|
||||
if (plugin.getBungeeSettings().isGiveExtraAllSitesRewards()) {
|
||||
int numberOfSites = plugin.getVoteSitesEnabled().size();
|
||||
if (numberOfVotes >= numberOfSites * 2) {
|
||||
if (num > numberOfSites) {
|
||||
if (num % numberOfSites == 0) {
|
||||
// should give extra allsites?
|
||||
if (user.checkAllVotes()) {
|
||||
plugin.debug("Giving extra allsites reward from bungee");
|
||||
giveAllSitesRewards(user, user.isOnline(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkAlmostAllSites(VotingPluginUser user, boolean forceBungee) {
|
||||
boolean checkAllVotes = user.checkAlmostAllVotes();
|
||||
plugin.extraDebug("Checking almostallsites reward: " + checkAllVotes + "/" + user.getSitesNotVotedOn());
|
||||
if (checkAllVotes) {
|
||||
int currentDay = LocalDateTime.now().getDayOfYear();
|
||||
int day = user.getGottenAlmostAllSitesDay();
|
||||
if (currentDay == day) {
|
||||
checkAllVotes = false;
|
||||
plugin.debug("Not giving almostallsites, already gotten today");
|
||||
} else {
|
||||
user.setGottenAlmostAllSitesDay(currentDay);
|
||||
giveAlmostAllSitesRewards(user, user.isOnline(), forceBungee);
|
||||
}
|
||||
}
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
public boolean checkCumualativeVotes(VotingPluginUser user, BungeeMessageData bungeeMessageData,
|
||||
boolean forceBungee) {
|
||||
boolean gotCumulativeAny = false;
|
||||
Set<String> votes = plugin.getSpecialRewardsConfig().getCumulativeVotes();
|
||||
for (String vote : votes) {
|
||||
if (MessageAPI.isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRewardEnabled(votesRequired)
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(votesRequired))) {
|
||||
boolean gotCumulative = false;
|
||||
int total = 0;
|
||||
boolean useBungeeTotalNum = bungeeMessageData != null;
|
||||
String totalToUse = plugin.getSpecialRewardsConfig().getCumulativeVotesTotal(votesRequired);
|
||||
TopVoter top = TopVoter.getTopVoter(totalToUse);
|
||||
if (!useBungeeTotalNum) {
|
||||
total = user.getTotal(top);
|
||||
} else {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
total = bungeeMessageData.getAllTimeTotal();
|
||||
break;
|
||||
case Daily:
|
||||
total = bungeeMessageData.getDailyTotal();
|
||||
break;
|
||||
case Monthly:
|
||||
total = bungeeMessageData.getMonthTotal();
|
||||
break;
|
||||
case Weekly:
|
||||
total = bungeeMessageData.getWeeklyTotal();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> blackList = plugin.getSpecialRewardsConfig()
|
||||
.getCumulativeBlackList(votesRequired);
|
||||
boolean blackListed = false;
|
||||
for (Integer num : blackList) {
|
||||
if (num.intValue() == total) {
|
||||
blackListed = true;
|
||||
plugin.extraDebug("Not giving cumulative " + votesRequired + " to "
|
||||
+ user.getPlayerName() + " due to blacklist");
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getCumulativeRecurring(votesRequired)) {
|
||||
if (total != 0 && total >= votesRequired) {
|
||||
if ((total % votesRequired) == 0 && !blackListed) {
|
||||
gotCumulative = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (total == votesRequired) {
|
||||
gotCumulative = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (gotCumulative) {
|
||||
if (!plugin.getSpecialRewardsConfig().isOnlyOneCumulative() || !gotCumulativeAny) {
|
||||
gotCumulativeAny = true;
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired + ", total: "
|
||||
+ top.toString() + ", current total: " + total);
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired, forceBungee);
|
||||
} else {
|
||||
plugin.debug("Already got one cumulative");
|
||||
}
|
||||
} else {
|
||||
plugin.devDebug(user.getPlayerName() + " not able to get cumulative " + votesRequired
|
||||
+ ", total required: " + top.toString() + ", current player total: " + total);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid cumulative number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotCumulativeAny;
|
||||
}
|
||||
|
||||
public boolean checkFirstVote(VotingPluginUser user, boolean forceBungee) {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVote()) {
|
||||
giveFirstVoteRewards(user, user.isOnline(), forceBungee);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkFirstVoteToday(VotingPluginUser user, boolean forceBungee) {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVoteToday()) {
|
||||
giveFirstVoteTodayRewards(user, user.isOnline(), forceBungee);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkMilestone(VotingPluginUser user, BungeeMessageData bungeeMessageData, boolean forceBungee) {
|
||||
int milestoneCount = user.getMilestoneCount();
|
||||
if (bungeeMessageData != null) {
|
||||
try {
|
||||
milestoneCount = bungeeMessageData.getMilestoneCount();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
milestoneCount = user.getMilestoneCount();
|
||||
}
|
||||
}
|
||||
if (plugin.getConfigFile().isPreventRepeatMilestones()) {
|
||||
ArrayList<Integer> nums = new ArrayList<Integer>();
|
||||
|
||||
for (String str : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
try {
|
||||
nums.add(Integer.parseInt(str));
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Failed to get number from " + str);
|
||||
}
|
||||
}
|
||||
|
||||
for (int num : nums) {
|
||||
if (milestoneCount > num) {
|
||||
if (!user.hasGottenMilestone(num)) {
|
||||
plugin.getLogger()
|
||||
.info("Milestone " + num + " for " + user.getPlayerName()
|
||||
+ " not already given when it should be, Current AllTimeTotal: "
|
||||
+ user.getTotal(TopVoter.AllTime) + ", Current MileStoneCount: "
|
||||
+ user.getMilestoneCount());
|
||||
user.setHasGotteMilestone(num, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean gotMilestone = false;
|
||||
Set<String> votes = plugin.getSpecialRewardsConfig().getMilestoneVotes();
|
||||
for (String vote : votes) {
|
||||
if (MessageAPI.isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (plugin.getSpecialRewardsConfig().getMilestoneRewardEnabled(votesRequired)
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMilestoneRewardsPath(votesRequired))) {
|
||||
|
||||
int userVotesTotal = milestoneCount;
|
||||
if (userVotesTotal >= votesRequired && !user.hasGottenMilestone(votesRequired)) {
|
||||
giveMilestoneVoteReward(user, user.isOnline(), votesRequired, forceBungee);
|
||||
user.setHasGotteMilestone(votesRequired, true);
|
||||
plugin.debug(user.getPlayerName() + " got milestone " + votesRequired);
|
||||
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Milestone " + votesRequired + " not enabled or has no rewards");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid milestone number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotMilestone;
|
||||
}
|
||||
|
||||
public boolean checkVoteStreak(VotingPluginUser user, String type, boolean forceBungee) {
|
||||
boolean gotReward = false;
|
||||
|
||||
Set<String> streaks = plugin.getSpecialRewardsConfig().getVoteStreakVotes(type);
|
||||
for (String streak : streaks) {
|
||||
String s = streak.replaceAll("-", "");
|
||||
boolean multiple = false;
|
||||
if (streak.contains("-")) {
|
||||
// multiple
|
||||
multiple = true;
|
||||
|
||||
}
|
||||
plugin.debug("Streak: " + streak + " multiple: " + multiple);
|
||||
if (MessageAPI.isInt(s)) {
|
||||
int streakRequired = Integer.parseInt(s);
|
||||
if (streakRequired != 0) {
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled(type, streak)
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath(type, "" + streak))) {
|
||||
int curStreak = 0;
|
||||
if (type.equalsIgnoreCase("day")) {
|
||||
curStreak = user.getDayVoteStreak();
|
||||
} else if (type.equalsIgnoreCase("week")) {
|
||||
curStreak = user.getWeekVoteStreak();
|
||||
} else if (type.equalsIgnoreCase("month")) {
|
||||
curStreak = user.getMonthVoteStreak();
|
||||
}
|
||||
if (!multiple) {
|
||||
if (curStreak == streakRequired) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, "" + streakRequired, curStreak,
|
||||
forceBungee);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + " for " + type);
|
||||
}
|
||||
} else {
|
||||
if (curStreak != 0 && curStreak % streakRequired == 0) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, streak, curStreak, forceBungee);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + "* for " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return gotReward;
|
||||
|
||||
}
|
||||
|
||||
public void giveAllSitesRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.ALLSITE);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveAlmostAllSitesRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.ALMOSTALLSITES);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAlmostAllSitesRewardPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveCumulativeVoteReward(VotingPluginUser user, boolean online, int cumulative, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.CUMMULATIVE.setAmount(cumulative));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getCumulativeRewardsPath(cumulative)).setServer(forceBungee)
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
}
|
||||
|
||||
public void giveFirstVoteRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.FIRSTVOTE);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveFirstVoteTodayRewards(VotingPluginUser user, boolean online, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.FIRSTVOTETODAY);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
plugin.getRewardHandler().giveReward(user, plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteTodayRewardsPath(),
|
||||
new RewardOptions().setServer(forceBungee).setOnline(online));
|
||||
}
|
||||
|
||||
public void giveMilestoneVoteReward(VotingPluginUser user, boolean online, int milestone, boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.MILESTONE.setAmount(milestone));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getMilestoneRewardsPath(milestone)).setOnline(online)
|
||||
.withPlaceHolder("Milestone", "" + milestone).setServer(forceBungee).send(user);
|
||||
}
|
||||
|
||||
public void giveVoteStreakReward(VotingPluginUser user, boolean online, String type, String string, int votes,
|
||||
boolean forceBungee) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.VOTESTREAK.setType(type).setAmount(votes));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
new RewardBuilder(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath(type, string)).setOnline(online)
|
||||
.withPlaceHolder("Type", type).setServer(forceBungee).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.bencodez.votingplugin.user;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.usercache.UserDataManager;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyBoolean;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyInt;
|
||||
import com.bencodez.advancedcore.api.user.usercache.keys.UserDataKeyString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class UserManager {
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public UserManager(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addCachingKeys() {
|
||||
UserDataManager manager = plugin.getUserManager().getDataManager();
|
||||
manager.addKey(new UserDataKeyBoolean("TopVoterIgnore"));
|
||||
manager.addKey(new UserDataKeyInt("VotePartyVotes"));
|
||||
manager.addKey(new UserDataKeyString("LastVotes"));
|
||||
manager.addKey(new UserDataKeyBoolean(getCoolDownCheckPath()));
|
||||
manager.addKey(new UserDataKeyString("OfflineVotes").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyInt("MilestoneCount"));
|
||||
manager.addKey(new UserDataKeyInt("MonthTotal"));
|
||||
manager.addKey(new UserDataKeyInt("AllTimeTotal"));
|
||||
manager.addKey(new UserDataKeyInt("DailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("WeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("Points"));
|
||||
manager.addKey(new UserDataKeyInt("DayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("BestDayVoteStreak"));
|
||||
manager.addKey(new UserDataKeyString("DayVoteStreakLastUpdate").setColumnType("MEDIUMTEXT"));
|
||||
manager.addKey(new UserDataKeyString("GottenMileStones").setColumnType("LONGTEXT"));
|
||||
manager.addKey(new UserDataKeyBoolean("Reminded"));
|
||||
manager.addKey(new UserDataKeyBoolean("DisableBroadcast"));
|
||||
manager.addKey(new UserDataKeyInt("WeekVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("BestWeekVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("MonthVoteStreak"));
|
||||
manager.addKey(new UserDataKeyInt("HighestDailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("HighestMonthlyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("HighestWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastMonthTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastWeeklyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("LastDailyTotal"));
|
||||
manager.addKey(new UserDataKeyInt("BestMonthVoteStreak"));
|
||||
manager.addKey(new UserDataKeyString(getCoolDownCheckSitePath()).setColumnType("LONGTEXT"));
|
||||
if (plugin.getOptions().isPerServerRewards()) {
|
||||
manager.addKey(new UserDataKeyString("OfflineRewards" + plugin.getOptions().getServer())
|
||||
.setColumnType("MEDIUMTEXT"));
|
||||
}
|
||||
if (plugin.getConfigFile().isExtraAllSitesCheck()) {
|
||||
manager.addKey(new UserDataKeyInt(getGottenAllSitesDayPath()));
|
||||
}
|
||||
manager.addKey(new UserDataKeyInt(getGottenAlmostAllSitesDayPath()));
|
||||
}
|
||||
|
||||
public String getGottenAllSitesDayPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "AllSitesLast_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
}
|
||||
return "AllSitesLast";
|
||||
}
|
||||
|
||||
public String getGottenAlmostAllSitesDayPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "AlmostAllSitesLast_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
}
|
||||
return "AlmostAllSitesLast";
|
||||
}
|
||||
|
||||
public String getCoolDownCheckSitePath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage() + "_Sites";
|
||||
} else {
|
||||
return "CoolDownCheck" + "_Sites";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCoolDownCheckPath() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "CoolDownCheck_" + plugin.getBungeeSettings().getServerNameStorage();
|
||||
} else {
|
||||
return "CoolDownCheck";
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllUUIDs() {
|
||||
return plugin.getUserManager().getAllUUIDs();
|
||||
}
|
||||
|
||||
public VotingPluginUser getVotingPluginUser(com.bencodez.advancedcore.api.user.AdvancedCoreUser user) {
|
||||
return new VotingPluginUser(plugin, user);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(UUID uuid, String playerName) {
|
||||
return new VotingPluginUser(plugin, uuid, playerName);
|
||||
}
|
||||
|
||||
public VotingPluginUser getVotingPluginUser(OfflinePlayer player) {
|
||||
return getVotingPluginUser(player.getUniqueId(), player.getName());
|
||||
}
|
||||
|
||||
public VotingPluginUser getVotingPluginUser(Player player) {
|
||||
return getVotingPluginUser(player.getUniqueId(), player.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(String playerName) {
|
||||
return new VotingPluginUser(plugin, plugin.getUserManager().getProperName(playerName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(UUID uuid) {
|
||||
return new VotingPluginUser(plugin, uuid);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public VotingPluginUser getVotingPluginUser(UUID uuid, boolean loadName) {
|
||||
return new VotingPluginUser(plugin, uuid, loadName);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,181 +0,0 @@
|
||||
package com.bencodez.votingplugin.votereminding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteReminding.
|
||||
*/
|
||||
public class VoteReminding {
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
@Getter
|
||||
private ConcurrentHashMap<UUID, Boolean> remindersEnabled = new ConcurrentHashMap<UUID, Boolean>();
|
||||
|
||||
public VoteReminding(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void loadReminds() {
|
||||
List<String> uuidsStr = plugin.getServerData().getDisabledReminders();
|
||||
|
||||
for (String str : uuidsStr) {
|
||||
remindersEnabled.put(UUID.fromString(str), Boolean.FALSE);
|
||||
}
|
||||
|
||||
plugin.getTimer().scheduleAtFixedRate(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
saveReminds();
|
||||
}
|
||||
}, 24, 24, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
public void saveReminds() {
|
||||
ArrayList<UUID> remindersDisabled = new ArrayList<UUID>();
|
||||
for (Entry<UUID, Boolean> entry : remindersEnabled.entrySet()) {
|
||||
if (remindersEnabled.containsKey(entry.getKey())) {
|
||||
if (!remindersEnabled.get(entry.getKey()).booleanValue()) {
|
||||
remindersDisabled.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getServerData().saveDisabledReminders(remindersDisabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check remind.
|
||||
*
|
||||
* @param user the user
|
||||
*/
|
||||
public void checkRemind(VotingPluginUser user) {
|
||||
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
|
||||
if (shouldRemind(user)) {
|
||||
if (!plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
|
||||
runRemind(user);
|
||||
} else if (!user.isReminded()) {
|
||||
runRemind(user);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void giveReward(VotingPluginUser user) {
|
||||
new RewardBuilder(plugin.getConfigFile().getData(), plugin.getConfigFile().getVoteRemindingRewardsPath())
|
||||
.withPlaceHolder("sitesavailable", "" + user.getSitesNotVotedOn()).setGiveOffline(false)
|
||||
.disableDefaultWorlds().send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load remind checking.
|
||||
*/
|
||||
public void loadRemindChecking() {
|
||||
if (timer != null) {
|
||||
timer.shutdownNow();
|
||||
}
|
||||
if (plugin.getConfigFile().getVoteRemindingRemindDelay() > 0) {
|
||||
timer = Executors.newScheduledThreadPool(1);
|
||||
timer.scheduleWithFixedDelay(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin != null && plugin.isEnabled()) {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
if (!plugin.getOptions().isTreatVanishAsOffline() || !user.isVanished()) {
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
timer.shutdown();
|
||||
}
|
||||
}
|
||||
}, 30, plugin.getConfigFile().getVoteRemindingRemindDelay() * 60, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run remind.
|
||||
*
|
||||
* @param user the user
|
||||
*/
|
||||
public void runRemind(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isVoteRemindingEnabled()) {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
giveReward(user);
|
||||
if (user.getData().hasData() && plugin.getConfigFile().isVoteRemindingRemindOnlyOnce()) {
|
||||
user.setReminded(true);
|
||||
}
|
||||
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldRemind(VotingPluginUser user) {
|
||||
if (remindersEnabled.containsKey(user.getJavaUUID())) {
|
||||
if (!remindersEnabled.get(user.getJavaUUID()).booleanValue()) {
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (user.shouldBeReminded()) {
|
||||
boolean hasPermAll = user.hasPermission("VotingPlugin.Login.RemindVotes.All");
|
||||
if (hasPermAll) {
|
||||
return user.canVoteAll();
|
||||
} else {
|
||||
return user.canVoteAny();
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getUUID() + " no need to remind because player has VotingPlugin.NoRemind");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void runRemindLogin(VotingPluginUser user) {
|
||||
if (plugin.getConfigFile().isVoteRemindingEnabled()) {
|
||||
if (user.hasPermission("VotingPlugin.Login.RemindVotes") || user.hasPermission("VotingPlugin.Player")) {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
if ((!plugin.getVotingPluginUserManager().getAllUUIDs().contains(user.getUUID())
|
||||
|| shouldRemind(user))) {
|
||||
giveReward(user);
|
||||
if (user.getData().hasData()) {
|
||||
user.setReminded(true);
|
||||
}
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
} else {
|
||||
plugin.debug("Not reminding for " + user.getUUID());
|
||||
}
|
||||
} else {
|
||||
plugin.debug(user.getUUID() + " has no permission for reminders");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,734 @@
|
||||
// File: com/bencodez/votingplugin/BungeeHandler.java
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.eclipse.paho.client.mqttv3.MqttException;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
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.bungeeapi.globaldata.GlobalDataHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.globaldata.GlobalMySQL;
|
||||
import com.bencodez.simpleapi.encryption.EncryptionHandler;
|
||||
import com.bencodez.simpleapi.servercomm.codec.JsonEnvelope;
|
||||
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.MqttServerComm;
|
||||
import com.bencodez.simpleapi.servercomm.mysql.MySqlMessenger;
|
||||
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.proxy.BungeeMethod;
|
||||
import com.bencodez.votingplugin.proxy.VoteTotalsSnapshot;
|
||||
import com.bencodez.votingplugin.proxy.VotingPluginWire;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Handler for Bungee/proxy server integration.
|
||||
*/
|
||||
public class BungeeHandler implements Listener {
|
||||
@Getter
|
||||
private ClientHandler clientHandler;
|
||||
|
||||
private EncryptionHandler encryptionHandler;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyCurrent = -2;
|
||||
|
||||
@Getter
|
||||
private int bungeeVotePartyRequired = -2;
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private GlobalDataHandler globalDataHandler;
|
||||
|
||||
@Getter
|
||||
private ScheduledExecutorService timer;
|
||||
|
||||
@Getter
|
||||
private RedisHandler redisHandler;
|
||||
|
||||
@Getter
|
||||
private GlobalMessageHandler globalMessageHandler;
|
||||
|
||||
private Thread redisThread;
|
||||
|
||||
@Getter
|
||||
private MySqlMessenger backendMysqlMessenger;
|
||||
|
||||
@Getter
|
||||
private MqttHandler mqttHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new BungeeHandler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public BungeeHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and processes global data from the global data handler.
|
||||
*/
|
||||
public void checkGlobalData() {
|
||||
HashMap<String, DataValue> data = globalDataHandler.getExact(plugin.getBungeeSettings().getServer());
|
||||
|
||||
if (data.containsKey("ForceUpdate")) {
|
||||
boolean b = checkGlobalDataTimeValue(data.get("ForceUpdate"));
|
||||
if (b) {
|
||||
if (plugin.getStorageType().equals(UserStorage.MYSQL)) {
|
||||
plugin.getMysql().clearCacheBasic();
|
||||
}
|
||||
plugin.getUserManager().getDataManager().clearCache();
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "ForceUpdate", false);
|
||||
}
|
||||
}
|
||||
|
||||
boolean forceUpdate = false;
|
||||
|
||||
if (checkGlobalDataTime(TimeType.MONTH, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.WEEK, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
if (checkGlobalDataTime(TimeType.DAY, data)) {
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
if (forceUpdate) {
|
||||
HashMap<String, DataValue> dataToSet = new HashMap<>();
|
||||
dataToSet.put("FinishedProcessing", new DataValueBoolean(true));
|
||||
dataToSet.put("Processing", new DataValueBoolean(false));
|
||||
globalDataHandler.setData(plugin.getBungeeSettings().getServer(), dataToSet);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks global data for a time type change.
|
||||
*
|
||||
* @param type the time type to check
|
||||
* @param data the global data map
|
||||
* @return true if currently processing a time change
|
||||
*/
|
||||
public boolean checkGlobalDataTime(TimeType type, HashMap<String, DataValue> data) {
|
||||
boolean isProcessing = false;
|
||||
if (data.containsKey(type.toString())) {
|
||||
|
||||
DataValue value = data.get(type.toString());
|
||||
boolean b = checkGlobalDataTimeValue(value);
|
||||
if (b) {
|
||||
long lastUpdated = Long.valueOf(data.get("LastUpdated").getString()).longValue();
|
||||
plugin.debug("LastUpdated: " + lastUpdated);
|
||||
if (LocalDateTime.now().atZone(ZoneOffset.UTC).toInstant().toEpochMilli() - lastUpdated > 1000 * 60 * 60
|
||||
* 2) {
|
||||
plugin.getLogger().warning("Ignoring bungee time change since it was more than 2 hours ago");
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
return false;
|
||||
}
|
||||
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), "Processing", true);
|
||||
isProcessing = true;
|
||||
|
||||
plugin.debug("Detected time change from bungee: " + type.toString());
|
||||
plugin.getTimeChecker().forceChanged(type, false, true, true);
|
||||
globalDataHandler.setBoolean(plugin.getBungeeSettings().getServer(), type.toString(), false);
|
||||
|
||||
HashMap<String, Object> fields = new HashMap<>();
|
||||
fields.put("server", plugin.getBungeeSettings().getServer());
|
||||
sendSubChannel("TimeChangeFinished", fields);
|
||||
}
|
||||
}
|
||||
return isProcessing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks and extracts the boolean value from a DataValue.
|
||||
*
|
||||
* @param data the data value
|
||||
* @return the boolean value
|
||||
*/
|
||||
public boolean checkGlobalDataTimeValue(DataValue data) {
|
||||
if (data.isBoolean()) {
|
||||
return data.getBoolean();
|
||||
}
|
||||
return Boolean.valueOf(data.getString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes and cleans up all handlers and connections.
|
||||
*/
|
||||
public void close() {
|
||||
if (backendMysqlMessenger != null) {
|
||||
backendMysqlMessenger.shutdown();
|
||||
}
|
||||
|
||||
if (socketHandler != null) {
|
||||
socketHandler.closeConnection();
|
||||
}
|
||||
if (clientHandler != null) {
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
if (globalDataHandler != null) {
|
||||
globalDataHandler.getGlobalMysql().close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and initializes the bungee handler with the configured method.
|
||||
*/
|
||||
public void load() {
|
||||
plugin.debug("Loading bungee handler");
|
||||
|
||||
method = BungeeMethod.getByName(plugin.getBungeeSettings().getBungeeMethod());
|
||||
|
||||
plugin.getLogger().info("Using BungeeMethod: " + method.toString());
|
||||
|
||||
loadGlobalMysql();
|
||||
|
||||
globalMessageHandler = new GlobalMessageHandler() {
|
||||
@Override
|
||||
public void sendMessage(JsonEnvelope envelope) {
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
try {
|
||||
backendMysqlMessenger.sendToProxy(envelope);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.getPluginMessaging().sendEnvelope(envelope);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendEnvelopeSocket(envelope);
|
||||
} else if (method.equals(BungeeMethod.REDIS)) {
|
||||
redisHandler.publishEnvelope(plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin",
|
||||
envelope);
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
try {
|
||||
mqttHandler.publishEnvelope(
|
||||
plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/proxy", envelope);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// ==========================
|
||||
// Vote / VoteOnline (wire decode)
|
||||
// ==========================
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
handleWireVote(msg);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE_ONLINE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
handleWireVote(msg);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE_UPDATE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
// Wire decode
|
||||
VotingPluginWire.VoteUpdate v = VotingPluginWire.readVoteUpdate(msg);
|
||||
|
||||
String playerUuid = v.uuid;
|
||||
if (playerUuid == null || playerUuid.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug("pluginmessaging voteupdate received for " + playerUuid + ": " + v.votePartyCurrent + "/"
|
||||
+ v.votePartyRequired + " on " + v.service);
|
||||
|
||||
// Vote party cache update
|
||||
if (v.votePartyCurrent >= 0 || bungeeVotePartyCurrent == -2) {
|
||||
bungeeVotePartyCurrent = v.votePartyCurrent;
|
||||
}
|
||||
if (v.votePartyRequired >= 0 || bungeeVotePartyRequired == -2) {
|
||||
bungeeVotePartyRequired = v.votePartyRequired;
|
||||
}
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(UUID.fromString(playerUuid));
|
||||
user.cache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
// Optional: update last vote time for a service
|
||||
String service = v.service;
|
||||
long time = v.time;
|
||||
|
||||
if (service != null && !service.isEmpty() && time > 0) {
|
||||
user.setTime(plugin.getVoteSiteManager().getVoteSite(service, true), time);
|
||||
} else if (service != null && !service.isEmpty() && time <= 0
|
||||
&& plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug("Invalid last vote time received from bungee: " + time);
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_BUNGEE_TIME_CHANGE) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
checkGlobalData();
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener(VotingPluginWire.SUB_VOTE_BROADCAST) {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
Map<String, String> f = msg.getFields();
|
||||
|
||||
final String uuidStr = nvl(f.get(VotingPluginWire.K_UUID));
|
||||
final String playerNameRaw = nvl(f.get(VotingPluginWire.K_PLAYER));
|
||||
final String service = nvl(f.get(VotingPluginWire.K_SERVICE));
|
||||
|
||||
if (uuidStr.isEmpty() || service.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
UUID javaUuid;
|
||||
try {
|
||||
javaUuid = UUID.fromString(uuidStr);
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().warning("Invalid UUID in VoteBroadcast: " + uuidStr);
|
||||
return;
|
||||
}
|
||||
|
||||
// New fields (May use later)
|
||||
@SuppressWarnings("unused")
|
||||
final long time = readLongSafe(f.get(VotingPluginWire.K_TIME), 0L);
|
||||
@SuppressWarnings("unused")
|
||||
final String totals = nvl(f.get(VotingPluginWire.K_TOTALS));
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSiteManager()
|
||||
.getVoteSite(plugin.getVoteSiteManager().getVoteSiteName(true, service), true);
|
||||
|
||||
if (voteSite == null) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + service + "'");
|
||||
return;
|
||||
}
|
||||
if (!voteSite.isEnabled()) {
|
||||
plugin.debug("Votesite: " + voteSite.getKey() + " is not enabled (VoteBroadcast)");
|
||||
return;
|
||||
}
|
||||
|
||||
// Same user retrieval strategy: UUID + (possibly empty) name
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(javaUuid,
|
||||
playerNameRaw);
|
||||
|
||||
// Keep cache/name current like normal vote path does
|
||||
user.cache();
|
||||
user.updateName(true);
|
||||
|
||||
// Same broadcast logic as PlayerVoteListener
|
||||
if (plugin.getBroadcastHandler() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (user.isVanished()) {
|
||||
plugin.debug("Not broadcasting vote for vanished user: " + user.getPlayerName());
|
||||
return;
|
||||
}
|
||||
|
||||
final boolean online = user.isOnline(); // same behavior as non-bungee vote path
|
||||
plugin.getBroadcastHandler().broadcastVote(user.getJavaUUID(), user.getPlayerName(),
|
||||
voteSite.getDisplayName(), online);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("Status") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
String server = nvl(msg.getFields().get("server"));
|
||||
HashMap<String, Object> out = new HashMap<>();
|
||||
out.put("server", server);
|
||||
sendSubChannel("statusokay", out);
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("ServerName") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
String server = nvl(msg.getFields().get("server"));
|
||||
if (!plugin.getOptions().getServer().equals(server)) {
|
||||
plugin.getLogger().warning("Server name doesn't match in BungeeSettings.yml, should be " + server);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBungee") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
for (final String cmd : plugin.getBungeeSettings().getBungeeVotePartyGlobalCommands()) {
|
||||
plugin.getBukkitScheduler().runTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
new RewardBuilder(plugin.getBungeeSettings().getData(), "BungeeVotePartyRewards").send(p);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
globalMessageHandler.addListener(new GlobalMessageListener("VotePartyBroadcast") {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope msg) {
|
||||
String broadcast = nvl(msg.getFields().get("broadcast"));
|
||||
MiscUtils.getInstance().broadcast(broadcast);
|
||||
}
|
||||
});
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
try {
|
||||
backendMysqlMessenger = new MySqlMessenger("VotingPlugin",
|
||||
plugin.getMysql().getMysql().getConnectionManager().getDataSource(),
|
||||
MySqlMessenger.Mode.BACKEND, plugin.getOptions().getServer(), msg -> {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug("Proxy sent envelope: " + msg.envelope.getSubChannel() + " "
|
||||
+ msg.envelope.getFields());
|
||||
}
|
||||
globalMessageHandler.onMessage(msg.envelope);
|
||||
});
|
||||
} 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(), plugin.getBungeeSettings().getRedisdbindex()) {
|
||||
|
||||
@Override
|
||||
public void debug(String message) {
|
||||
if (plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
plugin.debug(message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
redisThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.isEnabled()) {
|
||||
RedisListener listener = redisHandler.createEnvelopeListener(
|
||||
plugin.getBungeeSettings().getRedisPrefix() + "VotingPlugin_"
|
||||
+ plugin.getBungeeSettings().getServer(),
|
||||
(ch, env) -> globalMessageHandler.onMessage(env));
|
||||
redisHandler.loadListener(listener);
|
||||
}
|
||||
}
|
||||
});
|
||||
redisThread.start();
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels(plugin.getBungeeSettings().getPluginMessagingChannel());
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public void onReceive(JsonEnvelope envelope) {
|
||||
globalMessageHandler.onMessage(envelope);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(plugin.getName(),
|
||||
new File(plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
clientHandler = new ClientHandler(plugin.getBungeeSettings().getBungeeServerHost(),
|
||||
plugin.getBungeeSettings().getBungeeServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug());
|
||||
|
||||
socketHandler = new SocketHandler("vp-socket", plugin.getBungeeSettings().getSpigotServerHost(),
|
||||
plugin.getBungeeSettings().getSpigotServerPort(), encryptionHandler,
|
||||
plugin.getBungeeSettings().isBungeeDebug()) {
|
||||
|
||||
@Override
|
||||
public void log(String str) {
|
||||
plugin.getLogger().info(str);
|
||||
}
|
||||
};
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
@Override
|
||||
public void onReceiveEnvelope(JsonEnvelope envelope) {
|
||||
globalMessageHandler.onMessage(envelope);
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.MQTT)) {
|
||||
try {
|
||||
String id = plugin.getBungeeSettings().getMqttClientID();
|
||||
if (id.isEmpty()) {
|
||||
id = plugin.getOptions().getServer();
|
||||
}
|
||||
mqttHandler = new MqttHandler(new MqttServerComm(id, plugin.getBungeeSettings().getMqttBrokerURL(),
|
||||
plugin.getBungeeSettings().getMqttUsername(), plugin.getBungeeSettings().getMqttPassword()), 2);
|
||||
|
||||
mqttHandler.subscribeEnvelopes(
|
||||
plugin.getBungeeSettings().getMqttPrefix() + "votingplugin/servers/"
|
||||
+ plugin.getOptions().getServer(),
|
||||
(topic, envelope) -> globalMessageHandler.onMessage(envelope));
|
||||
|
||||
} catch (MqttException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
private static long readLongSafe(String v, long def) {
|
||||
if (v == null)
|
||||
return def;
|
||||
try {
|
||||
return Long.parseLong(v);
|
||||
} catch (Exception ignored) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wire vote handler (Vote + VoteOnline).
|
||||
*/
|
||||
private void handleWireVote(JsonEnvelope msg) {
|
||||
// Strict schema check (wire uses envelope schema, not a "bungeeVersion" field)
|
||||
int schema = msg.getSchema();
|
||||
if (schema != VotingPluginWire.SCHEMA_VERSION) {
|
||||
plugin.getLogger().warning("Incompatible version with bungee/proxy, please update all servers: " + schema
|
||||
+ " != " + VotingPluginWire.SCHEMA_VERSION);
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginWire.Vote v = VotingPluginWire.readVote(msg);
|
||||
|
||||
String uuidStr = v.uuid;
|
||||
String player = v.player;
|
||||
String service = v.service;
|
||||
|
||||
if (uuidStr == null || uuidStr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.debug("wire vote received from " + player + "/" + uuidStr + " on " + service);
|
||||
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(UUID.fromString(uuidStr),
|
||||
player);
|
||||
|
||||
VoteTotalsSnapshot text = VoteTotalsSnapshot.parseStorage(v.totals == null ? "" : v.totals);
|
||||
|
||||
bungeeVotePartyCurrent = text.getVotePartyCurrent();
|
||||
bungeeVotePartyRequired = text.getVotePartyRequired();
|
||||
plugin.getServerData().setBungeeVotePartyCurrent(bungeeVotePartyCurrent);
|
||||
plugin.getServerData().setBungeeVotePartyRequired(bungeeVotePartyRequired);
|
||||
|
||||
user.cache();
|
||||
|
||||
boolean bungeeBroadcast = v.broadcast;
|
||||
|
||||
// Wire has no "setTotals" flag; treat as always true (so doNotSetTotals =
|
||||
// false)
|
||||
boolean doNotSetTotals = false;
|
||||
|
||||
user.bungeeVotePluginMessaging(service, v.time, text, doNotSetTotals, v.wasOnline, bungeeBroadcast, v.num);
|
||||
|
||||
if (plugin.getBungeeSettings().isPerServerPoints()) {
|
||||
user.addPoints(plugin.getConfigFile().getPointsOnVote());
|
||||
}
|
||||
|
||||
if (v.manageTotals) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
int _ignored = v.numberOfVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the global MySQL handler for cross-server data synchronization.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendEnvelopeSocket(JsonEnvelope envelope) {
|
||||
if (clientHandler != null) {
|
||||
clientHandler.sendEnvelope(envelope);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendSubChannel(String subChannel, HashMap<String, Object> fields) {
|
||||
JsonEnvelope.Builder b = JsonEnvelope.builder(subChannel).schema(VotingPluginWire.SCHEMA_VERSION);
|
||||
if (fields != null) {
|
||||
for (Map.Entry<String, Object> e : fields.entrySet()) {
|
||||
b.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
globalMessageHandler.sendMessage(b.build());
|
||||
}
|
||||
|
||||
private static String nvl(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
}
|
||||
File renamed without changes.
+1001
-498
File diff suppressed because it is too large.
Load diff
+236
-131
@@ -2,25 +2,36 @@ package com.bencodez.votingplugin;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.metrics.BStatsMetrics;
|
||||
|
||||
/**
|
||||
* Registers bStats charts for VotingPlugin.
|
||||
* <p>
|
||||
* Updated for VotingPlugin 7.0:
|
||||
* <ul>
|
||||
* <li>Broadcast: Always logs broadcast_type if VoteBroadcast.Type exists. If Type == NONE, ignores other broadcast
|
||||
* settings.</li>
|
||||
* <li>VoteLogging: Only logs VoteLogging charts when VoteLogging.Enabled is true.</li>
|
||||
* <li>No "Unknown" values are emitted; charts are only registered when their data exists.</li>
|
||||
* <li>VoteMilestones chart is bucketed to reduce cardinality.</li>
|
||||
* </ul>
|
||||
*/
|
||||
public class VotingPluginMetrics {
|
||||
|
||||
public void load(VotingPluginMain plugin) {
|
||||
BStatsMetrics metrics = new BStatsMetrics(plugin, 38);
|
||||
/**
|
||||
* Register bStats metrics.
|
||||
*
|
||||
* @param plugin VotingPlugin main instance
|
||||
*/
|
||||
public void load(final VotingPluginMain plugin) {
|
||||
if (plugin == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_firstvote", new Callable<String>() {
|
||||
final BStatsMetrics metrics = new BStatsMetrics(plugin, 38);
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -28,50 +39,22 @@ 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>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
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";
|
||||
}
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
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>() {
|
||||
|
||||
@Override
|
||||
@@ -79,22 +62,16 @@ public class VotingPluginMetrics {
|
||||
return plugin.getPlaceholders().getCacheLevel().toString();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_milestone", new Callable<String>() {
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votemilestones", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
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";
|
||||
}
|
||||
int size = plugin.getVoteMilestonesManager().getConfig().getMilestones().size();
|
||||
return bucketCount(size);
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -102,68 +79,19 @@ public class VotingPluginMetrics {
|
||||
if (plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Day")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Day", s)
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Day", s))) {
|
||||
return "True";
|
||||
}
|
||||
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakweek", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Week")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Week", s)
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Week", s))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakmonth", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Month")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Month", s)
|
||||
&& plugin.getRewardHandler().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Month", s))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
|
||||
return "False";
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofsites", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getVoteSitesEnabled().size();
|
||||
return "" + plugin.getVoteSiteManager().getVoteSitesEnabled().size();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -171,6 +99,7 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getRewardHandler().getRewards().size();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -179,6 +108,14 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("config_onlinemode", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getOptions().isOnlineMode();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofusers", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -186,9 +123,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";
|
||||
@@ -214,6 +153,7 @@ public class VotingPluginMetrics {
|
||||
return plugin.getOptions().getStorageType().toString();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -221,13 +161,7 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getOptions().isDisableCheckOnWorldChange();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votereminding_enabled", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getConfigFile().isVoteRemindingEnabled();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -235,6 +169,7 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterMonthly();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -242,6 +177,7 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterWeekly();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -249,33 +185,19 @@ public class VotingPluginMetrics {
|
||||
return "" + plugin.getConfigFile().isLoadTopVoterDaily();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeemethod", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "" + plugin.getBungeeHandler().getMethod().toString();
|
||||
} else {
|
||||
return "Disabled";
|
||||
}
|
||||
return "Disabled";
|
||||
}
|
||||
}));
|
||||
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeebroadcast", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isBungeeBroadcast();
|
||||
}
|
||||
}));
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeebroadcastalways", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + plugin.getBungeeSettings().isBungeeBroadcastAlways();
|
||||
}
|
||||
}));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("perserverrewards", new Callable<String>() {
|
||||
|
||||
@Override
|
||||
@@ -374,5 +296,188 @@ public class VotingPluginMetrics {
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* Broadcast metrics:
|
||||
* - Always log broadcast_type if VoteBroadcast.Type exists (even if NONE)
|
||||
* - If Type == NONE, ignore the rest of the broadcast settings
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
final ConfigurationSection root = safeConfig(plugin);
|
||||
final ConfigurationSection voteBroadcast = getSection(root, "VoteBroadcast");
|
||||
if (voteBroadcast != null && voteBroadcast.isString("Type")) {
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("broadcast_type", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return voteBroadcast.getString("Type");
|
||||
}
|
||||
}));
|
||||
|
||||
final String type = voteBroadcast.getString("Type", null);
|
||||
if (type != null && !"NONE".equalsIgnoreCase(type)) {
|
||||
|
||||
if (voteBroadcast.isString("Duration")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("broadcast_duration", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return voteBroadcast.getString("Duration");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (voteBroadcast.isInt("MaxSitesListed")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("broadcast_max_sites_listed",
|
||||
new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return bucketMaxSites(voteBroadcast.getInt("MaxSitesListed"));
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* VoteLogging metrics:
|
||||
* - Only log when VoteLogging.Enabled is true
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
final ConfigurationSection voteLogging = getSection(root, "VoteLogging");
|
||||
if (voteLogging != null && voteLogging.getBoolean("Enabled", false)) {
|
||||
|
||||
if (voteLogging.isInt("PurgeDays")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votelogging_purgedays", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return bucketPurgeDays(voteLogging.getInt("PurgeDays"));
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
if (voteLogging.isBoolean("UseMainMySQL")) {
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votelogging_usemainmysql", new Callable<String>() {
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return "" + voteLogging.getBoolean("UseMainMySQL");
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely gets the root configuration section.
|
||||
*
|
||||
* @param plugin plugin instance
|
||||
* @return root config section, or null if inaccessible
|
||||
*/
|
||||
private ConfigurationSection safeConfig(final VotingPluginMain plugin) {
|
||||
try {
|
||||
return plugin.getConfigFile().getData();
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a child section safely.
|
||||
*
|
||||
* @param root root section
|
||||
* @param key child key
|
||||
* @return child section or null
|
||||
*/
|
||||
private ConfigurationSection getSection(final ConfigurationSection root, final String key) {
|
||||
if (root == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return root.getConfigurationSection(key);
|
||||
} catch (Exception ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Buckets a milestone count to reduce bStats cardinality.
|
||||
*
|
||||
* @param count count
|
||||
* @return bucket string
|
||||
*/
|
||||
private String bucketCount(final int count) {
|
||||
if (count <= 0) {
|
||||
return "0";
|
||||
}
|
||||
if (count == 1) {
|
||||
return "1";
|
||||
}
|
||||
if (count <= 5) {
|
||||
return "2-5";
|
||||
}
|
||||
if (count <= 10) {
|
||||
return "6-10";
|
||||
}
|
||||
if (count <= 25) {
|
||||
return "11-25";
|
||||
}
|
||||
if (count <= 50) {
|
||||
return "26-50";
|
||||
}
|
||||
if (count <= 100) {
|
||||
return "51-100";
|
||||
}
|
||||
return ">100";
|
||||
}
|
||||
|
||||
/**
|
||||
* Buckets MaxSitesListed to reduce bStats cardinality.
|
||||
*
|
||||
* @param maxSites max sites listed
|
||||
* @return bucket string
|
||||
*/
|
||||
private String bucketMaxSites(final int maxSites) {
|
||||
if (maxSites <= 0) {
|
||||
return "0";
|
||||
}
|
||||
if (maxSites <= 5) {
|
||||
return "1-5";
|
||||
}
|
||||
if (maxSites <= 10) {
|
||||
return "6-10";
|
||||
}
|
||||
if (maxSites <= 25) {
|
||||
return "11-25";
|
||||
}
|
||||
return ">25";
|
||||
}
|
||||
|
||||
/**
|
||||
* Buckets purge days to reduce bStats cardinality.
|
||||
*
|
||||
* @param purgeDays purge days
|
||||
* @return bucket string
|
||||
*/
|
||||
private String bucketPurgeDays(final int purgeDays) {
|
||||
if (purgeDays < 0) {
|
||||
return "disabled";
|
||||
}
|
||||
if (purgeDays == 0) {
|
||||
return "0";
|
||||
}
|
||||
if (purgeDays <= 7) {
|
||||
return "1-7";
|
||||
}
|
||||
if (purgeDays <= 30) {
|
||||
return "8-30";
|
||||
}
|
||||
if (purgeDays <= 90) {
|
||||
return "31-90";
|
||||
}
|
||||
if (purgeDays <= 365) {
|
||||
return "91-365";
|
||||
}
|
||||
return ">365";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
/**
|
||||
* Defines HOW vote broadcasts are rendered.
|
||||
*
|
||||
* Terminology:
|
||||
* - BroadcastMsg : used when EXACTLY ONE item exists (single-site vote)
|
||||
* - Header : used ONCE when MULTIPLE items exist (batch/interval)
|
||||
* - ListLine : used ONCE PER ITEM when MULTIPLE items exist
|
||||
*
|
||||
* Placeholders (always available):
|
||||
* - %player% : player name (or "Server" for interval summaries)
|
||||
* - %site% : the current site/item for this line
|
||||
* - %sites_count% : number of items in the list
|
||||
* - %sites% : csv of items in the list
|
||||
* - %reason% : internal reason string ("vote", "batch", "interval", etc)
|
||||
*
|
||||
* Extra context placeholders (INTERVAL_SUMMARY_GLOBAL):
|
||||
* - %players% / %numberofplayers%
|
||||
* - %sites% / %numberofsites% (note: %sites% is csv; %numberofsites% is count)
|
||||
*/
|
||||
public final class BroadcastFormat {
|
||||
|
||||
private final String broadcastMsg;
|
||||
private final String header;
|
||||
private final String listLine;
|
||||
|
||||
/**
|
||||
* Constructor for BroadcastFormat.
|
||||
*
|
||||
* @param broadcastMsg the broadcast message template
|
||||
* @param header the header template
|
||||
* @param listLine the list line template
|
||||
*/
|
||||
public BroadcastFormat(String broadcastMsg, String header, String listLine) {
|
||||
this.broadcastMsg = broadcastMsg == null ? "" : broadcastMsg;
|
||||
this.header = header == null ? "" : header;
|
||||
this.listLine = listLine == null ? "" : listLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the broadcast with player name, items, and reason.
|
||||
*
|
||||
* @param playerName the player name
|
||||
* @param items the list of items
|
||||
* @param reason the reason string
|
||||
* @return the rendered list of strings
|
||||
*/
|
||||
public List<String> render(String playerName, List<String> items, String reason) {
|
||||
return render(playerName, items, reason, Collections.<String, String>emptyMap());
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the broadcast with player name, items, reason, and context.
|
||||
*
|
||||
* @param playerName the player name
|
||||
* @param items the list of items
|
||||
* @param reason the reason string
|
||||
* @param context additional context placeholders
|
||||
* @return the rendered list of strings
|
||||
*/
|
||||
public List<String> render(String playerName, List<String> items, String reason, Map<String, String> context) {
|
||||
List<String> output = new ArrayList<String>();
|
||||
int count = items == null ? 0 : items.size();
|
||||
|
||||
String csv = "";
|
||||
if (count > 0) {
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (String s : items) {
|
||||
if (s != null && !s.isEmpty()) {
|
||||
joiner.add(s);
|
||||
}
|
||||
}
|
||||
csv = joiner.toString();
|
||||
}
|
||||
|
||||
// SINGLE ITEM → BroadcastMsg
|
||||
if (count == 1 && !broadcastMsg.isEmpty()) {
|
||||
output.add(apply(broadcastMsg, playerName, items.get(0), count, csv, reason, context));
|
||||
return output;
|
||||
}
|
||||
|
||||
// MULTI ITEM → Header + ListLine per item
|
||||
if (!header.isEmpty()) {
|
||||
output.add(apply(header, playerName, "", count, csv, reason, context));
|
||||
}
|
||||
|
||||
if (count > 0 && !listLine.isEmpty()) {
|
||||
for (String s : items) {
|
||||
output.add(apply(listLine, playerName, s, count, csv, reason, context));
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private String apply(String template,
|
||||
String player,
|
||||
String item,
|
||||
int count,
|
||||
String csv,
|
||||
String reason,
|
||||
Map<String, String> context) {
|
||||
|
||||
String out = template
|
||||
.replace("%player%", player == null ? "" : player)
|
||||
.replace("%site%", item == null ? "" : item)
|
||||
.replace("%sites_count%", String.valueOf(count))
|
||||
.replace("%sites%", csv == null ? "" : csv)
|
||||
.replace("%reason%", reason == null ? "" : reason);
|
||||
|
||||
if (context != null && !context.isEmpty()) {
|
||||
for (Map.Entry<String, String> e : context.entrySet()) {
|
||||
out = out.replace("%" + e.getKey() + "%", e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,443 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.MiscUtils;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.time.ParsedDuration;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* Core broadcast logic.
|
||||
*
|
||||
* Decides WHEN to broadcast and builds lines/messages. Uses your existing
|
||||
* "eligible online players" behavior (disable broadcast respected).
|
||||
*
|
||||
* NOTE: Backend servers only.
|
||||
*/
|
||||
public final class BroadcastHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Only used for day-boundary logic (FIRST_VOTE_OF_DAY).
|
||||
*/
|
||||
private final ZoneId zoneId;
|
||||
|
||||
private volatile BroadcastSettings settings;
|
||||
|
||||
// Per-player cooldown tracking
|
||||
private final ConcurrentHashMap<UUID, Instant> lastBroadcastAt = new ConcurrentHashMap<UUID, Instant>();
|
||||
|
||||
// Batch window tracking
|
||||
private final ConcurrentHashMap<UUID, LinkedHashSet<String>> pendingSites = new ConcurrentHashMap<UUID, LinkedHashSet<String>>();
|
||||
private final ConcurrentHashMap<UUID, BukkitTask> pendingFlush = new ConcurrentHashMap<UUID, BukkitTask>();
|
||||
|
||||
// First vote of day tracking
|
||||
private final ConcurrentHashMap<UUID, LocalDate> firstVoteDay = new ConcurrentHashMap<UUID, LocalDate>();
|
||||
|
||||
// Interval summary tracking (uuid -> set of sites during interval)
|
||||
private final ConcurrentHashMap<UUID, LinkedHashSet<String>> intervalSites = new ConcurrentHashMap<UUID, LinkedHashSet<String>>();
|
||||
private volatile BukkitTask intervalTask;
|
||||
|
||||
/**
|
||||
* Constructs a new BroadcastHandler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
* @param settings the broadcast settings
|
||||
* @param zoneId the time zone ID, or null to use system default
|
||||
*/
|
||||
public BroadcastHandler(VotingPluginMain plugin, BroadcastSettings settings, ZoneId zoneId) {
|
||||
this.plugin = plugin;
|
||||
this.settings = settings;
|
||||
this.zoneId = zoneId == null ? ZoneId.systemDefault() : zoneId;
|
||||
|
||||
rescheduleIntervalIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the broadcast settings and reschedules interval task if needed.
|
||||
*
|
||||
* @param settings the new broadcast settings
|
||||
*/
|
||||
public void setSettings(BroadcastSettings settings) {
|
||||
this.settings = settings;
|
||||
rescheduleIntervalIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call whenever a vote is received.
|
||||
*
|
||||
* @param uuid player's uuid
|
||||
* @param playerName player name (optional; if null/empty, resolved from Bukkit)
|
||||
* @param siteName vote site name (display name)
|
||||
* @param wasOnline whether the player was online when the vote was received
|
||||
*/
|
||||
public void broadcastVote(UUID uuid, String playerName, String siteName, boolean wasOnline) {
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.isDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Always collect for interval summaries (even if Type isn't interval right
|
||||
// now).
|
||||
recordInterval(uuid, siteName);
|
||||
|
||||
String name = playerName == null || playerName.isEmpty() ? resolveName(uuid) : playerName;
|
||||
|
||||
VoteBroadcastType type = s.getType();
|
||||
|
||||
// New: types that only broadcast if the voting player is online
|
||||
if (type == VoteBroadcastType.EVERY_VOTE_ONLINE_ONLY) {
|
||||
if (!wasOnline) {
|
||||
return;
|
||||
}
|
||||
broadcastNow(name, single(siteName), "vote_online_only", null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == VoteBroadcastType.EVERY_VOTE) {
|
||||
broadcastNow(name, single(siteName), "vote", null);
|
||||
|
||||
} else if (type == VoteBroadcastType.COOLDOWN_PER_PLAYER) {
|
||||
if (checkAndMarkCooldown(uuid, s.getDuration())) {
|
||||
broadcastNow(name, single(siteName), "cooldown", null);
|
||||
}
|
||||
|
||||
} else if (type == VoteBroadcastType.BATCH_WINDOW_PER_PLAYER) {
|
||||
bufferBatch(uuid, name, siteName, s.getDuration());
|
||||
|
||||
} else if (type == VoteBroadcastType.FIRST_VOTE_OF_DAY) {
|
||||
if (markFirstVoteOfDay(uuid)) {
|
||||
broadcastNow(name, single(siteName), "first_day", null);
|
||||
}
|
||||
|
||||
} else if (type == VoteBroadcastType.INTERVAL_SUMMARY_GLOBAL) {
|
||||
// handled by scheduled task
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Broadcast helpers =======================
|
||||
*/
|
||||
|
||||
private void broadcastNow(String playerName, List<String> sites, String reason, Map<String, String> extraContext) {
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.isDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> cleaned = applyMaxSites(sites, s);
|
||||
cleaned.sort(new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String a, String b) {
|
||||
String aa = a == null ? "" : a.toLowerCase(Locale.ROOT);
|
||||
String bb = b == null ? "" : b.toLowerCase(Locale.ROOT);
|
||||
return aa.compareTo(bb);
|
||||
}
|
||||
});
|
||||
|
||||
List<String> lines;
|
||||
if (extraContext == null) {
|
||||
lines = s.getFormat().render(playerName, cleaned, reason);
|
||||
} else {
|
||||
lines = s.getFormat().render(playerName, cleaned, reason, extraContext);
|
||||
}
|
||||
|
||||
for (String line : lines) {
|
||||
broadcastToEligiblePlayers(line);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Your reliable broadcast style: - only sends to online players - respects
|
||||
* per-player disable broadcast toggle - runs PlaceholderAPI style per-player
|
||||
* placeholders (if your PlaceholderUtils does) - supports %newline% / %NewLine%
|
||||
* splitting
|
||||
*/
|
||||
private void broadcastToEligiblePlayers(String broadcastMsg) {
|
||||
if (broadcastMsg == null || broadcastMsg.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
VotingPluginUser u = plugin.getVotingPluginUserManager().getVotingPluginUser(p);
|
||||
if (u != null && !u.getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
// If you prefer your manual loop, keep it here (not in main)
|
||||
MiscUtils.getInstance().broadcast(broadcastMsg, players);
|
||||
|
||||
Bukkit.getServer().getConsoleSender().sendMessage(MessageAPI.colorize(broadcastMsg));
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Cooldown logic (fixed millis) =======================
|
||||
*/
|
||||
|
||||
private boolean checkAndMarkCooldown(UUID uuid, ParsedDuration cooldown) {
|
||||
if (cooldown == null || cooldown.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Instant now = Instant.now();
|
||||
Instant last = lastBroadcastAt.get(uuid);
|
||||
|
||||
if (last == null) {
|
||||
lastBroadcastAt.put(uuid, now);
|
||||
return true;
|
||||
}
|
||||
|
||||
Instant next = cooldown.addTo(last);
|
||||
if (!now.isBefore(next)) {
|
||||
lastBroadcastAt.put(uuid, now);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Batch window logic (fixed millis)
|
||||
* =======================
|
||||
*/
|
||||
|
||||
private void bufferBatch(UUID uuid, String playerName, String siteName, ParsedDuration window) {
|
||||
if (siteName != null && !siteName.isEmpty()) {
|
||||
LinkedHashSet<String> set = pendingSites.get(uuid);
|
||||
if (set == null) {
|
||||
LinkedHashSet<String> created = new LinkedHashSet<String>();
|
||||
set = pendingSites.putIfAbsent(uuid, created);
|
||||
if (set == null) {
|
||||
set = created;
|
||||
}
|
||||
}
|
||||
synchronized (set) {
|
||||
set.add(siteName);
|
||||
}
|
||||
}
|
||||
|
||||
if (!pendingFlush.containsKey(uuid)) {
|
||||
BukkitTask task = scheduleBatchFlush(uuid, playerName, window);
|
||||
BukkitTask prev = pendingFlush.putIfAbsent(uuid, task);
|
||||
if (prev != null) {
|
||||
task.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private BukkitTask scheduleBatchFlush(final UUID uuid, final String playerName, ParsedDuration window) {
|
||||
long delayMs = window == null ? 1L : window.delayMillisFromNow();
|
||||
long ticks = Math.max(1L, delayMs / 50L);
|
||||
|
||||
return Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
flushBatch(uuid, playerName);
|
||||
} finally {
|
||||
pendingFlush.remove(uuid);
|
||||
}
|
||||
}
|
||||
}, ticks);
|
||||
}
|
||||
|
||||
private void flushBatch(UUID uuid, String playerName) {
|
||||
Set<String> set = pendingSites.remove(uuid);
|
||||
if (set == null || set.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> list;
|
||||
synchronized (set) {
|
||||
list = new ArrayList<String>(set);
|
||||
}
|
||||
broadcastNow(playerName, list, "batch", null);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= First vote of day (calendar) =======================
|
||||
*/
|
||||
|
||||
private boolean markFirstVoteOfDay(UUID uuid) {
|
||||
LocalDate today = LocalDate.now(zoneId);
|
||||
LocalDate last = firstVoteDay.putIfAbsent(uuid, today);
|
||||
|
||||
if (last == null) {
|
||||
return true;
|
||||
}
|
||||
if (!last.equals(today)) {
|
||||
firstVoteDay.put(uuid, today);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Interval summary =======================
|
||||
*/
|
||||
|
||||
private void rescheduleIntervalIfNeeded() {
|
||||
if (intervalTask != null) {
|
||||
intervalTask.cancel();
|
||||
intervalTask = null;
|
||||
}
|
||||
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.getType() != VoteBroadcastType.INTERVAL_SUMMARY_GLOBAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
long delayMs = s.getDuration() == null ? 1L : s.getDuration().delayMillisFromNow();
|
||||
long ticks = Math.max(1L, delayMs / 50L);
|
||||
|
||||
intervalTask = Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
broadcastIntervalSummary();
|
||||
}
|
||||
}, ticks, ticks);
|
||||
}
|
||||
|
||||
private void recordInterval(UUID uuid, String siteName) {
|
||||
if (siteName == null || siteName.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
LinkedHashSet<String> set = intervalSites.get(uuid);
|
||||
if (set == null) {
|
||||
LinkedHashSet<String> created = new LinkedHashSet<String>();
|
||||
set = intervalSites.putIfAbsent(uuid, created);
|
||||
if (set == null) {
|
||||
set = created;
|
||||
}
|
||||
}
|
||||
synchronized (set) {
|
||||
set.add(siteName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Interval summary supports extra context placeholders: - %players% /
|
||||
* %numberofplayers% - %sites% / %numberofsites%
|
||||
*/
|
||||
private void broadcastIntervalSummary() {
|
||||
BroadcastSettings s = settings;
|
||||
if (s == null || s.isDisabled() || s.getType() != VoteBroadcastType.INTERVAL_SUMMARY_GLOBAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConcurrentHashMap<UUID, LinkedHashSet<String>> snapshot = new ConcurrentHashMap<UUID, LinkedHashSet<String>>(
|
||||
intervalSites);
|
||||
intervalSites.clear();
|
||||
|
||||
if (snapshot.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> entries = new ArrayList<String>();
|
||||
List<String> players = new ArrayList<String>();
|
||||
LinkedHashSet<String> uniqueSites = new LinkedHashSet<String>();
|
||||
|
||||
for (Map.Entry<UUID, LinkedHashSet<String>> entry : snapshot.entrySet()) {
|
||||
LinkedHashSet<String> siteSet = entry.getValue();
|
||||
if (siteSet == null || siteSet.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String name = resolveName(entry.getKey());
|
||||
players.add(name);
|
||||
|
||||
int siteCount;
|
||||
synchronized (siteSet) {
|
||||
siteCount = siteSet.size();
|
||||
for (String site : siteSet) {
|
||||
if (site != null && !site.isEmpty()) {
|
||||
uniqueSites.add(site);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
entries.add(name + " (" + siteCount + ")");
|
||||
}
|
||||
|
||||
if (entries.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String playersCsv = join(players);
|
||||
String sitesCsv = join(new ArrayList<String>(uniqueSites));
|
||||
|
||||
ConcurrentHashMap<String, String> context = new ConcurrentHashMap<String, String>();
|
||||
context.put("players", playersCsv);
|
||||
context.put("numberofplayers", String.valueOf(players.size()));
|
||||
context.put("sites", sitesCsv);
|
||||
context.put("numberofsites", String.valueOf(uniqueSites.size()));
|
||||
|
||||
broadcastNow("Server", entries, "interval", context);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======================= Utilities =======================
|
||||
*/
|
||||
|
||||
private List<String> single(String site) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (site != null && !site.isEmpty()) {
|
||||
list.add(site);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<String> applyMaxSites(List<String> sites, BroadcastSettings s) {
|
||||
if (sites == null) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
int max = s.getMaxSitesListed();
|
||||
if (max <= 0 || sites.size() <= max) {
|
||||
return new ArrayList<String>(sites);
|
||||
}
|
||||
return new ArrayList<String>(sites.subList(0, max));
|
||||
}
|
||||
|
||||
private String resolveName(UUID uuid) {
|
||||
try {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(uuid);
|
||||
String name = op == null ? null : op.getName();
|
||||
return name == null || name.isEmpty() ? "Player" : name;
|
||||
} catch (Exception e) {
|
||||
return "Player";
|
||||
}
|
||||
}
|
||||
|
||||
private String join(List<String> list) {
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (String s : list) {
|
||||
if (s != null && !s.isEmpty()) {
|
||||
joiner.add(s);
|
||||
}
|
||||
}
|
||||
return joiner.toString();
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.simpleapi.time.ParsedDuration;
|
||||
|
||||
/**
|
||||
* Immutable broadcast configuration.
|
||||
*
|
||||
* Type: NONE disables broadcasting.
|
||||
*/
|
||||
public final class BroadcastSettings {
|
||||
|
||||
private final VoteBroadcastType type;
|
||||
private final ParsedDuration duration;
|
||||
private final int maxSitesListed;
|
||||
private final BroadcastFormat format;
|
||||
|
||||
/**
|
||||
* Constructs a BroadcastSettings with the specified parameters.
|
||||
*
|
||||
* @param type the broadcast type
|
||||
* @param duration the broadcast duration
|
||||
* @param maxSitesListed the maximum number of sites to list
|
||||
* @param format the broadcast format
|
||||
*/
|
||||
public BroadcastSettings(VoteBroadcastType type, ParsedDuration duration, int maxSitesListed,
|
||||
BroadcastFormat format) {
|
||||
this.type = type == null ? VoteBroadcastType.NONE : type;
|
||||
this.duration = duration == null ? ParsedDuration.empty() : duration;
|
||||
this.maxSitesListed = Math.max(0, maxSitesListed);
|
||||
this.format = format == null ? new BroadcastFormat("", "", "") : format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the broadcast type.
|
||||
*
|
||||
* @return the broadcast type
|
||||
*/
|
||||
public VoteBroadcastType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the broadcast duration.
|
||||
*
|
||||
* @return the broadcast duration
|
||||
*/
|
||||
public ParsedDuration getDuration() {
|
||||
return duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of sites to list.
|
||||
*
|
||||
* @return the maximum number of sites to list
|
||||
*/
|
||||
public int getMaxSitesListed() {
|
||||
return maxSitesListed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the broadcast format.
|
||||
*
|
||||
* @return the broadcast format
|
||||
*/
|
||||
public BroadcastFormat getFormat() {
|
||||
return format;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether broadcasting is disabled.
|
||||
*
|
||||
* @return true if broadcasting is disabled
|
||||
*/
|
||||
public boolean isDisabled() {
|
||||
return type == VoteBroadcastType.NONE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads VoteBroadcast settings from config.yml.
|
||||
*
|
||||
* Expected structure: VoteBroadcast: Type: EVERY_VOTE Duration: 2m
|
||||
* MaxSitesListed: 0 Format: BroadcastMsg: '...' Header: '...' ListLine: '...'
|
||||
*
|
||||
* @param sec the configuration section to load from
|
||||
* @return the loaded broadcast settings
|
||||
*/
|
||||
public static BroadcastSettings load(ConfigurationSection sec) {
|
||||
VoteBroadcastType type = VoteBroadcastType.parse(sec == null ? null : sec.getString("Type"),
|
||||
VoteBroadcastType.NONE);
|
||||
|
||||
ParsedDuration duration = ParsedDuration.parse(sec == null ? "2m" : sec.getString("Duration", "2m"),
|
||||
TimeUnit.MINUTES);
|
||||
|
||||
int maxSites = sec == null ? 0 : sec.getInt("MaxSitesListed", 0);
|
||||
|
||||
ConfigurationSection fmt = sec == null ? null : sec.getConfigurationSection("Format");
|
||||
|
||||
String broadcastMsg = fmt == null ? "&6[Vote] &aThanks &e%player% &afor voting on &e%site%&a!"
|
||||
: fmt.getString("BroadcastMsg", "&6[Vote] &aThanks &e%player% &afor voting on &e%site%&a!");
|
||||
|
||||
String header = fmt == null ? "&6[Vote] &a%player% voted! &7(%sites_count%)"
|
||||
: fmt.getString("Header", "&6[Vote] &a%player% voted! &7(%sites_count%)");
|
||||
|
||||
String listLine = fmt == null ? " &7- &e%site%" : fmt.getString("ListLine", " &7- &e%site%");
|
||||
|
||||
return new BroadcastSettings(type, duration, maxSites, new BroadcastFormat(broadcastMsg, header, listLine));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.bencodez.votingplugin.broadcast;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Defines WHEN vote broadcasts occur.
|
||||
*
|
||||
* Set Type: NONE to disable broadcasting entirely.
|
||||
*/
|
||||
public enum VoteBroadcastType {
|
||||
|
||||
/**
|
||||
* No vote broadcasting.
|
||||
*/
|
||||
NONE,
|
||||
|
||||
/**
|
||||
* Broadcast on every vote (even if the player is offline). Uses
|
||||
* Format.BroadcastMsg (+ optional header/list if you choose).
|
||||
*/
|
||||
EVERY_VOTE,
|
||||
|
||||
/**
|
||||
* Broadcast on every vote ONLY if the voting player is online. Useful when
|
||||
* processing offline votes but you don't want global spam for them.
|
||||
*/
|
||||
EVERY_VOTE_ONLINE_ONLY,
|
||||
|
||||
/**
|
||||
* Broadcast at most once per Duration per player. (Even if they vote multiple
|
||||
* sites inside the cooldown.)
|
||||
*/
|
||||
COOLDOWN_PER_PLAYER,
|
||||
|
||||
/**
|
||||
* Batch sites per player for Duration, then broadcast one message listing
|
||||
* sites.
|
||||
*/
|
||||
BATCH_WINDOW_PER_PLAYER,
|
||||
|
||||
/**
|
||||
* Broadcast only the first vote of the day per player (calendar day).
|
||||
*/
|
||||
FIRST_VOTE_OF_DAY,
|
||||
|
||||
/**
|
||||
* Every Duration, broadcast a global summary of who voted and how many sites.
|
||||
* Uses context placeholders: %players%, %numberofplayers%, %sites%,
|
||||
* %numberofsites%.
|
||||
*/
|
||||
INTERVAL_SUMMARY_GLOBAL;
|
||||
|
||||
/**
|
||||
* Parses a vote broadcast type from a string.
|
||||
* @param s the string to parse
|
||||
* @param def the default value if parsing fails
|
||||
* @return the parsed broadcast type or default
|
||||
*/
|
||||
public static VoteBroadcastType parse(String s, VoteBroadcastType def) {
|
||||
if (s == null || s.trim().isEmpty()) {
|
||||
return def;
|
||||
}
|
||||
try {
|
||||
return VoteBroadcastType.valueOf(s.trim().toUpperCase(Locale.ROOT));
|
||||
} catch (Exception ignored) {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1623
-643
File diff suppressed because it is too large.
Load diff
+5
@@ -16,6 +16,11 @@ public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new CommandAdminVote instance.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
*/
|
||||
public CommandAdminVote(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
+10
-6
@@ -25,6 +25,12 @@ public class CommandAliases implements CommandExecutor {
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new CommandAliases instance.
|
||||
*
|
||||
* @param cmdHandle the command handler
|
||||
* @param adminCommand whether this is an admin command
|
||||
*/
|
||||
public CommandAliases(CommandHandler cmdHandle, boolean adminCommand) {
|
||||
this.cmdHandle = cmdHandle;
|
||||
this.adminCommand = adminCommand;
|
||||
@@ -40,7 +46,7 @@ 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);
|
||||
@@ -48,7 +54,7 @@ public class CommandAliases implements CommandExecutor {
|
||||
plugin.debug("Attempting cmd...");
|
||||
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 {
|
||||
@@ -91,11 +97,9 @@ public class CommandAliases implements CommandExecutor {
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(
|
||||
MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandAdminVote()));
|
||||
} else {
|
||||
sender.sendMessage(
|
||||
MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
sender.sendMessage(MessageAPI.colorize(plugin.getConfigFile().getFormatInvalidCommandVote()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
File renamed without changes.
+53
-64
@@ -19,26 +19,32 @@ 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.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.simpleapi.valuerequest.InputMethod;
|
||||
import com.bencodez.simpleapi.valuerequest.StringListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
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;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteMilestones;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.milestones.AdminVoteVoteMilestones;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.voteshop.AdminVoteVoteShop;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
/**
|
||||
* Admin GUI handler for the voting plugin.
|
||||
*/
|
||||
public class AdminGUI {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminGUI.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
*/
|
||||
public AdminGUI(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@@ -49,7 +55,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)) {
|
||||
@@ -58,14 +64,14 @@ public class AdminGUI {
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
new ValueRequest(plugin, plugin.getDialogService(), null).requestString(player, "", null, true, "Enter vote site", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
plugin.getConfigVoteSites().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
openAdminGUIVoteSiteSite(player, plugin.getVoteSite(value, true));
|
||||
openAdminGUIVoteSiteSite(player, plugin.getVoteSiteManager().getVoteSite(value, true));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -82,19 +88,11 @@ public class AdminGUI {
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.DIAMOND_BLOCK, 1).setName("&cEdit Milestones")) {
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.DIAMOND_BLOCK, 1).setName("&cEdit VoteMilestones")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteMilestones(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton(new ItemBuilder(Material.COBBLESTONE, 1).setName("&cEdit Cumulative")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteCumulative(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
|
||||
new AdminVoteVoteMilestones(plugin, clickEvent.getPlayer()).open(GUIMethod.CHEST);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -226,6 +224,9 @@ public class AdminGUI {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load hook to add admin GUI buttons.
|
||||
*/
|
||||
public void loadHook() {
|
||||
for (BInventoryButton b : adminGUIButtons()) {
|
||||
com.bencodez.advancedcore.command.gui.AdminGUI.getInstance().addButton(b);
|
||||
@@ -240,8 +241,8 @@ public class AdminGUI {
|
||||
public void openAdminGUIVoteSites(Player player) {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
for (VoteSite voteSite : plugin.getVoteSiteManager().getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("Enabled: " + voteSite.isEnabled());
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
|
||||
@@ -249,19 +250,18 @@ public class AdminGUI {
|
||||
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.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);
|
||||
@@ -281,29 +281,29 @@ 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());
|
||||
}
|
||||
new ValueRequestBuilder(new StringListener() {
|
||||
new ValueRequest(plugin, plugin.getDialogService(), InputMethod.INVENTORY).requestString(
|
||||
event.getWhoClicked(), "", playerNames, true, "Select player", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getPlayerMeta(plugin, player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
plugin.getVoteTimer().submit(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
.allowCustomOption(true).request(event.getWhoClicked());
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -349,24 +349,13 @@ public class AdminGUI {
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelay", voteSite.getVoteDelay()) {
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("VoteDelay", voteSite.getVoteDelay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelayMin", voteSite.getVoteDelay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
|
||||
plugin.getConfigVoteSites().setVoteDelay(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
@@ -377,7 +366,7 @@ public class AdminGUI {
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelay(siteName, num.intValue());
|
||||
plugin.getConfigVoteSites().setVoteDelayDailyHour(siteName, num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
@@ -463,4 +452,4 @@ public class AdminGUI {
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
+25
@@ -14,12 +14,22 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Abstract class for admin vote confirmation dialogs.
|
||||
*/
|
||||
public abstract class AdminVoteConfirmation extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteConfirmation.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param title the title of the confirmation dialog
|
||||
*/
|
||||
public AdminVoteConfirmation(VotingPluginMain plugin, CommandSender player, String title) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -31,6 +41,11 @@ public abstract class AdminVoteConfirmation extends GUIHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
@@ -60,8 +75,18 @@ public abstract class AdminVoteConfirmation extends GUIHandler {
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user confirms the action.
|
||||
*
|
||||
* @param p the player who confirmed
|
||||
*/
|
||||
public abstract void onConfirm(Player p);
|
||||
|
||||
/**
|
||||
* Called when the user denies the action.
|
||||
*
|
||||
* @param p the player who denied
|
||||
*/
|
||||
public abstract void onDeny(Player p);
|
||||
|
||||
@Override
|
||||
+19
-4
@@ -15,11 +15,21 @@ import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* Admin help GUI handler.
|
||||
*/
|
||||
public class AdminVoteHelp extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteHelp.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param page the page number to display
|
||||
*/
|
||||
public AdminVoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -35,7 +45,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;
|
||||
@@ -54,6 +64,11 @@ public class AdminVoteHelp extends GUIHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin help text.
|
||||
*
|
||||
@@ -61,8 +76,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 +86,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) {
|
||||
+48
-5
@@ -15,18 +15,36 @@ import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin permissions GUI handler.
|
||||
*/
|
||||
public class AdminVotePerms extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePerms.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePerms with player name.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param page the page number
|
||||
* @param playerName the player name to check
|
||||
*/
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page, String playerName) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -39,8 +57,19 @@ public class AdminVotePerms extends GUIHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* List permissions for a sender.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return array of permission strings
|
||||
*/
|
||||
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 +129,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);
|
||||
|
||||
@@ -113,12 +142,20 @@ public class AdminVotePerms extends GUIHandler {
|
||||
return ArrayUtils.convert(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* List permissions for a specific player.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @param player the player name
|
||||
* @param page the page number
|
||||
* @return list of permission strings
|
||||
*/
|
||||
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)) {
|
||||
@@ -179,8 +216,14 @@ public class AdminVotePerms extends GUIHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* List permissions in developer format.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return array of permission strings in developer format
|
||||
*/
|
||||
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");
|
||||
+17
-3
@@ -18,10 +18,19 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
/**
|
||||
* Admin placeholders GUI handler.
|
||||
*/
|
||||
public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePlaceholders.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVotePlaceholders(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -32,6 +41,11 @@ public class AdminVotePlaceholders extends GUIHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
@@ -48,7 +62,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 +80,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 +93,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();
|
||||
+18
-6
@@ -18,11 +18,21 @@ import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
/**
|
||||
* Admin placeholders player GUI handler.
|
||||
*/
|
||||
public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVotePlaceholdersPlayer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public AdminVotePlaceholdersPlayer(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -34,6 +44,11 @@ public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
@@ -45,7 +60,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 +75,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,12 +85,9 @@ 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()) {
|
||||
placeholderUser = plugin.getVotingPluginUserManager().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier().toLowerCase();
|
||||
if (identifier.endsWith("_")) {
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
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.advancedcore.api.user.UserDataFetchMode;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Admin top points GUI handler.
|
||||
*/
|
||||
public class AdminVoteTopPoints extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteTopPoints.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
* @param page the page number
|
||||
*/
|
||||
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 onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@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.userDataFetechMode(UserDataFetchMode.NO_CACHE);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
+32
-14
@@ -17,15 +17,25 @@ 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.valuerequest.ValueRequestBuilder;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.NumberListener;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.simpleapi.valuerequest.InputMethod;
|
||||
import com.bencodez.simpleapi.valuerequest.NumberListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote party GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteParty extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteParty.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteParty(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -45,12 +55,16 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
EditGUI inv = new EditGUI("Edit VoteParty");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteParty");
|
||||
|
||||
// to add
|
||||
inv.addButton(new EditGUIButton(new ItemBuilder(Material.PAPER, 1),
|
||||
new EditGUIValueBoolean("Enabled", plugin.getSpecialRewardsConfig().isVotePartyEnabled()) {
|
||||
|
||||
@@ -83,15 +97,21 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ValueRequestBuilder(new NumberListener() {
|
||||
ArrayList<Number> options = new ArrayList<Number>();
|
||||
options.add(Integer.valueOf(0));
|
||||
options.add(Integer.valueOf(10));
|
||||
options.add(Integer.valueOf(50));
|
||||
options.add(Integer.valueOf(100));
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(value.intValue());
|
||||
}
|
||||
}, new Number[] { 0, 10, 50, 100 })
|
||||
.currentValue("" + plugin.getServerData().getVotePartyExtraRequired()).allowCustomOption(true)
|
||||
.request(clickEvent.getPlayer());
|
||||
new ValueRequest(plugin, plugin.getDialogService(), InputMethod.INVENTORY).requestNumber(
|
||||
clickEvent.getPlayer(), Integer.valueOf(plugin.getServerData().getVotePartyExtraRequired()),
|
||||
options, true, "Set extra votes", new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
plugin.getServerData().setVotePartyExtraRequired(value.intValue());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
@@ -215,8 +235,6 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
}
|
||||
});
|
||||
|
||||
// implement item reward?
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@@ -231,4 +249,4 @@ public class AdminVoteVoteParty extends GUIHandler {
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+17
-2
@@ -12,13 +12,23 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
/**
|
||||
* Admin vote player GUI handler.
|
||||
*/
|
||||
public class AdminVoteVotePlayer extends GUIHandler {
|
||||
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVotePlayer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param playerName the player name
|
||||
*/
|
||||
public AdminVoteVotePlayer(VotingPluginMain plugin, CommandSender player, String playerName) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -44,7 +54,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.getVoteSitesEnabled()) {
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
inv.addButton(new BInventoryButton(site.getItem().setName(site.getKey())) {
|
||||
|
||||
@Override
|
||||
@@ -71,6 +81,11 @@ public class AdminVoteVotePlayer extends GUIHandler {
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
+21
-8
@@ -15,11 +15,20 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteConfirmation;
|
||||
|
||||
public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
/**
|
||||
* Admin vote milestone remove GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteMilestoneRemove extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteMilestoneRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
/**
|
||||
* Constructor for AdminVoteVoteMilestoneRemove.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteMilestoneRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@@ -38,11 +47,16 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Remove milestones");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.MileStones");
|
||||
for (final String votes : plugin.getSpecialRewardsConfig().getMilestoneVotes()) {
|
||||
BInventory inv = new BInventory("Remove VoteMilestones");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteMilestones");
|
||||
for (final String votes : plugin.getVoteMilestonesManager().getConfig().getMilestones().keySet()) {
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(Material.PAPER, 1).setName(votes).addLoreLine("&c&lClick to remove")) {
|
||||
|
||||
@@ -52,18 +66,17 @@ public class AdminVoteMilestoneRemove extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onConfirm(Player p) {
|
||||
plugin.getSpecialRewardsConfig().removeMilestone(votes);
|
||||
plugin.getSpecialRewardsConfig().removeVoteMilestone(votes);
|
||||
p.sendMessage("Removed milestone " + votes);
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeny(Player p) {
|
||||
new AdminVoteMilestones(plugin, p);
|
||||
new AdminVoteVoteMilestones(plugin, p);
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
+120
@@ -0,0 +1,120 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.milestones;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.command.gui.RewardEditGUI;
|
||||
import com.bencodez.simpleapi.valuerequest.InputMethod;
|
||||
import com.bencodez.simpleapi.valuerequest.NumberListener;
|
||||
import com.bencodez.simpleapi.valuerequest.StringListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote milestones GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteMilestones extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteMilestones.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteMilestones(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory("Edit VoteMilestones");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.Edit.VoteMilestones");
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER)
|
||||
.setName("&cEdit existing vote milestone rewards (Legacy milestones not included)")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
Set<String> keys = plugin.getVoteMilestonesManager().getConfig().getMilestones().keySet();
|
||||
ArrayList<String> milestoneKeys = new ArrayList<String>();
|
||||
for (String key : keys) {
|
||||
if (!key.startsWith("Legacy_")) {
|
||||
milestoneKeys.add(key);
|
||||
}
|
||||
}
|
||||
|
||||
new ValueRequest(plugin, plugin.getDialogService(), InputMethod.INVENTORY).requestString(
|
||||
clickEvent.getPlayer(), "", milestoneKeys, false, "Select milestone", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
RewardEditGUI.getInstance().openRewardGUI(clickEvent.getPlayer(),
|
||||
plugin.getRewardHandler().getDirectlyDefined("VoteMilestones." + value + ".Rewards"));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aAdd milestone")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ValueRequest(plugin, plugin.getDialogService(), null).requestNumber(player, 0, null, true,
|
||||
"Enter milestone", new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
plugin.getSpecialRewardsConfig().setVoteMilestone(value.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.REDSTONE_BLOCK).setName("&cRemove milestone")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteVoteMilestoneRemove(plugin, clickEvent.getPlayer()).open();
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select an event filter, then open AdminVoteLogRecent (filtered).
|
||||
*/
|
||||
public class AdminVoteLogEventSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogEventSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogEventSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days) {
|
||||
this(plugin, sender, table, user, days, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogEventSelect with page.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogEventSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@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 {
|
||||
String title = "&aVoteLog - Events";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<VoteLogMysqlTable.VoteLogEvent> events = Arrays.asList(VoteLogMysqlTable.VoteLogEvent.values());
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(events.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= events.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo events")
|
||||
.addLoreLine("&7No events on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
VoteLogMysqlTable.VoteLogEvent ev = events.get(i);
|
||||
inv.addButton(makeEventButton(ev));
|
||||
}
|
||||
}
|
||||
|
||||
// back button
|
||||
if (user != null && plugin.getGui().isChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(7));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEventButton(VoteLogMysqlTable.VoteLogEvent ev) {
|
||||
ItemBuilder item = new ItemBuilder(Material.BOOK).setName("&a" + ev.name())
|
||||
.addLoreLine("&7Click to view recent logs filtered by this event")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, ev).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+125
@@ -0,0 +1,125 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Helper class for admin vote log GUI operations.
|
||||
*/
|
||||
public class AdminVoteLogHelpers {
|
||||
/**
|
||||
* Get the material icon for a vote log event.
|
||||
*
|
||||
* @param event the vote log event
|
||||
* @param status the status of the vote
|
||||
* @return the material to use for the icon
|
||||
*/
|
||||
public static Material getMaterialForEvent(VoteLogMysqlTable.VoteLogEvent event, String status) {
|
||||
// Cached entries still override to chest (keeps your current behavior)
|
||||
if ("CACHED".equalsIgnoreCase(status)) {
|
||||
return Material.CHEST;
|
||||
}
|
||||
|
||||
if (event == null) {
|
||||
return Material.PAPER;
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case VOTE_RECEIVED:
|
||||
return Material.EMERALD;
|
||||
|
||||
case VOTEMILESTONE:
|
||||
return Material.ANVIL;
|
||||
|
||||
case VOTE_STREAK_REWARD:
|
||||
return Material.FIREWORK_ROCKET;
|
||||
|
||||
case TOP_VOTER_REWARD:
|
||||
return Material.GOLD_BLOCK;
|
||||
|
||||
default:
|
||||
return Material.PAPER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the color code for a vote log event.
|
||||
*
|
||||
* @param event the vote log event
|
||||
* @return the color code string
|
||||
*/
|
||||
public static String getEventColor(VoteLogMysqlTable.VoteLogEvent event) {
|
||||
if (event == null) {
|
||||
return "&7";
|
||||
}
|
||||
|
||||
switch (event) {
|
||||
case VOTE_RECEIVED:
|
||||
return "&a";
|
||||
case VOTEMILESTONE:
|
||||
return "&6";
|
||||
|
||||
case VOTE_STREAK_REWARD:
|
||||
return "&d";
|
||||
|
||||
case TOP_VOTER_REWARD:
|
||||
return "&c";
|
||||
|
||||
default:
|
||||
return "&7";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a safe string, converting null to empty string.
|
||||
*
|
||||
* @param s the string to check
|
||||
* @return the string or empty string if null
|
||||
*/
|
||||
public static String safe(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a string is not null and not empty.
|
||||
*
|
||||
* @param s the string to check
|
||||
* @return true if the string is not empty
|
||||
*/
|
||||
public static boolean notEmpty(String s) {
|
||||
return s != null && !s.trim().isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a timestamp in milliseconds to a readable date string.
|
||||
*
|
||||
* @param millis the timestamp in milliseconds
|
||||
* @return the formatted date string
|
||||
*/
|
||||
public static String formatTime(long millis) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(millis));
|
||||
} catch (Exception e) {
|
||||
return String.valueOf(millis);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a shortened version of a UUID string.
|
||||
*
|
||||
* @param uuid the UUID string
|
||||
* @return the first 8 characters of the UUID or "unknown"
|
||||
*/
|
||||
public static String shortUuid(String uuid) {
|
||||
if (uuid == null || uuid.isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
return uuid.length() > 8 ? uuid.substring(0, 8) : uuid;
|
||||
}
|
||||
|
||||
}
|
||||
+208
@@ -0,0 +1,208 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin vote log menu GUI handler.
|
||||
*/
|
||||
public class AdminVoteLogMenu extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days; // window used by selectors/stats (0 = all time)
|
||||
|
||||
// Default to "voting" (Vote received)
|
||||
private final VoteLogMysqlTable.VoteLogEvent defaultEvent = VoteLogMysqlTable.VoteLogEvent.VOTE_RECEIVED;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogMenu.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogMenu(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, int days) {
|
||||
this(plugin, sender, table, null, days);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogMenu with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogMenu(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
this.days = Math.max(0, days);
|
||||
}
|
||||
|
||||
@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 {
|
||||
String title = "&aVoteLog - Admin";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.NAME_TAG).setName("&aVotes by Player")
|
||||
.addLoreLine("&7List stored player names").addLoreLine("&7Click a player to view their votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayerSelect(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.NAME_TAG).setName("&aVotes by Player (Online)")
|
||||
.addLoreLine("&7List online players").addLoreLine("&7Click a player to view their votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayerSelectOnline(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&aVotes by Service")
|
||||
.addLoreLine("&7List all services found").addLoreLine("&7Click a service to view votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogServiceSelect(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
// NEW: Votes by Server
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&aVotes by Server")
|
||||
.addLoreLine("&7List all servers found").addLoreLine("&7Click a server to view votelog")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogServerSelect(plugin, clickEvent.getPlayer(), table, user, days, 0).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.MAP).setName("&aStats")
|
||||
.addLoreLine("&7Overview counts/uniques/top services")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogStats(plugin, clickEvent.getPlayer(), table, user, days, 10).open();
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.CLOCK).setName("&aRecent Logs")
|
||||
.addLoreLine("&7Recent logs filtered by event").addLoreLine("&7Default: &f" + defaultEvent.name())
|
||||
.addLoreLine("&8(Use bottom buttons to switch event)")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// Open recent with default event filter
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, defaultEvent).open();
|
||||
}
|
||||
});
|
||||
|
||||
addEventSwitchButtons(inv);
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void addEventSwitchButtons(BInventory inv) {
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.LIME_DYE)
|
||||
.setName("&aEvent: &fVOTE_RECEIVED").addLoreLine("&7Show recent vote received events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days,
|
||||
VoteLogMysqlTable.VoteLogEvent.VOTE_RECEIVED).open();
|
||||
}
|
||||
}.setSlot(3));
|
||||
|
||||
// More... (open selector)
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Material.BOOK).setName("&aEvent: &fMore...").addLoreLine("&7Pick any event filter")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogEventSelect(plugin, clickEvent.getPlayer(), table, user, days).open();
|
||||
}
|
||||
}.setSlot(4));
|
||||
|
||||
// All events
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.GRAY_DYE).setName("&aEvent: &fALL")
|
||||
.addLoreLine("&7Show recent logs for all events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, null).open();
|
||||
}
|
||||
}.setSlot(5));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given player (paged).
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*
|
||||
* Supports input as player name OR uuid string (you decide in CommandLoader
|
||||
* which constructor to call).
|
||||
*/
|
||||
public class AdminVoteLogPlayer extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private final int page;
|
||||
|
||||
private final String playerName;
|
||||
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogPlayer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param playerName the player name or UUID
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogPlayer(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String playerName,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.playerName = playerName;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@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 {
|
||||
String title = "&aVoteLog - Player";
|
||||
if (playerName != null && !playerName.isEmpty()) {
|
||||
title += " &7(" + playerName + ")";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByPlayerName(playerName, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
Material mat = "CACHED".equalsIgnoreCase(entry.status) ? Material.CHEST : Material.EMERALD;
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
// keep same name/lore layout you already have
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName("&a" + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// vote_id is now the correlation id entry.voteId
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select an ONLINE player, then open AdminVoteLogPlayer.
|
||||
*/
|
||||
public class AdminVoteLogPlayerSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogPlayerSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogPlayerSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Players";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> online = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(online.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= online.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo players")
|
||||
.addLoreLine("&7No online players on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
Player p = online.get(i);
|
||||
inv.addButton(makePlayerButton(p));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makePlayerButton(final Player target) {
|
||||
String name = target.getName();
|
||||
|
||||
ItemBuilder item = new ItemBuilder(Material.NAME_TAG).setName("&a" + name)
|
||||
.addLoreLine("&7Click to open votelog for this player")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayer(plugin, clickEvent.getPlayer(), table, name, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select an ONLINE player, then open AdminVoteLogPlayer.
|
||||
*/
|
||||
public class AdminVoteLogPlayerSelectOnline extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogPlayerSelectOnline.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogPlayerSelectOnline(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@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 {
|
||||
String title = "&aVoteLog - Players";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Player> online = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(online.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= online.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo players")
|
||||
.addLoreLine("&7No online players on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
Player p = online.get(i);
|
||||
inv.addButton(makePlayerButton(p));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makePlayerButton(Player target) {
|
||||
String name = target.getName();
|
||||
|
||||
ItemBuilder item = new ItemBuilder(Material.NAME_TAG).setName("&a" + name)
|
||||
.addLoreLine("&7Click to open votelog for this player")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogPlayer(plugin, clickEvent.getPlayer(), table, name, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Recent VoteLog entries (paged).
|
||||
*
|
||||
* Now supports optional event filter + days window.
|
||||
*/
|
||||
public class AdminVoteLogRecent extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int page;
|
||||
|
||||
private final int days; // 0 = all time
|
||||
private final VoteLogMysqlTable.VoteLogEvent event; // null = all events
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogRecent.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogRecent(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, int page) {
|
||||
this(plugin, sender, table, null, page, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogRecent with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogRecent(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int page) {
|
||||
this(plugin, sender, table, user, page, 0, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogRecent with full parameters.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param page the page number
|
||||
* @param days the number of days to filter
|
||||
* @param event the event type to filter
|
||||
*/
|
||||
// NEW constructor used by Menu/EventSelect
|
||||
public AdminVoteLogRecent(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int page, int days, VoteLogMysqlTable.VoteLogEvent event) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
this.page = Math.max(0, page);
|
||||
this.days = Math.max(0, days);
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Recent";
|
||||
if (event != null) {
|
||||
title += " &7(" + event.name() + ")";
|
||||
}
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows;
|
||||
if (event == null) {
|
||||
rows = (days > 0) ? table.getRecentAll(days, needed) : table.getRecent(needed);
|
||||
} else {
|
||||
rows = table.getRecentByEvent(event, days, needed);
|
||||
}
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
addEventSwitchButtons(inv);
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void addEventSwitchButtons(BInventory inv) {
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.LIME_DYE)
|
||||
.setName("&aEvent: &fVOTE_RECEIVED").addLoreLine("&7Show recent vote received events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days,
|
||||
VoteLogMysqlTable.VoteLogEvent.VOTE_RECEIVED).open();
|
||||
}
|
||||
}.setSlot(3));
|
||||
|
||||
// More... (open selector)
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Material.BOOK).setName("&aEvent: &fMore...").addLoreLine("&7Pick any event filter")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogEventSelect(plugin, clickEvent.getPlayer(), table, user, days).open();
|
||||
}
|
||||
}.setSlot(4));
|
||||
|
||||
// All events
|
||||
inv.getPageButtons().add(new BInventoryButton(new ItemBuilder(Material.GRAY_DYE).setName("&aEvent: &fALL")
|
||||
.addLoreLine("&7Show recent logs for all events")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogRecent(plugin, clickEvent.getPlayer(), table, user, 0, days, null).open();
|
||||
}
|
||||
}.setSlot(5));
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given server (paged).
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*/
|
||||
public class AdminVoteLogServer extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
private final int page;
|
||||
|
||||
private final String server;
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServer.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param server the server name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServer(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String server,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.server = server;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServer with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param server the server name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServer(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, String server, int days, int page) {
|
||||
this(plugin, sender, table, server, days, page);
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
BInventory inv = new BInventory("&aVoteLog - Server &7(" + AdminVoteLogHelpers.safe(server) + ")");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByServer(server, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.server)) {
|
||||
item.addLoreLine("&7Server: &f" + AdminVoteLogHelpers.safe(entry.server));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// vote_id is the correlation id
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select a server (distinct list), then open AdminVoteLogServer.
|
||||
*/
|
||||
public class AdminVoteLogServerSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServerSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServerSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Servers";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<String> servers = table.getDistinctServers(days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(servers.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= servers.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo servers")
|
||||
.addLoreLine("&7No servers on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
String srv = servers.get(i);
|
||||
inv.addButton(makeServerButton(srv));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeServerButton(final String server) {
|
||||
ItemBuilder item = new ItemBuilder(Material.PAPER).setName("&a" + AdminVoteLogHelpers.safe(server))
|
||||
.addLoreLine("&7Click to open votelog for this server")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogServer(plugin, clickEvent.getPlayer(), table, server, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+204
@@ -0,0 +1,204 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given service/site (paged).
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*/
|
||||
public class AdminVoteLogService extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
private final int page;
|
||||
|
||||
private final String service;
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogService.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param service the service name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogService(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String service,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.service = service;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogService with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param service the service name
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogService(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, String service, int days, int page) {
|
||||
this(plugin, sender, table, service, days, page);
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
BInventory inv = new BInventory("&aVoteLog - Service &7(" + AdminVoteLogHelpers.safe(service) + ")");
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByService(service, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(final VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = AdminVoteLogHelpers.formatTime(entry.voteTime);
|
||||
String uuidShort = AdminVoteLogHelpers.shortUuid(entry.playerUuid);
|
||||
String voteShort = AdminVoteLogHelpers.shortUuid(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.playerName) || AdminVoteLogHelpers.notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + AdminVoteLogHelpers.safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + AdminVoteLogHelpers.safe(entry.service));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + AdminVoteLogHelpers.safe(entry.context));
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + AdminVoteLogHelpers.safe(entry.status));
|
||||
}
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
if (AdminVoteLogHelpers.notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + AdminVoteLogHelpers.safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// vote_id is the correlation id
|
||||
new AdminVoteLogVoteId(plugin, clickEvent.getPlayer(), table, entry.voteId, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select a service (distinct list), then open AdminVoteLogService.
|
||||
*/
|
||||
public class AdminVoteLogServiceSelect extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServiceSelect.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServiceSelect(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = Math.max(0, days);
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Services";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<String> services = table.getDistinctServices(days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(services.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= services.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo services")
|
||||
.addLoreLine("&7No services on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
String svc = services.get(i);
|
||||
inv.addButton(makeServiceButton(svc));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeServiceButton(final String service) {
|
||||
ItemBuilder item = new ItemBuilder(Material.PAPER).setName("&a" + AdminVoteLogHelpers.safe(service))
|
||||
.addLoreLine("&7Click to open votelog for this service")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogService(plugin, clickEvent.getPlayer(), table, service, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: Select a service from DB (distinct services), then open
|
||||
* AdminVoteLogService.
|
||||
*/
|
||||
public class AdminVoteLogServiceSelectAll extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
private final int page;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogServiceSelectAll.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogServiceSelectAll(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Services";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
List<String> services = table.getDistinctServices(days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(services.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= services.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo services")
|
||||
.addLoreLine("&7No services on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
String svc = services.get(i);
|
||||
inv.addButton(makeServiceButton(svc));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeServiceButton(String service) {
|
||||
ItemBuilder item = new ItemBuilder(Material.PAPER).setName("&a" + AdminVoteLogHelpers.safe(service))
|
||||
.addLoreLine("&7Click to open votelog for this service")
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time");
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new AdminVoteLogService(plugin, clickEvent.getPlayer(), table, service, days, 0).open();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog stats overview.
|
||||
*
|
||||
* Uses VoteLogMysqlTable instance passed in from CommandLoader.
|
||||
*
|
||||
* Shows: - total / immediate / cached counts (VoteLogCounts) - unique voters -
|
||||
* top services - top servers
|
||||
*/
|
||||
public class AdminVoteLogStats extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
|
||||
private final int days;
|
||||
|
||||
private final int topServicesLimit;
|
||||
private final int topServersLimit;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogStats.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param days the number of days to filter
|
||||
*/
|
||||
public AdminVoteLogStats(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, int days) {
|
||||
this(plugin, sender, table, null, days, 10, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogStats with user and top services limit.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param topServicesLimit the maximum number of top services to display
|
||||
*/
|
||||
public AdminVoteLogStats(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int topServicesLimit) {
|
||||
this(plugin, sender, table, user, days, topServicesLimit, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogStats with full parameters.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param days the number of days to filter
|
||||
* @param topServicesLimit the maximum number of top services to display
|
||||
* @param topServersLimit the maximum number of top servers to display
|
||||
*/
|
||||
public AdminVoteLogStats(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, int days, int topServicesLimit, int topServersLimit) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
this.days = Math.max(0, days);
|
||||
this.topServicesLimit = topServicesLimit <= 0 ? 10 : topServicesLimit;
|
||||
this.topServersLimit = topServersLimit <= 0 ? 10 : topServersLimit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - Stats";
|
||||
if (days > 0) {
|
||||
title += " &7(" + days + "d)";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
// counts
|
||||
VoteLogMysqlTable.VoteLogCounts counts = table.getCounts(days);
|
||||
long uniques = table.getUniqueVoters(days);
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BOOK).setName("&aOverview")
|
||||
.addLoreLine("&7Total Votes: &f" + counts.total).addLoreLine("&7Immediate: &f" + counts.immediate)
|
||||
.addLoreLine("&7Cached: &f" + counts.cached).addLoreLine("&7Unique Voters: &f" + uniques)
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
// top services header
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.MAP).setName("&aTop Services")
|
||||
.addLoreLine("&7Top " + topServicesLimit + " services/sites:")
|
||||
.addLoreLine("&8(Click does nothing)")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
int shownServices = 0;
|
||||
for (VoteLogMysqlTable.ServiceCount sc : table.getTopServices(days, topServicesLimit)) {
|
||||
shownServices++;
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER)
|
||||
.setName("&a#" + shownServices + " &f" + AdminVoteLogHelpers.safe(sc.service))
|
||||
.addLoreLine("&7Votes: &f" + sc.votes)
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op (could open AdminVoteLogService in future)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (shownServices == 0) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo service data")
|
||||
.addLoreLine("&7No services found in the log.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// top servers header
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&aTop Servers")
|
||||
.addLoreLine("&7Top " + topServersLimit + " servers:").addLoreLine("&8(Click does nothing)")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
int shownServers = 0;
|
||||
for (VoteLogMysqlTable.ServerCount sc : table.getTopServers(days, topServersLimit)) {
|
||||
shownServers++;
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER)
|
||||
.setName("&a#" + shownServers + " &f" + AdminVoteLogHelpers.safe(sc.server))
|
||||
.addLoreLine("&7Votes: &f" + sc.votes)
|
||||
.addLoreLine(days > 0 ? "&7Window: &fLast " + days + " days" : "&7Window: &fAll time")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op (could open AdminVoteLogServer in future)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (shownServers == 0) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo server data")
|
||||
.addLoreLine("&7No servers found in the log.")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+257
@@ -0,0 +1,257 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin.votelog;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votelog.VoteLogMysqlTable;
|
||||
|
||||
/**
|
||||
* Admin GUI: VoteLog entries for a given voteId (paged).
|
||||
*
|
||||
* vote_id is NOT unique; this shows ALL rows for the correlation id.
|
||||
*/
|
||||
public class AdminVoteLogVoteId extends GUIHandler {
|
||||
|
||||
private final VotingPluginMain plugin;
|
||||
private final VoteLogMysqlTable table;
|
||||
private VotingPluginUser user;
|
||||
private final int page;
|
||||
|
||||
private final String voteId;
|
||||
private final int days;
|
||||
|
||||
private static final int PAGE_SIZE = 45;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogVoteId.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param voteId the vote ID to filter
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogVoteId(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table, String voteId,
|
||||
int days, int page) {
|
||||
super(plugin, sender);
|
||||
this.plugin = plugin;
|
||||
this.table = table;
|
||||
this.voteId = voteId;
|
||||
this.days = days;
|
||||
this.page = Math.max(0, page);
|
||||
|
||||
if (sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteLogVoteId with user.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param sender the command sender
|
||||
* @param table the vote log table
|
||||
* @param user the voting plugin user
|
||||
* @param voteId the vote ID to filter
|
||||
* @param days the number of days to filter
|
||||
* @param page the page number
|
||||
*/
|
||||
public AdminVoteLogVoteId(VotingPluginMain plugin, CommandSender sender, VoteLogMysqlTable table,
|
||||
VotingPluginUser user, String voteId, int days, int page) {
|
||||
this(plugin, sender, table, voteId, days, page);
|
||||
this.user = user;
|
||||
if (this.user == null && sender instanceof Player) {
|
||||
this.user = plugin.getVotingPluginUserManager().getVotingPluginUser((Player) sender);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
String title = "&aVoteLog - VoteId";
|
||||
if (voteId != null && !voteId.isEmpty()) {
|
||||
title += " &7(" + shortId(voteId) + ")";
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(title);
|
||||
inv.requirePermission("VotingPlugin.Commands.AdminVote.VoteLog");
|
||||
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
if (table == null) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cVoteLog unavailable")
|
||||
.addLoreLine("&7VoteLog MySQL table is not loaded/enabled.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (voteId == null || voteId.isEmpty()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo voteId provided")
|
||||
.addLoreLine("&7Missing voteId.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
return;
|
||||
}
|
||||
|
||||
int needed = (page + 1) * PAGE_SIZE;
|
||||
|
||||
// vote_id is not unique -> show ALL rows for it (paged)
|
||||
List<VoteLogMysqlTable.VoteLogEntry> rows = table.getByVoteIdAll(voteId, days, needed);
|
||||
|
||||
int start = page * PAGE_SIZE;
|
||||
int end = Math.min(rows.size(), start + PAGE_SIZE);
|
||||
|
||||
if (start >= rows.size()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.PAPER).setName("&eNo entries")
|
||||
.addLoreLine("&7No vote log entries on this page.").addLoreLine("&7Try going back a page.")) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// no-op
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (int i = start; i < end; i++) {
|
||||
inv.addButton(makeEntryButton(rows.get(i)));
|
||||
}
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(54);
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private BInventoryButton makeEntryButton(VoteLogMysqlTable.VoteLogEntry entry) {
|
||||
VoteLogMysqlTable.VoteLogEvent event = entry.event != null ? VoteLogMysqlTable.VoteLogEvent.valueOf(entry.event)
|
||||
: null;
|
||||
|
||||
Material mat = AdminVoteLogHelpers.getMaterialForEvent(event, entry.status);
|
||||
|
||||
String eventColor = AdminVoteLogHelpers.getEventColor(event);
|
||||
|
||||
String timeStr = formatTime(entry.voteTime);
|
||||
String uuidShort = shortId(entry.playerUuid);
|
||||
String voteShort = shortId(entry.voteId);
|
||||
|
||||
ItemBuilder item = new ItemBuilder(mat)
|
||||
.setName(eventColor + AdminVoteLogHelpers.safe(entry.event) + " &7(" + voteShort + ")");
|
||||
|
||||
// Only add lore lines when the value is actually set / meaningful
|
||||
// (prevents blank/0/default noise)
|
||||
if (notEmpty(entry.playerName) || notEmpty(entry.playerUuid)) {
|
||||
item.addLoreLine("&7Player: &f" + safe(entry.playerName) + " &7(" + uuidShort + ")");
|
||||
}
|
||||
|
||||
if (entry.voteTime > 0) {
|
||||
item.addLoreLine("&7Time: &f" + timeStr);
|
||||
}
|
||||
|
||||
if (notEmpty(entry.service)) {
|
||||
item.addLoreLine("&7Service: &f" + safe(entry.service));
|
||||
}
|
||||
|
||||
if (notEmpty(entry.context)) {
|
||||
item.addLoreLine("&7Context: &f" + safe(entry.context));
|
||||
}
|
||||
|
||||
if (notEmpty(entry.status)) {
|
||||
item.addLoreLine("&7Status: &f" + safe(entry.status));
|
||||
}
|
||||
|
||||
if (entry.proxyCachedTotal != 0) {
|
||||
item.addLoreLine("&7Cached Total: &f" + entry.proxyCachedTotal);
|
||||
}
|
||||
|
||||
if (notEmpty(entry.voteId)) {
|
||||
item.addLoreLine("&7VoteId: &f" + safe(entry.voteId));
|
||||
}
|
||||
|
||||
return new BInventoryButton(item) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// read-only
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private String formatTime(long millis) {
|
||||
try {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.format(new Date(millis));
|
||||
} catch (Exception e) {
|
||||
return String.valueOf(millis);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean notEmpty(String s) {
|
||||
return s != null && !s.trim().isEmpty();
|
||||
}
|
||||
|
||||
private String shortId(String s) {
|
||||
if (s == null || s.isEmpty()) {
|
||||
return "unknown";
|
||||
}
|
||||
return s.length() > 8 ? s.substring(0, 8) : s;
|
||||
}
|
||||
|
||||
private String safe(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+25
-10
@@ -12,14 +12,23 @@ 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.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
import com.bencodez.simpleapi.valuerequest.StringListener;
|
||||
import com.bencodez.simpleapi.valuerequest.ValueRequest;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote shop GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShop extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShop.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteShop(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -30,6 +39,11 @@ public class AdminVoteVoteShop extends GUIHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
@@ -55,14 +69,15 @@ public class AdminVoteVoteShop extends GUIHandler {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
new ValueRequest(plugin, plugin.getDialogService(), null).requestString(player, "", null, true,
|
||||
"Enter item name", new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
plugin.getGui().createShop(value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
plugin.getShopFile().createShop(value);
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -81,4 +96,4 @@ public class AdminVoteVoteShop extends GUIHandler {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+23
-8
@@ -22,17 +22,32 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.command.gui.RewardEditGUI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote shop item GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShopItem extends GUIHandler {
|
||||
|
||||
private String identifier;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShopItem.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
* @param identifier the item identifier
|
||||
*/
|
||||
public AdminVoteVoteShopItem(VotingPluginMain plugin, CommandSender player, String identifier) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
@@ -53,7 +68,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 +76,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 +84,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 +92,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 +101,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 +156,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 +171,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();
|
||||
}
|
||||
|
||||
+17
-4
@@ -14,15 +14,29 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.commands.gui.admin.AdminVoteConfirmation;
|
||||
|
||||
/**
|
||||
* Admin vote shop item remove GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShopItemRemove.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteShopItemRemove(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
@@ -42,9 +56,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 +68,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 +79,6 @@ public class AdminVoteVoteShopItemRemove extends GUIHandler {
|
||||
}
|
||||
}.open();
|
||||
|
||||
|
||||
}
|
||||
}.addData("ident", identifier));
|
||||
}
|
||||
+16
-2
@@ -13,15 +13,29 @@ import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* Admin vote shop items GUI handler.
|
||||
*/
|
||||
public class AdminVoteVoteShopItems extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AdminVoteVoteShopItems.
|
||||
*
|
||||
* @param plugin the VotingPluginMain instance
|
||||
* @param player the command sender
|
||||
*/
|
||||
public AdminVoteVoteShopItems(VotingPluginMain plugin, CommandSender player) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
@@ -41,9 +55,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) {
|
||||
+47
-2
@@ -18,11 +18,21 @@ import com.bencodez.simpleapi.array.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* GUI handler for vote best/streak display.
|
||||
*/
|
||||
public class VoteBest extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new vote best GUI.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteBest(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -31,11 +41,11 @@ 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());
|
||||
@@ -47,6 +57,41 @@ public class VoteBest extends GUIHandler {
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("HighestDailyTotal", "" + user.getHighestDailyTotal())
|
||||
.placeholder("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal())
|
||||
.placeholder("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal())
|
||||
.title(plugin.getGui().getChestVoteBestName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteBestTitle())
|
||||
.columns(2)
|
||||
.button(plugin.getGui().getChestVoteBestDayBestItem().getName(),
|
||||
"&7Best daily total: &e%HighestDailyTotal%",
|
||||
payload -> {
|
||||
})
|
||||
.button(plugin.getGui().getChestVoteBestWeekBestItem().getName(),
|
||||
"&7Best weekly total: &e%HighestWeeklyTotal%",
|
||||
payload -> {
|
||||
})
|
||||
.button(plugin.getGui().getChestVoteBestMonthBestItem().getName(),
|
||||
"&7Best monthly total: &e%HighestMonthlyTotal%",
|
||||
payload -> {
|
||||
})
|
||||
.button(plugin.getGui().isChestVoteBestBackButton() ? "&eBack" : "",
|
||||
plugin.getGui().isChestVoteBestBackButton() ? "&7Return to previous menu" : "",
|
||||
payload -> {
|
||||
if (plugin.getGui().isChestVoteBestBackButton()) {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
}
|
||||
})
|
||||
.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
+66
-2
@@ -19,11 +19,21 @@ import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
/**
|
||||
* GUI handler for vote interface.
|
||||
*/
|
||||
public class VoteGUI extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new vote GUI.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteGUI(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -35,6 +45,58 @@ public class VoteGUI extends GUIHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
if (this.user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("points", "" + user.getPoints()).placeholder("player", user.getPlayerName())
|
||||
.placeholder("top", plugin.getConfigFile().getVoteTopDefault())
|
||||
.placeholder("sitesavailable", "" + user.getSitesNotVotedOn())
|
||||
.title(plugin.getGui().getChestVoteGUIName()).body("&7Select an option").columns(2);
|
||||
|
||||
for (final String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
ItemBuilder builder = getItemSlot(slot, player);
|
||||
|
||||
String buttonText = builder.getName();
|
||||
String tooltip = "";
|
||||
|
||||
if (builder.getLore() != null && !builder.getLore().isEmpty()) {
|
||||
tooltip = builder.getLore().get(0);
|
||||
}
|
||||
|
||||
dialog.button(buttonText, tooltip, payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
|
||||
|
||||
if (cmd.equalsIgnoreCase("none")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cmd.equals("")) {
|
||||
clicked.performCommand(cmd);
|
||||
} else {
|
||||
plugin.getCommandLoader().processSlotClick(clicked, user, slot);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item for a specific GUI slot.
|
||||
*
|
||||
* @param slot the slot name
|
||||
* @param player the player
|
||||
* @return the item builder for the slot
|
||||
*/
|
||||
private ItemBuilder getItemSlot(String slot, Player player) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteGUISlotSection(slot));
|
||||
|
||||
@@ -64,7 +126,7 @@ 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]);
|
||||
@@ -151,7 +213,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
|
||||
@@ -206,6 +269,7 @@ public class VoteGUI extends GUIHandler {
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
+42
-14
@@ -11,17 +11,26 @@ import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.simpleapi.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* GUI handler for vote help display.
|
||||
*/
|
||||
public class VoteHelp extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Constructs a new vote help GUI.
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
* @param player the command sender
|
||||
* @param page the page number
|
||||
*/
|
||||
public VoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -33,9 +42,20 @@ public class VoteHelp extends GUIHandler {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates help text with hover support.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return list of text components for help
|
||||
*/
|
||||
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 +74,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) {
|
||||
@@ -64,9 +84,15 @@ public class VoteHelp extends GUIHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates legacy help text without hover support.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return list of text components for help
|
||||
*/
|
||||
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 +102,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) {
|
||||
@@ -106,15 +132,17 @@ public class VoteHelp extends GUIHandler {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates vote help text with pagination.
|
||||
*
|
||||
* @param sender the command sender
|
||||
* @return list of text components for help
|
||||
*/
|
||||
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> text = new ArrayList<TextComponent>();
|
||||
if (NMSManager.getInstance().isVersion("1.12")) {
|
||||
text = helpTextLegacy(sender);
|
||||
} else {
|
||||
text = helpText(sender);
|
||||
}
|
||||
ArrayList<TextComponent> msg = new ArrayList<>();
|
||||
ArrayList<TextComponent> text = new ArrayList<>();
|
||||
text = helpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
if ((text.size() % pagesize) != 0) {
|
||||
+62
-7
@@ -1,6 +1,7 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -17,14 +18,24 @@ 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;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
/**
|
||||
* GUI handler for displaying last vote information.
|
||||
*/
|
||||
public class VoteLast extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new VoteLast GUI handler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteLast(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -33,14 +44,14 @@ 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(MessageAPI.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(), "%player%",
|
||||
playerName));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
msg.add(user.voteCommandLastLine(voteSite));
|
||||
}
|
||||
@@ -49,6 +60,50 @@ public class VoteLast extends GUIHandler {
|
||||
return ArrayUtils.colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName()).title(plugin.getGui().getChestVoteLastName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteLastTitle()).columns(2);
|
||||
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (site.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
dialog.placeholder("sitename", site.getDisplayName()).button(site.getDisplayName(),
|
||||
user.voteCommandLastLine(site), payload -> {
|
||||
|
||||
if (plugin.getGui().isChestVoteLastClickableLinks()) {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
|
||||
if (clicked != null) {
|
||||
VotingPluginUser clickedUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(clicked);
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("voteurl", site.getVoteURL());
|
||||
placeholders.put("sitename", site.getDisplayName());
|
||||
placeholders.put("player", clicked.getName());
|
||||
|
||||
clickedUser.sendMessage(plugin.getGui().getChestVoteURLURLText(), placeholders);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteLastBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
@@ -63,7 +118,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.getVoteSitesEnabled()) {
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!site.isHidden()) {
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new UpdatingBInventoryButton(plugin, site.getItem().setName(site.getDisplayName())
|
||||
@@ -80,10 +135,10 @@ public class VoteLast extends GUIHandler {
|
||||
PlaceholderUtils
|
||||
.replacePlaceHolder(
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getGui()
|
||||
PlaceholderUtils.replacePlaceHolder(
|
||||
plugin.getGui()
|
||||
.getChestVoteURLURLText(),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"voteurl", site.getVoteURL()),
|
||||
"sitename", site.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
+64
-10
@@ -19,16 +19,26 @@ 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;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
/**
|
||||
* GUI handler for displaying next vote information.
|
||||
*/
|
||||
public class VoteNext extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Constructs a new VoteNext GUI handler.
|
||||
*
|
||||
* @param plugin the main plugin instance
|
||||
* @param player the command sender
|
||||
* @param user the voting plugin user
|
||||
*/
|
||||
public VoteNext(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
@@ -37,14 +47,14 @@ 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(MessageAPI.colorize(MessageAPI
|
||||
.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteNextTitle(), "%player%", playerName)));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSitesEnabled()) {
|
||||
for (VoteSite voteSite : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (!voteSite.isHidden()) {
|
||||
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
|
||||
|
||||
@@ -57,14 +67,55 @@ public class VoteNext extends GUIHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName()).title(plugin.getGui().getChestVoteNextName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteNextTitle()).columns(2);
|
||||
|
||||
for (VoteSite site : plugin.getVoteSiteManager().getVoteSitesEnabled()) {
|
||||
if (site.isHidden()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String siteNameDisplay = plugin.getGui().getChestVoteNextCustomSiteNamesDisplays(site.getKey());
|
||||
|
||||
if (siteNameDisplay.isEmpty()) {
|
||||
siteNameDisplay = site.getDisplayName();
|
||||
}
|
||||
|
||||
dialog.placeholder("sitename", site.getDisplayName()).placeholder("SiteName", site.getDisplayName())
|
||||
.placeholder("info", user.voteCommandNextInfo(site))
|
||||
.button(siteNameDisplay, user.voteCommandNextInfo(site), payload -> {
|
||||
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
|
||||
if (clicked != null) {
|
||||
clicked.sendMessage(user.voteCommandNextInfo(site));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteNextBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSitesEnabled()) {
|
||||
for (VoteSite site : plugin.getVoteSiteManager().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()))
|
||||
@@ -86,17 +137,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.getVoteSitesEnabled()) {
|
||||
for (VoteSite site : plugin.getVoteSiteManager().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(PlaceholderUtils.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) {
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.voteshop.VoteShopManager;
|
||||
import com.bencodez.votingplugin.voteshop.service.VoteShopPurchaseResult;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategory;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategoryButton;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopDefinition;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopEntry;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopExtraItem;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopItem;
|
||||
|
||||
/**
|
||||
* Main vote shop GUI.
|
||||
*/
|
||||
public class VoteShop extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Creates the GUI.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param player the sender
|
||||
* @param user the user
|
||||
*/
|
||||
public VoteShop(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
VoteShopManager manager = plugin.getVoteShopManager();
|
||||
VoteShopDefinition definition = manager.getDefinition();
|
||||
|
||||
if (!definition.isEnabled()) {
|
||||
player.sendMessage(MessageAPI.colorize(definition.getDisabledMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser currentUser = getUser(player);
|
||||
BInventory inv = new BInventory(definition.getTitle());
|
||||
inv.addPlaceholder("points", String.valueOf(currentUser.getPoints()));
|
||||
inv.addPlaceholder("sitesavailable", String.valueOf(currentUser.getSitesNotVotedOn()));
|
||||
inv.dontClose();
|
||||
|
||||
for (VoteShopEntry entry : definition.getMainEntries().values()) {
|
||||
if (entry instanceof VoteShopItem) {
|
||||
addItemButton(inv, player, currentUser, (VoteShopItem) entry, null);
|
||||
} else if (entry instanceof VoteShopCategoryButton) {
|
||||
addCategoryButton(inv, player, currentUser, (VoteShopCategoryButton) entry);
|
||||
}
|
||||
}
|
||||
|
||||
for (VoteShopExtraItem extraItem : definition.getExtraItems().values()) {
|
||||
addExtraItemButton(inv, player, currentUser, extraItem);
|
||||
}
|
||||
|
||||
if (definition.isBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(currentUser));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param item the item
|
||||
* @param category the category, null for main shop
|
||||
*/
|
||||
protected void addItemButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopItem item, final VoteShopCategory category) {
|
||||
VoteShopPurchaseResult validation = plugin.getVoteShopManager().getPurchaseService().validatePurchase(player,
|
||||
currentUser, item);
|
||||
boolean hasPermission = plugin.getVoteShopManager().getPurchaseService().hasPermission(player,
|
||||
item.getPermission());
|
||||
|
||||
if ((!hasPermission && item.isHideOnNoPermission()) || (validation == VoteShopPurchaseResult.LIMIT_REACHED
|
||||
&& plugin.getVoteShopManager().getDefinition().isHideLimitedReached())) {
|
||||
return;
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(item.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
VotingPluginUser clickedUser = getUser(event.getPlayer());
|
||||
if (plugin.getConfigFile().isExtraVoteShopCheck()) {
|
||||
clickedUser.cache();
|
||||
}
|
||||
|
||||
if (item.isNotBuyable()) {
|
||||
clickedUser.sendMessage(plugin.getConfigFile().getFormatShopNotPurchasable());
|
||||
return;
|
||||
}
|
||||
|
||||
VoteShopPurchaseResult clickValidation = plugin.getVoteShopManager().getPurchaseService()
|
||||
.validatePurchase(event.getPlayer(), clickedUser, item);
|
||||
if (clickValidation != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(event.getPlayer(), clickedUser,
|
||||
item, clickValidation);
|
||||
return;
|
||||
}
|
||||
|
||||
if (item.isRequireConfirmation()) {
|
||||
if (plugin.getShopFile().isShopConfirmPurchaseUseDialog()) {
|
||||
new VoteShopConfirm(plugin, event.getPlayer(), clickedUser, item, category)
|
||||
.open(GUIMethod.DIALOG);
|
||||
return;
|
||||
} else {
|
||||
new VoteShopConfirm(plugin, event.getPlayer(), clickedUser, item, category)
|
||||
.open(GUIMethod.CHEST);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
handlePurchase(event.getPlayer(), clickedUser, item, category);
|
||||
}
|
||||
}.addData("identifier", item.getIdentifier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a category button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param button the button
|
||||
*/
|
||||
protected void addCategoryButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopCategoryButton button) {
|
||||
boolean hasPermission = plugin.getVoteShopManager().getPurchaseService().hasPermission(player,
|
||||
button.getPermission());
|
||||
if (!hasPermission && button.isHideOnNoPermission()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final VoteShopCategory category = plugin.getVoteShopManager().getCategory(button.getCategoryId());
|
||||
if (category == null) {
|
||||
plugin.extraDebug(
|
||||
"VoteShop: missing category '" + button.getCategoryId() + "' for entry " + button.getIdentifier());
|
||||
return;
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(button.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new VoteShopCategoryMenu(plugin, event.getPlayer(), currentUser, category).open(GUIMethod.CHEST);
|
||||
}
|
||||
}.addData("identifier", button.getIdentifier()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an extra item button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param extraItem the extra item
|
||||
*/
|
||||
protected void addExtraItemButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopExtraItem extraItem) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(extraItem.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
plugin.getCommandLoader().processSlotClick(player, currentUser, extraItem.getIdentifier());
|
||||
new RewardBuilder(plugin.getShopFile().getData(),
|
||||
"ExtraItems." + extraItem.getIdentifier() + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles a completed purchase.
|
||||
*
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param item the item
|
||||
* @param category the category or null
|
||||
*/
|
||||
protected void handlePurchase(Player player, VotingPluginUser currentUser, VoteShopItem item,
|
||||
VoteShopCategory category) {
|
||||
VoteShopPurchaseResult result = plugin.getVoteShopManager().purchase(player, currentUser, item);
|
||||
if (result != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(player, currentUser, item, result);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCommandLoader().processSlotClick(player, currentUser, item.getIdentifier());
|
||||
if (plugin.getVoteShopManager().getDefinition().isReopenGuiOnPurchase()) {
|
||||
if (category != null) {
|
||||
new VoteShopCategoryMenu(plugin, player, currentUser, category).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
plugin.getCommandLoader().processSlotClick(player, currentUser, "shop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current user.
|
||||
*
|
||||
* @param player the player
|
||||
* @return the user
|
||||
*/
|
||||
protected VotingPluginUser getUser(Player player) {
|
||||
if (user == null) {
|
||||
user = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
return plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
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.simpleapi.messages.MessageAPI;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategory;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategoryButton;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopEntry;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopItem;
|
||||
|
||||
/**
|
||||
* Vote shop category GUI.
|
||||
*/
|
||||
public class VoteShopCategoryMenu extends GUIHandler {
|
||||
|
||||
private VoteShopCategory category;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Creates the GUI.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param player the sender
|
||||
* @param user the user
|
||||
* @param category the category
|
||||
*/
|
||||
public VoteShopCategoryMenu(VotingPluginMain plugin, CommandSender player, VotingPluginUser user,
|
||||
VoteShopCategory category) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (!plugin.getVoteShopManager().getDefinition().isEnabled()) {
|
||||
player.sendMessage(MessageAPI.colorize(plugin.getVoteShopManager().getDefinition().getDisabledMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
VotingPluginUser currentUser = plugin.getVotingPluginUserManager().getVotingPluginUser(player);
|
||||
BInventory inv = new BInventory(category.getName());
|
||||
inv.addPlaceholder("points", String.valueOf(currentUser.getPoints()));
|
||||
inv.addPlaceholder("sitesavailable", String.valueOf(currentUser.getSitesNotVotedOn()));
|
||||
inv.dontClose();
|
||||
|
||||
for (VoteShopEntry entry : category.getEntries().values()) {
|
||||
if (entry instanceof VoteShopItem) {
|
||||
addItemButton(inv, player, currentUser, (VoteShopItem) entry);
|
||||
} else if (entry instanceof VoteShopCategoryButton) {
|
||||
addCategoryButton(inv, player, currentUser, (VoteShopCategoryButton) entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (category.isBackButton()) {
|
||||
addBackButton(inv, player, currentUser, category.getId());
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
private void addBackButton(BInventory inv, Player player, VotingPluginUser user, String category) {
|
||||
|
||||
if (!plugin.getShopFile().isCategoryBackButtonEnabled(category)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationSection section = plugin.getShopFile().getCategoryBackButtonItem(category);
|
||||
|
||||
if (section == null) {
|
||||
section = plugin.getShopFile().getDefaultBackButtonItem();
|
||||
}
|
||||
|
||||
ItemBuilder builder;
|
||||
|
||||
if (section != null) {
|
||||
builder = new ItemBuilder(section);
|
||||
} else {
|
||||
builder = new ItemBuilder(Material.ARROW);
|
||||
builder.setName("&cBack");
|
||||
}
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new VoteShop(plugin, player, user).open();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param item the item
|
||||
*/
|
||||
protected void addItemButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopItem item) {
|
||||
new VoteShop(plugin, player, currentUser).addItemButton(inv, player, currentUser, item, category);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a category button.
|
||||
*
|
||||
* @param inv the inventory
|
||||
* @param player the player
|
||||
* @param currentUser the user
|
||||
* @param button the button
|
||||
*/
|
||||
protected void addCategoryButton(BInventory inv, final Player player, final VotingPluginUser currentUser,
|
||||
final VoteShopCategoryButton button) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(button.getDisplaySection())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
VoteShopCategory target = plugin.getVoteShopManager().getCategory(button.getCategoryId());
|
||||
if (target != null) {
|
||||
new VoteShopCategoryMenu(plugin, event.getPlayer(), currentUser, target).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
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.simpleapi.player.PlayerUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.voteshop.service.VoteShopPurchaseResult;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopCategory;
|
||||
import com.bencodez.votingplugin.voteshop.shop.VoteShopItem;
|
||||
|
||||
/**
|
||||
* Confirmation GUI for vote shop purchases.
|
||||
*/
|
||||
public class VoteShopConfirm extends GUIHandler {
|
||||
|
||||
private VoteShopCategory category;
|
||||
|
||||
private VoteShopItem item;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
private VotingPluginUser user;
|
||||
|
||||
/**
|
||||
* Creates the GUI.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
* @param player the sender
|
||||
* @param user the user
|
||||
* @param item the item
|
||||
* @param category the category or null
|
||||
*/
|
||||
public VoteShopConfirm(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, VoteShopItem item,
|
||||
VoteShopCategory category) {
|
||||
super(plugin, player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.item = item;
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@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(final Player player) {
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "ident", item.getIdentifier());
|
||||
BInventory inv = new BInventory(plugin.getShopFile().getShopConfirmPurchaseTitle());
|
||||
inv.dontClose();
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseYesItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
user.cache();
|
||||
VoteShopPurchaseResult result = plugin.getVoteShopManager().purchase(player, user, item);
|
||||
if (result != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(player, user, item, result);
|
||||
returnToPrevious(event.getPlayer());
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCommandLoader().processSlotClick(player, user, item.getIdentifier());
|
||||
if (item.isCloseGUI()) {
|
||||
event.closeInventory();
|
||||
} else {
|
||||
returnToPrevious(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseNoItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (item.isCloseGUI()) {
|
||||
event.closeInventory();
|
||||
} else {
|
||||
returnToPrevious(event.getPlayer());
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
PlayerUtils.setPlayerMeta(plugin, player, "ident", item.getIdentifier());
|
||||
|
||||
plugin.getDialogService().confirmation(player).placeholder("player", user.getPlayerName())
|
||||
.placeholder("identifier", item.getIdentifier())
|
||||
.title(plugin.getShopFile().getShopConfirmPurchaseTitle())
|
||||
.body("&7Confirm purchase of &e%identifier%&7?")
|
||||
.yesText(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseYesItem()).getName())
|
||||
.noText(new ItemBuilder(plugin.getShopFile().getShopConfirmPurchaseNoItem()).getName())
|
||||
.onYes(payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
user.cache();
|
||||
VoteShopPurchaseResult result = plugin.getVoteShopManager().purchase(clicked, user, item);
|
||||
if (result != VoteShopPurchaseResult.SUCCESS) {
|
||||
plugin.getVoteShopManager().getPurchaseService().sendFailureMessage(clicked, user, item,
|
||||
result);
|
||||
returnToPrevious(clicked);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getCommandLoader().processSlotClick(clicked, user, item.getIdentifier());
|
||||
if (!item.isCloseGUI()) {
|
||||
returnToPrevious(clicked);
|
||||
}
|
||||
}).onNo(payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
returnToPrevious(clicked);
|
||||
}
|
||||
}).open();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns to the previous GUI.
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
protected void returnToPrevious(Player player) {
|
||||
if (category != null) {
|
||||
new VoteShopCategoryMenu(plugin, player, user, category).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
+53
-2
@@ -29,14 +29,65 @@ public class VoteStreak extends GUIHandler {
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("DailyStreak", "" + user.getDayVoteStreak())
|
||||
.placeholder("WeeklyStreak", "" + user.getWeekVoteStreak())
|
||||
.placeholder("MonthlyStreak", "" + user.getMonthVoteStreak())
|
||||
.placeholder("BestDailyStreak", "" + user.getBestDayVoteStreak())
|
||||
.placeholder("BestWeeklyStreak", "" + user.getBestWeekVoteStreak())
|
||||
.placeholder("BestMonthlyStreak", "" + user.getBestMonthVoteStreak())
|
||||
.title(plugin.getGui().getChestVoteStreakName())
|
||||
.body(plugin.getConfigFile().getFormatCommandsVoteStreakTitle())
|
||||
.columns(2);
|
||||
|
||||
dialog.button(plugin.getGui().getChestVoteStreakCurrentDayStreakItem().getName(),
|
||||
"&7Current daily streak: &e%DailyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakCurrentWeekStreakItem().getName(),
|
||||
"&7Current weekly streak: &e%WeeklyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakCurrentMonthStreakItem().getName(),
|
||||
"&7Current monthly streak: &e%MonthlyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakHighestDayStreakItem().getName(),
|
||||
"&7Best daily streak: &e%BestDailyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakHighestWeekStreakItem().getName(),
|
||||
"&7Best weekly streak: &e%BestWeeklyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
dialog.button(plugin.getGui().getChestVoteStreakHighestMonthStreakItem().getName(),
|
||||
"&7Best monthly streak: &e%BestMonthlyStreak%",
|
||||
payload -> {
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteStreakBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@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());
|
||||
+90
-33
@@ -19,11 +19,10 @@ import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.PlaceholderUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardBuilder;
|
||||
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;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
import com.bencodez.votingplugin.votesites.VoteSite;
|
||||
|
||||
public class VoteToday extends GUIHandler {
|
||||
|
||||
@@ -38,13 +37,56 @@ public class VoteToday extends GUIHandler {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName()).placeholder("page", "" + page)
|
||||
.title(plugin.getGui().getChestVoteTodayName())
|
||||
.body(String.join("\n", plugin.getConfigFile().getFormatCommandsVoteTodayTitle())).columns(2);
|
||||
|
||||
for (TopVoterPlayer topPlayer : plugin.getVoteToday().keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(topPlayer).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(topPlayer).get(voteSite).format(formatter);
|
||||
|
||||
final UUID uuid = topPlayer.getUuid();
|
||||
|
||||
dialog.placeholder("player", topPlayer.getPlayerName()).placeholder("votesite", voteSite.getKey())
|
||||
.placeholder("sitename", voteSite.getDisplayName())
|
||||
.placeholder("SiteName", voteSite.getDisplayName())
|
||||
.placeholder("VoteSite", voteSite.getDisplayName()).placeholder("time", timeString)
|
||||
.placeholder("Time", timeString).button("&e" + topPlayer.getPlayerName(),
|
||||
plugin.getConfigFile().getFormatCommandsVoteTodayLine(), payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
VotingPluginUser clickedUser = plugin.getVotingPluginUserManager()
|
||||
.getVotingPluginUser(uuid);
|
||||
new VoteGUI(plugin, clicked, clickedUser).open(
|
||||
GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTodayBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
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 +94,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);
|
||||
|
||||
@@ -85,28 +127,38 @@ public class VoteToday extends GUIHandler {
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
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("player", user.getPlayerName());
|
||||
placeholders.put("votesite", voteSite.getKey());
|
||||
placeholders.put("sitename", voteSite.getDisplayName());
|
||||
placeholders.put("SiteName", voteSite.getDisplayName());
|
||||
placeholders.put("VoteSite", voteSite.getDisplayName());
|
||||
placeholders.put("time", timeString);
|
||||
placeholders.put("Time", timeString);
|
||||
msg = PlaceholderUtils.replacePlaceHolder(msg, placeholders);
|
||||
ItemBuilder item = null;
|
||||
if (plugin.getGui().isChestVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
|
||||
|
||||
ItemBuilder item;
|
||||
if (plugin.getGui().isChestVoteTodayUseSkull()) {
|
||||
item = new ItemBuilder(user.getPlayerHead());
|
||||
} else {
|
||||
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
|
||||
}
|
||||
item.setName(PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
|
||||
"player", user.getPlayerName()));
|
||||
item.setLore(msg);
|
||||
|
||||
String title = PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
|
||||
placeholders);
|
||||
String lore = PlaceholderUtils.replacePlaceHolder(plugin.getGui().getChestVoteTodayLine(),
|
||||
placeholders);
|
||||
|
||||
item.setName(title);
|
||||
item.setLore(lore);
|
||||
|
||||
final UUID uuid = user.getUuid();
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = plugin.getVotingPluginUserManager().getVotingPluginUser(uuid);
|
||||
@@ -116,42 +168,46 @@ public class VoteToday extends GUIHandler {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String guiPath = "VoteToday";
|
||||
for (final String str : plugin.getGui().getChestGUIExtraItems(guiPath)) {
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(plugin.getGui().getChestGUIExtraItemsItem(guiPath, str))) {
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "."
|
||||
+ clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new RewardBuilder(plugin.getGui().getData(),
|
||||
"CHEST." + guiPath + ".ExtraItems." + str + "." + clickEvent.getButton().getLastRewardsPath(player))
|
||||
.setGiveOffline(false).send(clickEvent.getPlayer());
|
||||
|
||||
if (plugin.getGui().isChestVoteTodayBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
});}
|
||||
|
||||
if(plugin.getGui().isChestVoteTodayBackButton()){inv.addButton(plugin.getCommandLoader().getBackButton(user));}inv.openInventory(player);}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodToday().toUpperCase()));
|
||||
}
|
||||
|
||||
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(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
|
||||
// timeString);
|
||||
}
|
||||
@@ -161,7 +217,7 @@ public class VoteToday extends GUIHandler {
|
||||
}
|
||||
|
||||
public String[] voteTodayGUI() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> msg = new ArrayList<>();
|
||||
for (TopVoterPlayer user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
LocalDateTime mostRecent = null;
|
||||
@@ -175,12 +231,13 @@ 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(PlaceholderUtils
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
msg.add(PlaceholderUtils.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(),
|
||||
placeholders));
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.colorize(msg);
|
||||
+71
-3
@@ -41,6 +41,74 @@ public class VoteTopVoter extends GUIHandler {
|
||||
this.top = top;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
|
||||
String topVoter = top.getName();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<TopVoterPlayer, Integer> topVotes = (LinkedHashMap<TopVoterPlayer, Integer>) plugin.getTopVoter(top)
|
||||
.clone();
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("topvoter", topVoter)
|
||||
.title(plugin.getGui().getChestVoteTopName())
|
||||
.body("&7Viewing &e%topvoter% &7top voters")
|
||||
.columns(2);
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : topVotes.entrySet()) {
|
||||
final TopVoterPlayer topPlayer = entry.getKey();
|
||||
final int votes = entry.getValue();
|
||||
final int position = pos;
|
||||
|
||||
dialog.placeholder("position", "" + position)
|
||||
.placeholder("player", topPlayer.getPlayerName())
|
||||
.placeholder("votes", "" + votes)
|
||||
.button(plugin.getGui().getChestVoteTopItemName(),
|
||||
plugin.getGui().getChestVoteTopItemLore(),
|
||||
payload -> {
|
||||
if (plugin.getGui().isChestVoteTopOpenMainGUIOnClick()) {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, topPlayer.getUser()).open(
|
||||
GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}
|
||||
});
|
||||
pos++;
|
||||
}
|
||||
|
||||
dialog.button("&eNext", "&7View next top voter board", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteTopVoter(plugin, clicked, user, top.next(), 0).open(GUIMethod.DIALOG);
|
||||
}
|
||||
});
|
||||
|
||||
dialog.button("&ePrevious", "&7View previous top voter board", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteTopVoter(plugin, clicked, user, top.prev(), 0).open(GUIMethod.DIALOG);
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
@@ -56,7 +124,7 @@ public class VoteTopVoter extends GUIHandler {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,7 +153,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 +177,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())
|
||||
+45
-1
@@ -28,6 +28,50 @@ public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDialog(Player player) {
|
||||
Set<Entry<TopVoterPlayer, Integer>> users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
com.bencodez.simpleapi.dialog.MultiActionDialogBuilder dialog = plugin.getDialogService().multiAction(player)
|
||||
.placeholder("player", user.getPlayerName())
|
||||
.placeholder("topvoter", "Last Month")
|
||||
.title(plugin.getGui().getChestVoteTopName())
|
||||
.body("&7Viewing &eLast Month &7top voters")
|
||||
.columns(2);
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<TopVoterPlayer, Integer> entry : users) {
|
||||
final TopVoterPlayer topPlayer = entry.getKey();
|
||||
final int votes = entry.getValue();
|
||||
final int position = pos;
|
||||
|
||||
dialog.placeholder("position", "" + position)
|
||||
.placeholder("player", topPlayer.getPlayerName())
|
||||
.placeholder("votes", "" + votes)
|
||||
.button(plugin.getGui().getChestVoteTopItemName(),
|
||||
plugin.getGui().getChestVoteTopItemLore(),
|
||||
payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, topPlayer.getUser())
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().isChestVoteTopBackButton()) {
|
||||
dialog.button("&eBack", "&7Return to previous menu", payload -> {
|
||||
Player clicked = player.getServer().getPlayer(payload.owner());
|
||||
if (clicked != null) {
|
||||
new VoteGUI(plugin, clicked, user).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dialog.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
@@ -65,7 +109,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)
|
||||
Loaded 100 of 295 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user