Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5b4d93197c | ||
|
|
d1d159ba90 | ||
|
|
8501c351dd | ||
|
|
a61d8bbd04 | ||
|
|
ccd39ebc89 | ||
|
|
da04ddad7d | ||
|
|
498210d709 | ||
|
|
c128bec2af | ||
|
|
84ce9275f0 | ||
|
|
66bdd9b5c7 | ||
|
|
b02ab916cd | ||
|
|
a2068da36b | ||
|
|
83c43331a9 | ||
|
|
afe68ef229 | ||
|
|
7eec56ee2a | ||
|
|
2ed462b61c | ||
|
|
dd142d20fe | ||
|
|
8a340dc292 | ||
|
|
e77201613e | ||
|
|
710ad17f47 | ||
|
|
a617625b87 | ||
|
|
e8a5319544 | ||
|
|
86e737892a | ||
|
|
3fd7a40421 | ||
|
|
a70e5aa54c | ||
|
|
593aae1e67 | ||
|
|
e88849854b | ||
|
|
738fd5645e | ||
|
|
22ac364f8a | ||
|
|
5d78d3a734 | ||
|
|
e83b12a248 | ||
|
|
0f50998519 | ||
|
|
1768d4490f | ||
|
|
2a3635b805 | ||
|
|
a5be973fd4 | ||
|
|
c8a76f38f9 | ||
|
|
273edaf101 | ||
|
|
d1a90676fc | ||
|
|
ff6119050d | ||
|
|
0a0b95097d | ||
|
|
ace42a5a1f | ||
|
|
1a23648b91 | ||
|
|
65b5a46525 | ||
|
|
462d99c0e5 | ||
|
|
04636dd5af | ||
|
|
d5b5b6cec0 | ||
|
|
921fdac8bb | ||
|
|
6b9bc60785 | ||
|
|
ff01c73193 | ||
|
|
a6cb4c3a8c | ||
|
|
43d33277ba | ||
|
|
9badb50075 | ||
|
|
ad6a09ba85 | ||
|
|
1791ec5e46 | ||
|
|
46457a9e61 | ||
|
|
38ab221fd8 | ||
|
|
fc2317655e | ||
|
|
fb183b9f1f | ||
|
|
64057723b6 | ||
|
|
703662c0c0 | ||
|
|
ac72b47362 | ||
|
|
6ca0e26e9c | ||
|
|
168f2fbce2 | ||
|
|
a45370011e | ||
|
|
f85c97f50a | ||
|
|
1651f8b626 | ||
|
|
ad08e4cfcf | ||
|
|
91ec3456f5 | ||
|
|
4c4f0ef6ae | ||
|
|
17a899407d | ||
|
|
1a194c684d | ||
|
|
93e06e431d | ||
|
|
8fede65b79 | ||
|
|
601d23d5cc | ||
|
|
536bacb96a | ||
|
|
07b4c36490 | ||
|
|
39a86b824e | ||
|
|
204c17affc | ||
|
|
ff92dccf47 | ||
|
|
ec69a4db70 | ||
|
|
c9e0880ce9 | ||
|
|
8b03792a52 | ||
|
|
42d9f413f5 | ||
|
|
fdb8a86def | ||
|
|
b54cda1834 | ||
|
|
824a740c96 | ||
|
|
63ed67b137 | ||
|
|
6fd008e1a8 | ||
|
|
13afac8da2 | ||
|
|
31565f20fb | ||
|
|
d4abcec817 | ||
|
|
6675f12205 | ||
|
|
66d2903ff5 | ||
|
|
fffeea6435 | ||
|
|
b9ae8b8c6f | ||
|
|
974029523e | ||
|
|
70abbcc119 | ||
|
|
927be61e93 | ||
|
|
8a3341e7b9 | ||
|
|
e3ace6cf12 | ||
|
|
b84f230179 | ||
|
|
e2fd7347b4 | ||
|
|
223ba96a95 | ||
|
|
766efe0cda | ||
|
|
ab792de3c7 | ||
|
|
7807ef6d88 | ||
|
|
ba7407cca6 | ||
|
|
b83249187e | ||
|
|
2b22e7ea6f | ||
|
|
86b18f3bea | ||
|
|
f3c844b2f8 | ||
|
|
53568b6c6f | ||
|
|
35b034b9e7 | ||
|
|
45367d59d2 | ||
|
|
1ded5a4369 | ||
|
|
940f9a5662 | ||
|
|
319d4ead82 | ||
|
|
cd87ccf6ff | ||
|
|
9604c6c156 | ||
|
|
5b47d1b198 | ||
|
|
97d265045c | ||
|
|
ce508c4009 | ||
|
|
8094e8acec | ||
|
|
2d2cfe8ccf | ||
|
|
cb6d17c6e3 | ||
|
|
1811e18420 | ||
|
|
964aeef138 | ||
|
|
524d001c28 | ||
|
|
976a8f4f62 | ||
|
|
b30ea9c7d3 | ||
|
|
ae60182cd7 | ||
|
|
b28cfac096 | ||
|
|
4b93353022 | ||
|
|
7715b3d66d | ||
|
|
5fbecec78b | ||
|
|
64f15a1bf2 | ||
|
|
9ab08c22be | ||
|
|
f29e4d99ba | ||
|
|
fdb53d550e | ||
|
|
c2ac312522 | ||
|
|
c87b5e5728 | ||
|
|
1eeea835aa | ||
|
|
cf6a6200ca | ||
|
|
885ec12d88 | ||
|
|
c23911b14a | ||
|
|
da9a5b88aa | ||
|
|
d96490e60b | ||
|
|
2198c5d4a0 | ||
|
|
776179e41d | ||
|
|
7bda38ff48 | ||
|
|
a23ead4d9c | ||
|
|
0f820738c6 | ||
|
|
30d912114d | ||
|
|
567288309c | ||
|
|
7cd67f55f1 | ||
|
|
59e7dcd8e8 | ||
|
|
90e55a0a7d | ||
|
|
a280d91c05 | ||
|
|
feb54aeb9e | ||
|
|
ee96bf500e | ||
|
|
91a266889f | ||
|
|
6051138613 | ||
|
|
d9780f9954 | ||
|
|
453287dc1c | ||
|
|
8f119862d0 | ||
|
|
df1fc4a734 | ||
|
|
a545462410 | ||
|
|
bb7cc4d6e7 | ||
|
|
eb69cf41a5 | ||
|
|
642164b1b4 | ||
|
|
ff99a462d7 | ||
|
|
e7de87e8aa | ||
|
|
e5d91037cb | ||
|
|
e7db5b8aa2 | ||
|
|
551c962cd2 | ||
|
|
5ada4e05a2 | ||
|
|
1f3243e362 | ||
|
|
303b944128 | ||
|
|
989e8fd7a2 | ||
|
|
9a21e37516 | ||
|
|
29a27477b6 | ||
|
|
0ebc5a4c6e | ||
|
|
1c6131589f | ||
|
|
a183335df7 | ||
|
|
c0447ab6e0 | ||
|
|
0c9c2dacfa | ||
|
|
48dbd26d24 | ||
|
|
65de370539 | ||
|
|
1ffb050939 | ||
|
|
0f15c69831 | ||
|
|
5d99ea6154 | ||
|
|
7224cb76de | ||
|
|
1ac9df057d | ||
|
|
033941388c | ||
|
|
fc979bc6bf | ||
|
|
f1860f2934 | ||
|
|
ab8696a3a4 | ||
|
|
09cd00a563 | ||
|
|
f2ca7c3240 | ||
|
|
6928c15147 | ||
|
|
9e278de881 | ||
|
|
af9e207012 | ||
|
|
c667a6ba56 | ||
|
|
37c6888962 | ||
|
|
5729968630 | ||
|
|
5fb377da21 | ||
|
|
92f0c284cd | ||
|
|
7c8be94d88 | ||
|
|
19690712ba | ||
|
|
7c32a0c883 | ||
|
|
df87848caa | ||
|
|
534253fbfc | ||
|
|
afbbbcfd45 | ||
|
|
f5ea7e8490 | ||
|
|
c0b1c82ec4 | ||
|
|
99eb028a62 | ||
|
|
ce3a40a155 | ||
|
|
da5e71a614 | ||
|
|
c2e509e4c7 | ||
|
|
a068c0b1db | ||
|
|
b1fa69ed26 | ||
|
|
d91f485f1e | ||
|
|
0252dd3535 | ||
|
|
21cf18f34e | ||
|
|
892cae605b | ||
|
|
c97fd708e0 | ||
|
|
12dd52af3d | ||
|
|
3a3d784d6d | ||
|
|
86c98ccae1 | ||
|
|
e004121081 | ||
|
|
27c3bf71ec | ||
|
|
c5da78712f | ||
|
|
7cd12844fd | ||
|
|
f04d03fa90 | ||
|
|
10af3797d1 | ||
|
|
5dd9de8310 | ||
|
|
75c7b6b703 | ||
|
|
70ef27deb8 | ||
|
|
007f2e7b73 | ||
|
|
f7cafaefdc | ||
|
|
cb6e27e700 | ||
|
|
fd5ba1f98e | ||
|
|
e63fd4d79c | ||
|
|
be2a7e2ee3 | ||
|
|
85a8a29e69 | ||
|
|
b07fe783dd | ||
|
|
75e4f45e9f | ||
|
|
826d353bfd | ||
|
|
2891607947 | ||
|
|
b7a4955766 | ||
|
|
d1f7c78bbe | ||
|
|
289980aa41 | ||
|
|
217d1b60a3 | ||
|
|
fce1b38a24 | ||
|
|
6538465add | ||
|
|
a70b9e46a8 | ||
|
|
22d7c75261 | ||
|
|
1cdf7a1033 | ||
|
|
27afaf8e1b | ||
|
|
019699ae75 | ||
|
|
745df69024 | ||
|
|
6e84130261 | ||
|
|
124485b4f0 | ||
|
|
f6f9028680 | ||
|
|
7fab7c5ca8 | ||
|
|
355bcfa4d1 | ||
|
|
87715a1e93 | ||
|
|
cf5faca040 | ||
|
|
099ceb3bca | ||
|
|
56dd38b6e0 | ||
|
|
ad752e024a | ||
|
|
fc6f1052d6 | ||
|
|
f663b06626 | ||
|
|
7a38a4d7f8 | ||
|
|
28b8c04f95 | ||
|
|
85bc09c3da | ||
|
|
b817ea25e6 | ||
|
|
25ba2f597e | ||
|
|
321b3fbf3a | ||
|
|
df6a4e4a35 | ||
|
|
7c0031b265 | ||
|
|
e99ec75a0f | ||
|
|
15f851e825 | ||
|
|
0579e7a2fd | ||
|
|
1c0b7dc0b1 | ||
|
|
40d002fbfa | ||
|
|
e665eb668f | ||
|
|
05239717a5 | ||
|
|
b91f9bedfa | ||
|
|
12261ece0e | ||
|
|
bef017c12d | ||
|
|
a6544a399f | ||
|
|
60b61ae49d | ||
|
|
93ccd5f392 | ||
|
|
8169ed413c | ||
|
|
1a42dfadc0 | ||
|
|
c5a5573652 | ||
|
|
f7c3093478 | ||
|
|
6000e1fab9 | ||
|
|
2ac42539aa | ||
|
|
6d25b02975 | ||
|
|
f3582627fb | ||
|
|
9e98c2db78 | ||
|
|
d387b632dd | ||
|
|
69d4a49462 | ||
|
|
5f648983c8 | ||
|
|
d98bfd45fc | ||
|
|
a38931ca23 | ||
|
|
508fcb2f29 | ||
|
|
d280e4b131 | ||
|
|
48c014227d | ||
|
|
21c4be4148 | ||
|
|
d44290dcdc | ||
|
|
702c739ec8 | ||
|
|
c1122bd939 | ||
|
|
bdaa896fc1 | ||
|
|
3b1c051fd2 | ||
|
|
11194f819e | ||
|
|
662eb16fdd | ||
|
|
d65070973c | ||
|
|
cef41348cc | ||
|
|
bcba694308 | ||
|
|
fbd7c6d3fc | ||
|
|
f842c08d62 | ||
|
|
4e58a6915f | ||
|
|
4336644fbc | ||
|
|
e32909ac58 | ||
|
|
bd16e2ccaf | ||
|
|
36fa55139e | ||
|
|
b128280d5f | ||
|
|
51e3f05031 | ||
|
|
19b83070c6 | ||
|
|
5622956e75 | ||
|
|
1ac3ea4916 | ||
|
|
391cc0edf1 | ||
|
|
a59a98f8cb | ||
|
|
e62213bfd5 | ||
|
|
61b77c4754 | ||
|
|
758aaa3dd7 | ||
|
|
51389a27fb | ||
|
|
37b94cc36c | ||
|
|
1e4796d418 | ||
|
|
62b0d6012d | ||
|
|
52726c8bb3 | ||
|
|
ede06e0923 | ||
|
|
6eb2c95cc0 | ||
|
|
835dff8620 | ||
|
|
1019b0b83b | ||
|
|
a44070b505 | ||
|
|
58bd4e2d9d | ||
|
|
cff346e6a4 | ||
|
|
0331e34e91 | ||
|
|
26ff8d8588 | ||
|
|
9a38826cf7 | ||
|
|
b854631990 | ||
|
|
5d1cd97ebd | ||
|
|
c21feb74d1 | ||
|
|
052e2f2541 | ||
|
|
1270b57afa | ||
|
|
cf8b219b9d | ||
|
|
689133aab8 | ||
|
|
019c0f01eb | ||
|
|
743cac217b | ||
|
|
5f19cb1ec8 | ||
|
|
ac5ffa0f7c | ||
|
|
114e07eb01 | ||
|
|
8ba1d75ab3 | ||
|
|
b3555918ed | ||
|
|
0759c05ed1 | ||
|
|
278a8f70f2 | ||
|
|
fb5dc9923f | ||
|
|
f942505e62 | ||
|
|
2d2b2db0a7 | ||
|
|
18d5078842 | ||
|
|
074b2c51e2 | ||
|
|
539194720a | ||
|
|
19fc5865fa | ||
|
|
f0d58e0c6a | ||
|
|
ddc2bea418 | ||
|
|
24da6893ac | ||
|
|
7268017dc1 | ||
|
|
4133480750 | ||
|
|
006a265c7a | ||
|
|
6850ef8a7d | ||
|
|
497f556ba6 | ||
|
|
d62da744cd | ||
|
|
864482e393 | ||
|
|
e41c25ed5d | ||
|
|
3e429b83a8 | ||
|
|
cd1af401ba | ||
|
|
26e04bd890 | ||
|
|
b6d70fac9c | ||
|
|
9e572c786c | ||
|
|
4e44ce3ab8 | ||
|
|
74c7fcb4da | ||
|
|
ef64d52ad1 | ||
|
|
ab7bbec563 | ||
|
|
6afe4ab9d6 | ||
|
|
12f43e3691 | ||
|
|
1e7cf2a1ba | ||
|
|
90636250cb | ||
|
|
838451f956 | ||
|
|
cc85d999e1 | ||
|
|
0013013cd2 | ||
|
|
bfd04cf8a2 | ||
|
|
beb1b70f50 | ||
|
|
f52edad583 | ||
|
|
0a1283de4b | ||
|
|
bed263aa87 | ||
|
|
55d8d20f88 | ||
|
|
3a59e2cdc2 | ||
|
|
57fb754bc0 | ||
|
|
052b48348b | ||
|
|
5d15747c4e | ||
|
|
ce09359445 | ||
|
|
c22792bd9b | ||
|
|
4ab36c355e | ||
|
|
0b3829c1b4 | ||
|
|
ae4883f099 | ||
|
|
2e3cf25e57 | ||
|
|
e65b831f35 | ||
|
|
b6dc426eed | ||
|
|
a4f7619ca3 | ||
|
|
4e38dd0f1a | ||
|
|
2264db76cc | ||
|
|
28082abde5 | ||
|
|
4814cfae86 | ||
|
|
3aa7820239 | ||
|
|
c4a7232bca | ||
|
|
ee390ac0b1 | ||
|
|
187ee01d82 | ||
|
|
64f3d89abb | ||
|
|
bc33cef53f | ||
|
|
199936262a | ||
|
|
3b6eb22c16 | ||
|
|
0dc2ada7bc | ||
|
|
f591756697 | ||
|
|
86175dc284 | ||
|
|
d69970acdd | ||
|
|
8242c4a977 | ||
|
|
f319bce854 | ||
|
|
8bd1bfc3e0 | ||
|
|
cec3232b51 | ||
|
|
7dcd892106 | ||
|
|
78ca13fcb7 | ||
|
|
48d37045d2 | ||
|
|
92e4ec5ddb | ||
|
|
6d760e2c5b | ||
|
|
ee4eb6d86c | ||
|
|
44cea60852 | ||
|
|
4f68c6677e | ||
|
|
018aa632c9 | ||
|
|
ac1f19817f | ||
|
|
365ece55b1 | ||
|
|
8bbbfc6c7c | ||
|
|
5fb3c34745 | ||
|
|
8f32a7fed8 | ||
|
|
6a9a48fa81 | ||
|
|
2cd3ddf7e0 | ||
|
|
c110a53494 | ||
|
|
944ef03f80 | ||
|
|
654ee73945 | ||
|
|
b113a068fd | ||
|
|
216f9e878f | ||
|
|
3c1404c429 | ||
|
|
80d7251540 | ||
|
|
5d4fa15a0b | ||
|
|
02258478bb | ||
|
|
c4274e30ff | ||
|
|
aade5c2a80 | ||
|
|
a09113f2c6 | ||
|
|
d5cd6cd16a | ||
|
|
fc7ad2a3ff | ||
|
|
1539d4199c | ||
|
|
bf4fc1cb56 | ||
|
|
9bc2ec59e5 | ||
|
|
32baf04a75 | ||
|
|
a62da35686 | ||
|
|
7a9f409b59 | ||
|
|
12c103e354 | ||
|
|
cd62cbf576 | ||
|
|
e550d93ca5 | ||
|
|
25effd4805 | ||
|
|
bb6066d867 | ||
|
|
c44f40afd0 | ||
|
|
fa677ace84 | ||
|
|
37e312a6d9 | ||
|
|
1358e32470 | ||
|
|
e08eddb0c0 | ||
|
|
f7ac8b5fa4 | ||
|
|
7d192be572 | ||
|
|
7984dec523 | ||
|
|
bb420bc709 | ||
|
|
78b9a336d9 | ||
|
|
667a4ea749 | ||
|
|
4ede4ff88b | ||
|
|
e26043958a | ||
|
|
d3a6c267c6 | ||
|
|
0d92dfa563 | ||
|
|
6e9916fcbd | ||
|
|
e81c3e27bc | ||
|
|
f4613cdce4 | ||
|
|
799340ce06 | ||
|
|
ea1a033f2e | ||
|
|
dabdd8ae8f | ||
|
|
3e2b7eede9 | ||
|
|
f941deed79 | ||
|
|
f601b4a134 | ||
|
|
26630725bd | ||
|
|
7faa90ce43 | ||
|
|
4c99b6b06e | ||
|
|
2f2d8278a4 | ||
|
|
e8be2974f9 | ||
|
|
4930feff94 | ||
|
|
132d871039 | ||
|
|
aea6954dbb | ||
|
|
1ee8819e4c | ||
|
|
41e3b7fbf6 | ||
|
|
4218d240bc | ||
|
|
683d6fcc42 | ||
|
|
c9f6ab2fa6 | ||
|
|
c99d3baa3c | ||
|
|
d0ade2feff | ||
|
|
dcebe5a701 | ||
|
|
d33791fb28 | ||
|
|
8512b3ab4f | ||
|
|
4395d8cc89 | ||
|
|
55f4e6872c | ||
|
|
6699a9204c | ||
|
|
14e1a975c9 | ||
|
|
7ab3c4bcf9 | ||
|
|
1866196571 | ||
|
|
301c21ed20 | ||
|
|
2d5208a568 | ||
|
|
44a543e64c | ||
|
|
458c66819a | ||
|
|
dcf4f3f15d | ||
|
|
e33ef5420a | ||
|
|
8d1c3a05ce | ||
|
|
9a167a46d8 | ||
|
|
ffe60808b6 | ||
|
|
1affd6c2fa | ||
|
|
17225dca5b | ||
|
|
fc9f55ead8 | ||
|
|
eec877623e | ||
|
|
a06b0573c5 | ||
|
|
dfcfee302f | ||
|
|
cb1cc27c60 | ||
|
|
aed30a94c0 | ||
|
|
8e172e2647 | ||
|
|
ca355e1a01 | ||
|
|
b0e18d5224 | ||
|
|
f5fc80ef14 | ||
|
|
21f846f0bc | ||
|
|
a6a742b91e | ||
|
|
4ca6510910 | ||
|
|
e06ea06884 | ||
|
|
2c79dff678 | ||
|
|
56c4a094cf | ||
|
|
1898af9fea | ||
|
|
885d2bc019 | ||
|
|
12c604d09c | ||
|
|
7b48699b39 | ||
|
|
3b5593882f | ||
|
|
8c72154eed | ||
|
|
0dc942ecfd | ||
|
|
bc4d051590 | ||
|
|
011a0322ea | ||
|
|
ed90db12a4 | ||
|
|
3afea03485 | ||
|
|
6da17ee181 | ||
|
|
e5d1c255c0 | ||
|
|
b43754661c | ||
|
|
89c419c8df | ||
|
|
bd6b2b1edb | ||
|
|
b7c73902f2 | ||
|
|
c0995447de | ||
|
|
d970506c76 | ||
|
|
74fb06302a | ||
|
|
1cfed8aa98 | ||
|
|
9f563c37e5 | ||
|
|
d311588984 | ||
|
|
8c5324f602 | ||
|
|
17832a0bf7 | ||
|
|
3c415c63c9 | ||
|
|
6ab27775d2 | ||
|
|
e04bf8210f | ||
|
|
7b4879ddf1 | ||
|
|
081ac7bb3c | ||
|
|
d9894c6b74 | ||
|
|
f13f56c830 | ||
|
|
b6a67f2aeb | ||
|
|
a5b416b210 | ||
|
|
caa4a7a714 | ||
|
|
72aa819361 | ||
|
|
cf52db0c7d | ||
|
|
5021c4bf67 | ||
|
|
9dd8e757d4 | ||
|
|
da7cdb74d4 | ||
|
|
18c6ee6614 | ||
|
|
cafe2b1de7 | ||
|
|
74c94746c1 | ||
|
|
61130a1b2b | ||
|
|
7dafa5c8eb | ||
|
|
c89edc47c3 | ||
|
|
0b89df6262 | ||
|
|
c2218b2c67 | ||
|
|
1950cfdd2d | ||
|
|
71af70a026 | ||
|
|
b269c29f7c | ||
|
|
c9e8ade60f | ||
|
|
2364fd7ac6 | ||
|
|
7135ed0f95 | ||
|
|
b5fbaaaf92 | ||
|
|
94c025886a | ||
|
|
0956466edb | ||
|
|
b2b23ab622 | ||
|
|
0e6529efbe | ||
|
|
f7ce51f63a | ||
|
|
68334ef1a2 | ||
|
|
404c1eeb4d | ||
|
|
347c1d975d | ||
|
|
3b022fc841 | ||
|
|
88afb70fad | ||
|
|
62e21d9f93 | ||
|
|
20289a5d7b | ||
|
|
02b0103fbd | ||
|
|
a514ad6cac | ||
|
|
894f1147fd | ||
|
|
6a881b7c5f | ||
|
|
b3eaac0fbb | ||
|
|
4444b53106 | ||
|
|
ec4a28a63e | ||
|
|
f3722a32f5 | ||
|
|
b3cf416fc4 | ||
|
|
66c2f3a5a6 | ||
|
|
50609d6729 | ||
|
|
0635e7370e | ||
|
|
f94951cffa | ||
|
|
5ebdcca3e6 | ||
|
|
f00b7df49b | ||
|
|
e0a6c14825 | ||
|
|
a3bcc4a391 | ||
|
|
7af7034149 | ||
|
|
3cb18946ed | ||
|
|
ac604ee538 | ||
|
|
aac3c129cc | ||
|
|
28695094ca | ||
|
|
ac583d58bc | ||
|
|
52de25fad3 | ||
|
|
72bf623007 | ||
|
|
c6e61ea5a5 | ||
|
|
b400476758 | ||
|
|
9ff0fc8356 | ||
|
|
f7b142e8c6 | ||
|
|
4d80915811 | ||
|
|
f1edc73eca | ||
|
|
197beb1792 | ||
|
|
3aed208345 | ||
|
|
27e500fbf0 | ||
|
|
a0f6016dcd | ||
|
|
f37abe15c7 | ||
|
|
8f66733fe7 | ||
|
|
1bafb69f84 | ||
|
|
ed5ced8b31 | ||
|
|
468747847c | ||
|
|
d28ccc85ac | ||
|
|
9b5d6333d1 | ||
|
|
99307f15c7 | ||
|
|
8e9db014d1 | ||
|
|
5e88782475 | ||
|
|
ba50789744 | ||
|
|
f06e2d8045 | ||
|
|
58e7143a0a | ||
|
|
0ee3706190 | ||
|
|
9f7fc3dafd | ||
|
|
d8ce4a9578 | ||
|
|
574e8d4a54 | ||
|
|
19a7a6a733 | ||
|
|
1e131e57c3 | ||
|
|
57795bdb23 | ||
|
|
52bbb76aad | ||
|
|
1257ac4600 | ||
|
|
64ffc38405 | ||
|
|
f8009b05bc | ||
|
|
114f217046 | ||
|
|
2de309cccc | ||
|
|
7f827857bc | ||
|
|
75e244f678 | ||
|
|
a346f28df1 | ||
|
|
afa57566da | ||
|
|
6f46469ff6 | ||
|
|
7edf33a448 | ||
|
|
4d7b30eb20 | ||
|
|
ed8d92e4a4 | ||
|
|
f7e62f5790 | ||
|
|
84146236b1 | ||
|
|
97c4ee3564 | ||
|
|
f8547c5d86 | ||
|
|
c97acf7a29 | ||
|
|
fbbb11a4b0 | ||
|
|
e517bb43b8 | ||
|
|
e43ef1ea3e | ||
|
|
7ab78f30d5 | ||
|
|
668bc34157 | ||
|
|
5f89b30628 | ||
|
|
2145c9bc40 | ||
|
|
fdb3bca7f8 | ||
|
|
c96610d137 | ||
|
|
be6414602d | ||
|
|
a7b2d8010c | ||
|
|
4ccc5def2b | ||
|
|
5378d4e372 | ||
|
|
8d37d39b1c | ||
|
|
473a83604c | ||
|
|
4f72fbab78 | ||
|
|
1f62d68aed | ||
|
|
7c063bbe68 | ||
|
|
4c11df4b37 | ||
|
|
f859caf1ee | ||
|
|
566d688b57 | ||
|
|
e4209b15c3 | ||
|
|
bd5b26805a | ||
|
|
27c43b8e8e | ||
|
|
5b719141fe | ||
|
|
f8ee0bba17 | ||
|
|
d5ea3c60a9 | ||
|
|
3be9eaf47a | ||
|
|
f385927958 | ||
|
|
ec491a937c | ||
|
|
7bf879a08f | ||
|
|
18a0e1f338 | ||
|
|
c7cbf0230c | ||
|
|
cee519176a | ||
|
|
50d75449c0 | ||
|
|
316fbf7e62 | ||
|
|
7c82cbc6b4 | ||
|
|
8387b48e6b | ||
|
|
0e806a2985 |
No files matched your search
@@ -0,0 +1,30 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Bug report for VotingPlugin
|
||||
title: ''
|
||||
labels: Possible Bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version.
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots/Configs**
|
||||
If applicable, add screenshots to help explain your problem and/or configs relating to the issue.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea
|
||||
title: ''
|
||||
labels: Possible Feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,17 @@
|
||||
---
|
||||
name: Question/Concerns
|
||||
about: Ask about a question or a concern about the plugin
|
||||
title: ''
|
||||
labels: Question/Concern
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Versions**
|
||||
Plugin version and spigot version
|
||||
|
||||
**Relevant information**
|
||||
Configs that relate to the issue in a pastebin.
|
||||
|
||||
**Context**
|
||||
Context about the question/concern
|
||||
@@ -0,0 +1,16 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 20
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 5
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- Priority
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
@@ -2,9 +2,13 @@
|
||||
Plugin on SpigotMC
|
||||
https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/LICENSE.txt
|
||||
https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
|
||||
### Maven:
|
||||
|
||||
@@ -14,7 +18,7 @@ https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/LICENSE.t
|
||||
</repository>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.Ben12345rocks</groupId>
|
||||
<groupId>com.github.BenCodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
|
||||
@@ -15,6 +15,16 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=Cp1252
|
||||
encoding/Resources=Cp1252
|
||||
encoding/src=Cp1252
|
||||
@@ -1,13 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
@@ -17,40 +8,15 @@ org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.doc.comment.support=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
@@ -59,65 +25,6 @@ org.eclipse.jdt.core.compiler.problem.missingJavadocTags=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsMethodTypeParameters=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=info
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -1,4 +1,4 @@
|
||||
activeProfiles=
|
||||
activeProfiles=dev
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,8 @@
|
||||
DELEGATES_PREFERENCE=delegateValidatorList
|
||||
USER_BUILD_PREFERENCE=enabledBuildValidatorList
|
||||
USER_MANUAL_PREFERENCE=enabledManualValidatorList
|
||||
USER_PREFERENCE=overrideGlobalPreferencesfalse
|
||||
eclipse.preferences.version=1
|
||||
override=false
|
||||
suspend=false
|
||||
vf.version=3
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,49 @@
|
||||
# --------------------------
|
||||
# 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
|
||||
|
||||
# For pluginmessaging method only
|
||||
# Whether to broadcast on cached votes
|
||||
BungeeBroadcastAlways: false
|
||||
|
||||
# What type of bungee setup
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/Ben12345rocks/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
# MYSQL
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
# 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
|
||||
BungeeBroadcast: false
|
||||
|
||||
# What server this is in bungee (must match)
|
||||
# Also can be applied to rewards
|
||||
Server: PleaseSet
|
||||
|
||||
# -----------------------------
|
||||
# For socket setup below only
|
||||
# -----------------------------
|
||||
|
||||
# Bungee communication, add bungee host/port here
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add this to bungee server
|
||||
# For socket method
|
||||
SpigotServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
+262
-511
@@ -2,14 +2,17 @@
|
||||
# Main Config
|
||||
# See wiki for help:
|
||||
# https://github.com/Ben12345rocks/VotingPlugin/wiki
|
||||
|
||||
# Config is sorted in sections
|
||||
# Use Control + F to search with Notepad++
|
||||
#
|
||||
# Valid Options:
|
||||
# - SQLITE
|
||||
# - SQLITE
|
||||
# - FLAT
|
||||
# - MYSQL
|
||||
DataStorage: SQLITE
|
||||
|
||||
# Information for mysql
|
||||
# See the end of the config for cache options
|
||||
MySQL:
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
@@ -26,22 +29,15 @@ MySQL:
|
||||
# Table name prefix, for use with mutliple servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data files)
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# If true, plugin will send scoreboards on some commands
|
||||
SendScoreboards: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note that updates take 30-40 minutes to load before they can be downloaded
|
||||
AutoDownload: false
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
# ------------------------------------------------
|
||||
# VoteReminding
|
||||
@@ -53,12 +49,12 @@ AutoDownload: false
|
||||
VoteReminding:
|
||||
# Enable vote reminding
|
||||
# This will remind player when he can vote on all sites
|
||||
# Requires VoteDelay's to be setup properly
|
||||
# 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"
|
||||
Enabled: true
|
||||
|
||||
# Wether or t to remind only once when the player can vote
|
||||
# Whether or not to remind only once when the player can vote
|
||||
# Does not apply to login reminds.
|
||||
RemindOnlyOnce: true
|
||||
|
||||
@@ -85,25 +81,15 @@ VoteReminding:
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
|
||||
Commands:
|
||||
# Wether or not the following commands will open GUIs rather than display text
|
||||
UseGUI:
|
||||
Today: true
|
||||
TopVoter: true
|
||||
Last: true
|
||||
Next: true
|
||||
Total: true
|
||||
Vote: true
|
||||
Best: true
|
||||
Streak: true
|
||||
ActionBar:
|
||||
Message: '&cRemember to vote'
|
||||
Delay: 30
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
# ------------------------------------------------
|
||||
|
||||
# Common PlacesHolders:
|
||||
# Please Note: Not all are usable in all sections
|
||||
# Special PlaceHolders will be commented where available
|
||||
# %player% = player name
|
||||
# %SiteName% = vote site name
|
||||
@@ -112,7 +98,8 @@ Commands:
|
||||
|
||||
Format:
|
||||
# CommandHandler help message
|
||||
HelpLine: '&3&l%Command% - &3%HelpMessage%'
|
||||
# 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
|
||||
@@ -127,7 +114,7 @@ Format:
|
||||
# %url% = site URL
|
||||
Vote:
|
||||
Text:
|
||||
- '&4&lVote for our server!'
|
||||
- '&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
|
||||
@@ -136,7 +123,10 @@ Format:
|
||||
# make sure to set VoteURL in your VoteSites
|
||||
# Requires above to be true
|
||||
# Text will be sent before this
|
||||
Sites: '&4%num%: &c&l%SiteName% - &c%url%'
|
||||
Sites: '&3%num%: &6&l%SiteName% &6- %url%'
|
||||
|
||||
# If true, links will always be forced as urls
|
||||
ForceLinks: true
|
||||
|
||||
# Format for /vote next
|
||||
Next:
|
||||
@@ -166,7 +156,12 @@ Format:
|
||||
Title: '&3&l%player% Last Vote Times:'
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
Line: '&3%SiteName%: &6%time%'
|
||||
# %timesince% = time since vote
|
||||
Line: '&3%SiteName%: &6%timeSince%'
|
||||
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
LastVoted: '%times% ago'
|
||||
NeverVoted: 'Never voted'
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
@@ -197,9 +192,9 @@ Format:
|
||||
# Format for /vote help
|
||||
Help:
|
||||
# Title of /vote help
|
||||
Title: '&3&lVoting Player Help'
|
||||
Title: '&6&lVoting Player Help'
|
||||
# Format for help message in /v help
|
||||
Line: '&3&l%Command% - &3%HelpMessage%'
|
||||
Line: '&6%Command% - &6%HelpMessage%'
|
||||
# Require permission to see command in /v help or /av help
|
||||
RequirePermission: true
|
||||
|
||||
@@ -221,6 +216,9 @@ Format:
|
||||
- '&3Highest Week Streak: &3&l%BestWeeklyStreak%'
|
||||
- '&3Highest Month Streak: &3&l%BestMonthlyStreak%'
|
||||
|
||||
Today:
|
||||
Line: '&6%player% : %VoteSite% : %Time%'
|
||||
|
||||
# PlaceHolders:
|
||||
# %VotesRequired% = VotesRequired
|
||||
# %NeededVotes% = Number of votes needed to reach VotesRequired
|
||||
@@ -230,6 +228,10 @@ Format:
|
||||
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
ToggleBroadcasts:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
@@ -239,6 +241,19 @@ 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
|
||||
@@ -265,9 +280,18 @@ Format:
|
||||
# User not exist message, from commands such as /vote next (player)
|
||||
UserNotExist: '&cUser does not exist: %player%'
|
||||
|
||||
# Text for page buttons in inventories
|
||||
PrevPage: '&aPrevious Page'
|
||||
NextPage: '&aNext Page'
|
||||
# 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)
|
||||
@@ -277,410 +301,19 @@ Format:
|
||||
Monthly: 'Monthly'
|
||||
AllTime: 'AllTime'
|
||||
|
||||
# ------------------------------------------------
|
||||
# GUI Options
|
||||
# ------------------------------------------------
|
||||
|
||||
# Configure GUI's here
|
||||
# Note: Slots start at 0 instead of 1, max slot is 53 (don't go over) (E.g: last slot in first row of inventory is 8)
|
||||
# Item Material's can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||
GUI:
|
||||
# GUI for /vote gui, /vgui, votegui
|
||||
VoteGUI:
|
||||
# Items will be orders as it is below
|
||||
URL:
|
||||
# Standard item format, lore is automaticly applied
|
||||
Item:
|
||||
Material: 'BOW'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4URL'
|
||||
# You can set skulls of the player using the following
|
||||
# Remove the # to enable
|
||||
#Skull: '%Player%'
|
||||
Slot: 0
|
||||
Next:
|
||||
Item:
|
||||
Material: 'COMPASS'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Next'
|
||||
Slot: 1
|
||||
Last:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
Slot: 2
|
||||
Total:
|
||||
Item:
|
||||
Material: 'CHEST'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Total'
|
||||
Slot: 3
|
||||
Top:
|
||||
Item:
|
||||
Material: 'SIGN'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Top'
|
||||
Slot: 4
|
||||
Today:
|
||||
Item:
|
||||
Material: 'BOOK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Today'
|
||||
Slot: 5
|
||||
Shop:
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
Slot: 6
|
||||
|
||||
# GUI for /vote url
|
||||
# And /vote if enabled in Config.yml
|
||||
VoteURL:
|
||||
# GUI Name
|
||||
Name: '&cVoteURL'
|
||||
BackButton: true
|
||||
SiteName: '&c%Name%'
|
||||
SeeURL: '&cClick to see URL'
|
||||
NextVote: '&cCan Vote In: %Info%'
|
||||
ViewAllUrlsButtonEnabled: true
|
||||
AllUrlsButton:
|
||||
AlreadyVotedItem:
|
||||
Material: 'REDSTONE_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4All Voting Sites'
|
||||
Lore:
|
||||
- '&cClick Me'
|
||||
CanVoteItem:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4All Voting Sites'
|
||||
Lore:
|
||||
- '&cClick Me'
|
||||
AlreadyVotedItem:
|
||||
Material: 'REDSTONE_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
CanVoteItem:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
URLText: '%VoteUrl%'
|
||||
# Customize /vote reward
|
||||
# Show players what you get when you vote on each site
|
||||
VoteReward:
|
||||
# Name of votesite
|
||||
ExampleVoteSite:
|
||||
# items in /vote reward sitename
|
||||
Items:
|
||||
# Item
|
||||
# This is not the item display name
|
||||
# Do not have 2 of the same items
|
||||
Diamond:
|
||||
# Item ID
|
||||
Material: 'DIAMOND'
|
||||
# Item Data (Eg 1:4, data is 4)
|
||||
Data: 0
|
||||
# Amount of items
|
||||
# Should be greater than 0
|
||||
Amount: 1
|
||||
# Item name
|
||||
# Remove this line for no name
|
||||
Name: '&4Example'
|
||||
# Lore
|
||||
# Remove this line for no lore
|
||||
Lore:
|
||||
- '&4Line 1'
|
||||
Slot: 0
|
||||
VoteLast:
|
||||
Name: 'VoteLast: %player%'
|
||||
BackButton: true
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
VoteToday:
|
||||
Name: 'VoteToday'
|
||||
BackButton: true
|
||||
VoteTop:
|
||||
Name: 'VoteTop %topvoter%'
|
||||
BackButton: false
|
||||
Item:
|
||||
Name: '&3&l%position%: &3%player%'
|
||||
Lore: '&3&lVotes: &3%votes%'
|
||||
SwitchItem:
|
||||
Name: 'Switch TopVoter'
|
||||
Lore: 'Currently: %Top%'
|
||||
Material: 'SIGN'
|
||||
Amount: 1
|
||||
# 8 Slots over from the bottom left
|
||||
Slot: 7
|
||||
# Number of topvoters to display on page +9
|
||||
# 9 Slots on the botton are used for page buttons
|
||||
Size: 27
|
||||
VoteTotal:
|
||||
Name: 'VoteTotal: %player%'
|
||||
BackButton: true
|
||||
DayTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cDaily Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
WeekTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cWeekly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
MonthTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cMonthly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
AllTimeTotal:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cAllTime Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
VoteBest:
|
||||
Name: 'VoteBest: %player%'
|
||||
DayBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cDaily Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
WeekBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cWeekly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
MonthBest:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cMonthly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
VoteStreak:
|
||||
Name: 'VoteStreak: %player%'
|
||||
BackButton: false
|
||||
CurrentDayStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cCurrent Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentWeekStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cCurrent Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentMonthStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cCurrent Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestDayStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cHighest Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestWeekStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cHighest Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestMonthStreak:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Name: '&cHighest Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
VoteURLSite:
|
||||
Name: 'VoteSite: %site%'
|
||||
VoteGUIName: '&cVoteGUI: &c&l%player%'
|
||||
VoteRewardName: 'VoteReward'
|
||||
VoteShopName: 'VoteShop'
|
||||
|
||||
BackButton:
|
||||
Material: 'PAPER'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&8Back to VoteGUI'
|
||||
|
||||
VoteShopBackButton: true
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
Diamond:
|
||||
# Item
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Buy A Diamond'
|
||||
# You can set skulls of the player using the following
|
||||
# Remove the # to enable
|
||||
#Skull: '%Player%'
|
||||
Lore:
|
||||
- '&c&lCost: &c3 Voting Points'
|
||||
# Number of voting points this cost
|
||||
Cost: 3
|
||||
# Rewards to run if player buys succesfully
|
||||
Rewards:
|
||||
Items:
|
||||
Diamond:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
# Slot
|
||||
Slot: 0
|
||||
|
||||
# ------------------------------------------------
|
||||
# Extra Rewards
|
||||
# ------------------------------------------------
|
||||
|
||||
# To disable reward set value to []
|
||||
# Eg:
|
||||
# FirstVote: [] (All in one line)
|
||||
# By default all rewards are disabled
|
||||
|
||||
# First vote rewards
|
||||
FirstVote:
|
||||
Messages:
|
||||
Player: '&aYou voted for your first time!'
|
||||
Money: 100
|
||||
|
||||
# All vote rewards
|
||||
# Reward for voting on all sites in one day
|
||||
AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
Cumulative:
|
||||
# Number of votes required
|
||||
# Allows multiple cumulative rewards
|
||||
# Number be be around ' (E.g. '1')
|
||||
# Can have multiple listed here
|
||||
'20':
|
||||
Enabled: false
|
||||
# Wether 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
|
||||
VotesInSameDay: false
|
||||
VotesInSameWeek: false
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %cumulative% cumulative votes!'
|
||||
|
||||
VoteParty:
|
||||
# Wether or not vote party is enabled
|
||||
Enabled: false
|
||||
# Number of votes required to give rewards
|
||||
VotesRequired: 20
|
||||
# If true, players who did not vote to reach the votes required will
|
||||
# recieve the reward
|
||||
GiveAllPlayers: false
|
||||
# If true, the vote count will reset each day
|
||||
ResetEachDay: false
|
||||
# Reset at the end of the month
|
||||
ResetMonthly: 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
|
||||
# Broadcast when vote party reached
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# List of commands to execute, these only execute once.
|
||||
Commands: []
|
||||
# Reward files to give
|
||||
Rewards: []
|
||||
|
||||
# Reset milestons at end of the month
|
||||
ResetMilestonesMonthly: false
|
||||
|
||||
MileStones:
|
||||
# Number of votes required
|
||||
# Allows multiple milestones
|
||||
# Number be 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':
|
||||
# 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!"
|
||||
|
||||
|
||||
# ONLY USE THIS FOR TITLES/SOUNDS AND OTHER EFFECTS
|
||||
# IT WILL ONLY RUN ONE TIME FOR ANY NUMBER OF OFFLINE VOTES
|
||||
# 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
|
||||
AnySiteRewards: []
|
||||
|
||||
|
||||
# ------------------------------------------------
|
||||
# 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 ops
|
||||
# This also applies for players with op
|
||||
TopVoterIgnorePermission: false
|
||||
|
||||
# /vote top default data displayed
|
||||
@@ -696,6 +329,10 @@ LoadTopVoter:
|
||||
Monthly: true
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# Maxium number of players to show on top voter
|
||||
# Set to -1 for no limit
|
||||
MaxiumNumberOfTopVotersToLoad: -1
|
||||
|
||||
# When top voter awards are given (even if there are none listed) it will store top voters
|
||||
# Files will created in TopVoters folder.
|
||||
@@ -703,52 +340,21 @@ StoreTopVoters:
|
||||
Monthly: true
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
EnableMonthlyAwards: true
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# 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%!'
|
||||
|
||||
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%!'
|
||||
|
||||
# ------------------------------------------------
|
||||
# Advanced
|
||||
# Most of these values can be left untouched
|
||||
# Most of these values can be left untouched for most setups
|
||||
# ------------------------------------------------
|
||||
|
||||
# If false, votestreaks will be disabled
|
||||
UseVoteStreaks: true
|
||||
|
||||
# If false, storing best totals will be disabled
|
||||
UseHighestTotals: true
|
||||
|
||||
# If true, /vote will open /vote gui by default
|
||||
UseVoteGUIMainCommand: false
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
@@ -757,16 +363,71 @@ PointsOnVote: 1
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
DisableCheckOnWorldChange: false
|
||||
# If true, items given for rewards are dropped on the ground
|
||||
# If false, items will be given when there is space
|
||||
DropOnFullInv: true
|
||||
|
||||
# Click sound when using gui
|
||||
# Set to none for no sound
|
||||
ClickSound:
|
||||
Sound: 'UI_BUTTON_CLICK'
|
||||
Volume: 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# Playernames to not be broadcasted when voting
|
||||
# case sensitive
|
||||
VotingBroadcastBlacklist: []
|
||||
|
||||
# When enabled, javascript will be parsed on placeholders (from placeholderapi)
|
||||
# allows more fancy placeholders with math for example
|
||||
UseJavascriptPlaceholders: false
|
||||
|
||||
# Limit monthly votes to number of days of a month multipled by the number of sites
|
||||
LimitMonthlyVotes: false
|
||||
|
||||
# This is an extra safe guard to prevent milestones
|
||||
# from being executed more than once
|
||||
# Shoudn't be needed, but enable if you have trouble with milestones
|
||||
PreventRepeatMilestones: false
|
||||
|
||||
# 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
|
||||
|
||||
# If true, permissions will be handled differently
|
||||
MultiplePermissionsCheck: false
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
# Requires AddCustomCommand: true to be set
|
||||
CustomCommands:
|
||||
# identifier, not specific name
|
||||
command1:
|
||||
Args:
|
||||
- token
|
||||
# Message to send on command
|
||||
Message: 'token message'
|
||||
# Permission for this command
|
||||
Permission: 'votingplugin.commands.vote.token'
|
||||
# help message
|
||||
HelpMessage: 'See tokens'
|
||||
# Forces player to run this command
|
||||
Commands:
|
||||
- tokencommand
|
||||
|
||||
######################
|
||||
# Debug
|
||||
Debug: false
|
||||
######################
|
||||
|
||||
# Extra Debug
|
||||
# Only needed in extreme cases
|
||||
ExtraDebug: false
|
||||
# Debug levels:
|
||||
# NONE
|
||||
# INFO
|
||||
# EXTRA
|
||||
DebugLevel: NONE
|
||||
|
||||
# Debug info ingame
|
||||
# Players with permission "VotingPlugin.Debug"
|
||||
@@ -774,49 +435,30 @@ ExtraDebug: false
|
||||
DebugInGame: false
|
||||
|
||||
# Will log debug messages to VotingPlugin/Log/log.txt
|
||||
# Requires Debug to be on
|
||||
LogDebugToFile: false
|
||||
|
||||
# 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: []
|
||||
# Only needed for extreme cases
|
||||
#LogDebugToFile: false
|
||||
|
||||
# Wether or not to log every vote to a file
|
||||
# Whether or not to log every vote to a file
|
||||
# Use this if you wanna track player votes
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
# Only update in the background when needed when set to false
|
||||
AlwaysUpdate: false
|
||||
|
||||
# Update in the background only if players are online
|
||||
UpdateWithPlayersOnlineOnly: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Clear cache on update, setting to true reduces performance
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clears cache for the player who voted only
|
||||
# Only effects if using mysql
|
||||
# Would recommend for some bungee setups
|
||||
ClearCacheOnVote: false
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
# Will also disable a few other warnings about vote sites
|
||||
DisableNoServiceSiteMessage: false
|
||||
|
||||
# Used in special cases
|
||||
# Much slower, but may work better
|
||||
AlternateUUIDLookup: false
|
||||
|
||||
# Shouldn't need to change this
|
||||
AutoKillInvs: true
|
||||
|
||||
# Count fake votes
|
||||
# If true fake votes will give points and totals
|
||||
CountFakeVotes: true
|
||||
@@ -825,6 +467,10 @@ CountFakeVotes: true
|
||||
# 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: []
|
||||
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
@@ -832,6 +478,111 @@ PurgeOldData: false
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
# Whether or not to disable checking names on mojang, disable if you hit the rate limit
|
||||
# Shouldn't make a noticeable impact if set to false
|
||||
CheckNameMojang: true
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
# Most cases this will work all the time
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note: It takes 30-40 minutes before being able to download the latest build
|
||||
# You can also use /av download
|
||||
AutoDownload: false
|
||||
|
||||
# Whether or not to disable update checks
|
||||
DisableUpdateChecking: false
|
||||
|
||||
# Allow transfer of vote points between players
|
||||
AllowVotePointTransfers: false
|
||||
|
||||
# Disable this on a hub server for example
|
||||
# Still processes rewards for offline rewards (just won't give any)
|
||||
ProcessRewards: true
|
||||
|
||||
# Disable checking permissions on tab complete
|
||||
DisableAdvancedTab: false
|
||||
|
||||
# Load command aliases, such as /avgui
|
||||
# Requires restart to take effect
|
||||
LoadCommandAliases: true
|
||||
|
||||
# Wait until user is logged in with AuthMe
|
||||
# Requires AuthMe
|
||||
WaitUntilLoggedIn: true
|
||||
|
||||
# Preload skulls to improve performance
|
||||
# If false, skulls will be cached as they are used
|
||||
PreloadSkulls: false
|
||||
|
||||
# Setting to false disables saving skulls in a cache to improve speeds
|
||||
# Will reduce ram usage if disabled
|
||||
LoadSkulls: 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: []
|
||||
|
||||
# Enable to true for extra player checks
|
||||
ExtraBackgroundUpdate: false
|
||||
|
||||
# This will prevent spam clicking GUI's to prevent exploits
|
||||
# Number is time in between clicking in milliseconds
|
||||
SpamClickTime: 350
|
||||
# Message to send when inventory forced closed when spam clicking
|
||||
# Uncomment to use
|
||||
#SpamClickMessage: '&cDetected spam clicking GUI, closing to prevent exploits'
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Mysql cache options
|
||||
# Clearing cache forces the plugin to pull from database
|
||||
# Not needed unless you are using multiple servers
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# Clear cache on update, setting to true reduces update speed
|
||||
# Also may require AlwaysUpdate set to true
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clear cache on player join always
|
||||
ClearCacheOnJoin: false
|
||||
|
||||
# Clears cache for the player who voted only
|
||||
# Only effects if using mysql
|
||||
# Would recommend for some bungee setups
|
||||
ClearCacheOnVote: false
|
||||
|
||||
# Clear cache when player leaves
|
||||
ClearCacheOnLeave: false
|
||||
|
||||
ClearCacheOnVoteShopPurchase: true
|
||||
|
||||
# ###############################################################
|
||||
# Deprecated options, don't recommend using any of these
|
||||
|
||||
# Will force GUI's to close on every click
|
||||
AlwaysCloseInventory: false
|
||||
|
||||
# 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: []
|
||||
|
||||
# Shouldn't need to change this
|
||||
#AutoKillInvs: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
#DisableCheckOnWorldChange: false
|
||||
@@ -0,0 +1,328 @@
|
||||
# Configure GUI's here
|
||||
# Note: Slots start at 0 instead of 1, max slot is 53 (don't go over) (E.g: last slot in first row of inventory is 8)
|
||||
# Item Material's can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||
#
|
||||
# GUI Methods:
|
||||
# - BOOK
|
||||
# - CHEST
|
||||
# - CHAT (Disables GUI)
|
||||
GUIMethod:
|
||||
Today: CHEST #BOOK not available (future update?)
|
||||
TopVoter: CHEST #BOOK not available (future update?)
|
||||
Last: CHEST #BOOK not available (future update?)
|
||||
Next: CHEST
|
||||
Total: CHEST #BOOK not available (future update?)
|
||||
URL: CHEST
|
||||
Best: CHEST #BOOK not available (future update?)
|
||||
Streak: CHEST #BOOK not available (future update?)
|
||||
GUI: CHEST #CHAT/BOOK not availabe for this (future update?)
|
||||
|
||||
# Enable command for last month gui
|
||||
# Requires restart to take effect
|
||||
LastMonthGUI: false
|
||||
|
||||
CHEST:
|
||||
# GUI for /vote gui, /vgui, /votegui
|
||||
VoteGUI:
|
||||
# Items will be ordered as listed here
|
||||
# You can add items following this format, even set slots
|
||||
# See extra item below. GUI will auto resize to what is needed
|
||||
URL:
|
||||
# Standard item format, lore is automaticly applied
|
||||
Item:
|
||||
Material: 'BOW'
|
||||
Amount: 1
|
||||
Name: '&4URL'
|
||||
Lore:
|
||||
- '&aClick me for links'
|
||||
# You can set skulls of the player using the following
|
||||
# Remove the # to enable
|
||||
#Skull: '%Player%'
|
||||
Next:
|
||||
Item:
|
||||
Material: 'COMPASS'
|
||||
Amount: 1
|
||||
Name: '&4Next'
|
||||
Last:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
Total:
|
||||
Item:
|
||||
Material: 'CHEST'
|
||||
Amount: 1
|
||||
Name: '&4Total'
|
||||
Top:
|
||||
Item:
|
||||
Material: 'OAK_SIGN'
|
||||
Amount: 1
|
||||
Name: '&4Top'
|
||||
Today:
|
||||
Item:
|
||||
Material: 'BOOK'
|
||||
Amount: 1
|
||||
Name: '&4Today'
|
||||
Shop:
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
# 'ExtraName' below is an identifier, can be whatever
|
||||
# ExtraItem:
|
||||
# Item:
|
||||
# Material: 'DIRT'
|
||||
# Amount: 1
|
||||
# Name: 'Extra item'
|
||||
## Works on most GUI items
|
||||
# Slot: 10
|
||||
## Send rewards on click, run commands, check conditions, etc
|
||||
# Rewards: []
|
||||
|
||||
# GUI for /vote url, /vote
|
||||
VoteURL:
|
||||
# GUI Name
|
||||
Name: '&cVoteURL'
|
||||
BackButton: true
|
||||
SiteName: '&c%Name%'
|
||||
SeeURL: '&cClick to see URL'
|
||||
NextVote: '&cCan Vote In: %Info%'
|
||||
ViewAllUrlsButtonEnabled: true
|
||||
AllUrlsButton:
|
||||
RequireAllSitesVoted: true
|
||||
AlreadyVotedItem:
|
||||
Material: 'REDSTONE_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4All Voting Sites'
|
||||
Lore:
|
||||
- '&cClick Me'
|
||||
CanVoteItem:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4All Voting Sites'
|
||||
Lore:
|
||||
- '&cClick Me'
|
||||
AlreadyVotedItem:
|
||||
Material: 'REDSTONE_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
CanVoteItem:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
URLText: '%VoteUrl%'
|
||||
|
||||
VoteLast:
|
||||
Name: 'VoteLast: %player%'
|
||||
BackButton: true
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
VoteToday:
|
||||
Name: 'VoteToday'
|
||||
Line: '&6%VoteSite% : %Time%'
|
||||
IconTitle: '%player%'
|
||||
BackButton: true
|
||||
UseSkull: true
|
||||
# If UseSkull is false, use this item
|
||||
PlayerItem:
|
||||
Material: 'PAPER'
|
||||
Amount: 1
|
||||
VoteTop:
|
||||
Name: 'VoteTop %topvoter%'
|
||||
BackButton: false
|
||||
Item:
|
||||
Name: '&3&l%position%: &3%player%'
|
||||
Lore: '&3&lVotes: &3%votes%'
|
||||
SwitchItem:
|
||||
Name: '&3Switch TopVoter'
|
||||
Lore: '&bCurrently: %Top%'
|
||||
Material: 'OAK_SIGN'
|
||||
Amount: 1
|
||||
# 8 Slots over from the bottom left
|
||||
# Bottom of GUI
|
||||
Slot: 7
|
||||
# Number of topvoters to display on each GUI page
|
||||
# 9 Slots on the botton are used for page buttons (added on top)
|
||||
Size: 27
|
||||
# If true, /vote top will show player heads
|
||||
UseSkull: true
|
||||
# Item for player in GUI if use skull is false
|
||||
PlayerItem:
|
||||
Material: 'PAPER'
|
||||
VoteTotal:
|
||||
Name: 'VoteTotal: %player%'
|
||||
BackButton: true
|
||||
DayTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
WeekTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
MonthTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
AllTimeTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cAllTime Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
VoteBest:
|
||||
Name: 'VoteBest: %player%'
|
||||
DayBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
WeekBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
MonthBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
VoteStreak:
|
||||
Name: 'VoteStreak: %player%'
|
||||
BackButton: false
|
||||
CurrentDayStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentWeekStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentMonthStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestDayStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestWeekStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestMonthStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
VoteURLSite:
|
||||
Name: 'VoteSite: %site%'
|
||||
VoteGUIName: '&cVoteGUI: &c&l%player%'
|
||||
VoteRewardName: 'VoteReward'
|
||||
VoteShopName: 'VoteShop'
|
||||
|
||||
BackButton:
|
||||
Material: 'BARRIER'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&8Back to VoteGUI'
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
# Hide items in vote shop which user can not buy
|
||||
VoteShopHideLimitedReached: true
|
||||
# Requires above to be false
|
||||
VoteShopLimitReached: '&aYou reached your limit'
|
||||
VoteShopRequireConfirmation: false
|
||||
VoteShopDisabled: '&cVote shop disabled'
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
# Do not have spaces in the identifier
|
||||
# Change the identifier for each shop item
|
||||
Diamond:
|
||||
Identifier_Name: 'Diamond'
|
||||
# Item
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Buy A Diamond'
|
||||
# You can set skulls of the player using the following
|
||||
# Remove the # to enable
|
||||
#Skull: '%Player%'
|
||||
Lore:
|
||||
- '&c&lCost: &c3 Voting Points'
|
||||
# Number of voting points this cost
|
||||
Cost: 3
|
||||
# Permission required, leave blank for no permission
|
||||
Permission: ''
|
||||
# Whether or not to keep GUI open after purchase
|
||||
CloseGUI: true
|
||||
# Require confirmation on purchase, overrides global option above
|
||||
RequireConfirmation: false
|
||||
# Overrides other purchase message
|
||||
#PurchaseMessage: 'Thanks for the purchase'
|
||||
# Limit how many times you can buy this
|
||||
#Limit: 3
|
||||
# Reset limit daily/weekly/monthly
|
||||
#Reset:
|
||||
#Daily: false
|
||||
#Weekly: false
|
||||
#Monthly: false
|
||||
# If true, item is not buyable
|
||||
#NotBuyable: false
|
||||
# Rewards to run if player buys successfully
|
||||
Rewards:
|
||||
Items:
|
||||
Diamond:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
ShopConfirmPurchase:
|
||||
Title: 'Confirm Purchase?'
|
||||
YesItem:
|
||||
Material: EMERALD_BLOCK
|
||||
Amount: 1
|
||||
Name: '&aYes'
|
||||
NoItem:
|
||||
Material: BARRIER
|
||||
Amount: 1
|
||||
Name: '&cNo'
|
||||
|
||||
|
||||
BOOK:
|
||||
VoteURLBookGUI:
|
||||
Title: '&cVoteURL'
|
||||
CanVoteText: 'Click me'
|
||||
CanVoteColor: 'GREEN'
|
||||
AlreadyVotedText: 'Click me'
|
||||
AlreadyVotedColor: 'RED'
|
||||
Layout:
|
||||
- '&3&l%Sitename%'
|
||||
- '[UrlText]'
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
# 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
|
||||
|
||||
# First vote rewards
|
||||
FirstVote:
|
||||
Messages:
|
||||
Player: '&aYou voted for your first time!'
|
||||
|
||||
# All vote rewards
|
||||
# Reward for voting on all sites in one day
|
||||
AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
# 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 as 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
|
||||
# Wether 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
|
||||
VotesInSameDay: false
|
||||
VotesInSameWeek: false
|
||||
VotesInSameMonth: false
|
||||
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, 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
|
||||
# Reset extra votes
|
||||
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!'
|
||||
# List of commands to execute, these only execute once.
|
||||
# %player% does not work here
|
||||
Commands: []
|
||||
# Rewards to give per player
|
||||
Rewards:
|
||||
# Uncomment below for online player rewards 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)
|
||||
'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 vote cooldown ended
|
||||
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
|
||||
|
||||
# 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,5 +1,7 @@
|
||||
VoteSites:
|
||||
# VoteSite name
|
||||
# VoteSite key
|
||||
# Used for saving data for votesites
|
||||
# Use a short name if you can
|
||||
ExampleVoteSite:
|
||||
# Enable voteSite
|
||||
# If false, votesite will not be loaded by plugin
|
||||
@@ -16,37 +18,96 @@ VoteSites:
|
||||
|
||||
# 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)
|
||||
# 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 Format.yml
|
||||
# Do not include colors here
|
||||
# If you need to force a url set the url as this:
|
||||
# VoteURL: '[Text="ANY TEXT TO CLICK ON HERE",url="URLHERE"]'
|
||||
VoteURL: 'link to vote URL here, used in /vote'
|
||||
|
||||
# Time between votes in hours (used for /vote next)
|
||||
# Most sites are 24 hours
|
||||
VoteDelay: 24
|
||||
|
||||
# Use to have a minute votedelay
|
||||
#VoteDelayMin: 30
|
||||
|
||||
# Require waiting until votedelay time has pasted in order to accept vote
|
||||
# Recommend: false
|
||||
WaitUntilVoteDelay: false
|
||||
|
||||
# Reset vote delay each day (for certain sites that do this)
|
||||
# Recommend: false
|
||||
VoteDelayDaily: false
|
||||
|
||||
# If true, rewards can be executed offline (requires ForceOffline to be true in the reward)
|
||||
# Setting this to true will execute the reward offline, NOT WHEN THE PLAYER IS OFFLINE
|
||||
# Setting this to true will execute the reward offline while the player is offline
|
||||
# This basiclly disables offline voting if set to true, don't misinterpret this option
|
||||
ForceOffline: false
|
||||
|
||||
# VoteSite Material for GUI's
|
||||
# VoteSite Material for some GUI's
|
||||
# Removing this may result in an error, required on each site
|
||||
Item:
|
||||
DisplayItem:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Rewards to give
|
||||
# https://github.com/Ben12345rocks/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
|
||||
Items:
|
||||
item1:
|
||||
Material: DIAMOND
|
||||
Amount: 1
|
||||
|
||||
Messages:
|
||||
Player: 'You voted'
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.bungee.VotingPluginBungee
|
||||
author: BenCodez
|
||||
@@ -0,0 +1,67 @@
|
||||
# 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
|
||||
# Maxium size of caching mysql
|
||||
# -1 for no limit
|
||||
# Affecting this value may affect performance
|
||||
MaxSize: -1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
#PublicKeyRetrieval: false
|
||||
|
||||
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 if not using SOCKETS method
|
||||
BlockedServers:
|
||||
- hub
|
||||
|
||||
# What type of bungee setup
|
||||
# Requires restart and set on all servers
|
||||
# https://github.com/Ben12345rocks/VotingPlugin/wiki/Bungeecoord-Setups
|
||||
# Available:
|
||||
# SOCKETS
|
||||
# PLUGINMESSAGING
|
||||
# MYSQL
|
||||
BungeeMethod: PLUGINMESSAGING
|
||||
|
||||
FallBackServer: factions
|
||||
|
||||
AllowUnJoined: false
|
||||
|
||||
# ----------------------------
|
||||
# SOCKET METHOD Settings
|
||||
# ----------------------------
|
||||
|
||||
# Tell servers to broadcast
|
||||
# For socket method
|
||||
Broadcast: true
|
||||
|
||||
# Bungee communication, Add this to each spigot server
|
||||
# For socket method
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add each spigot server here
|
||||
# For socket method
|
||||
SpigotServers:
|
||||
lobby:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
factions:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1999
|
||||
@@ -1,10 +1,11 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.Ben12345rocks.VotingPlugin.Main
|
||||
main: com.bencodez.votingplugin.VotingPluginMain
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: Ben12345rocks
|
||||
softdepend: [AdvancedCore]
|
||||
author: BenCodez
|
||||
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
@@ -27,9 +28,6 @@ commands:
|
||||
votetop:
|
||||
description: See top voters
|
||||
aliases: vtop
|
||||
voteinfo:
|
||||
description: See player info
|
||||
aliases: vinfo
|
||||
votetoday:
|
||||
description: See who voted today
|
||||
aliases: vtoday
|
||||
@@ -57,21 +55,30 @@ commands:
|
||||
votestreak:
|
||||
description: A command
|
||||
aliases: vstreak
|
||||
votetogglebroadcast:
|
||||
description: A command
|
||||
aliases: vtogglebroadcast
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votegivereward:
|
||||
votelist:
|
||||
description: A command
|
||||
voteselectChoiceReward:
|
||||
aliases: vlist
|
||||
voteall:
|
||||
description: A command
|
||||
aliases: vall
|
||||
votechoices:
|
||||
description: A command
|
||||
alaises: vchoices
|
||||
votegivepoints:
|
||||
description: A command
|
||||
alaises: vgivepoints
|
||||
adminvotehelp:
|
||||
description: Open adminvote help
|
||||
aliases: avhelp
|
||||
adminvote?:
|
||||
description: Open adminvote help
|
||||
aliases: av?
|
||||
adminvoteconvert:
|
||||
description: A command
|
||||
adminvotereport:
|
||||
description: Command Alias
|
||||
aliases: avreport
|
||||
@@ -84,6 +91,9 @@ commands:
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
adminvotetestreward:
|
||||
description: Command Alias
|
||||
aliases: avtestreward
|
||||
adminvoteversion:
|
||||
description: Command Alias
|
||||
aliases: avversion
|
||||
@@ -93,81 +103,58 @@ commands:
|
||||
adminvoterewards:
|
||||
description: Command Alias
|
||||
aliases: avrewards
|
||||
adminvotereward:
|
||||
description: Command Alias
|
||||
aliases: avreward
|
||||
adminvoteuuid:
|
||||
description: Command Alias
|
||||
aliases: avuuid
|
||||
adminvotereset:
|
||||
description: Command Alias
|
||||
aliases: avreset
|
||||
adminvotevotesite:
|
||||
description: Command Alias
|
||||
aliases: avvotesite
|
||||
adminvoteconfig:
|
||||
description: Command Alias
|
||||
aliases: avconfig
|
||||
adminvoteserverdata:
|
||||
description: Command Alias
|
||||
aliases: avserverdata
|
||||
adminvotesettotal:
|
||||
description: Command Alias
|
||||
aliases: avsettotal
|
||||
adminvoteupdatecheck:
|
||||
description: Command Alias
|
||||
aliases: avupdatecheck
|
||||
adminvotevote:
|
||||
description: Command Alias
|
||||
aliases: [avvote, fakevote]
|
||||
adminvoteTriggerPlayerVoteEvent:
|
||||
description: Command Alias
|
||||
aliases: avTriggerPlayerVoteEvent
|
||||
adminvotesetpoints:
|
||||
description: Command Alias
|
||||
aliases: avsetpoints
|
||||
adminvoteaddpoints:
|
||||
description: Command Alias
|
||||
aliases: avaddpoints
|
||||
adminvotegui:
|
||||
description: Command Alias
|
||||
aliases: avgui
|
||||
votesetrequestmethod:
|
||||
description: Command Alias
|
||||
aliases: [vsetrequestmethod, setrequesetmethod]
|
||||
adminvotegivereward:
|
||||
description: Command Alias
|
||||
aliases: avgivereward
|
||||
adminvoteusers:
|
||||
description: Command Alias
|
||||
aliases: avusers
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
aliases: avClearTotal
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
aliases: avClearTotal
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteConvertFrom:
|
||||
description: Command Alias
|
||||
aliases: avConvertFrom
|
||||
adminvoteRemovePoints:
|
||||
description: Command Alias
|
||||
aliases: avRemovePoints
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteSetVotePartyCount:
|
||||
description: Command Alias
|
||||
aliases: avSetVotePartyCount
|
||||
adminvoteChoices:
|
||||
description: Command Alias
|
||||
aliases: avChoices
|
||||
adminvoteReloadAll:
|
||||
description: Command Alias
|
||||
aliases: avReloadAll
|
||||
adminvotePermsPlayer:
|
||||
description: Command Alias
|
||||
aliases: avPermsPlayer
|
||||
adminvoteResyncMilestonesAlreadyGiven:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestonesAlreadyGiven
|
||||
voteSetPrimaryAccount:
|
||||
description: Command Alias
|
||||
adminvoteClearOfflineVotes:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineVotes
|
||||
@@ -198,13 +185,47 @@ commands:
|
||||
adminvoteJavascript:
|
||||
description: Command Alias
|
||||
aliases: avJavascript
|
||||
adminvoteStatus:
|
||||
description: Command Alias
|
||||
aliases: avStatus
|
||||
adminvoteTest:
|
||||
description: Command Alias
|
||||
aliases: avTest
|
||||
adminvotePlaceholders:
|
||||
description: Command Alias
|
||||
aliases: avPlaceholders
|
||||
adminvoteDownloadJenkins:
|
||||
description: Command Alias
|
||||
aliases: avDownloadJenkins
|
||||
adminvoteForceVoteParty:
|
||||
description: Command Alias
|
||||
aliases: avForceVoteParty
|
||||
adminvoteSetRequestMethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
adminvoteUser:
|
||||
description: Command Alias
|
||||
aliases: avUser
|
||||
adminvoteCurrentPluginTime:
|
||||
description: Command Alias
|
||||
aliases: avCurrentPluginTime
|
||||
adminvoteResetPoints:
|
||||
description: Command Alias
|
||||
aliases: avResetPoints
|
||||
adminvoteVotePartyExtraRequired:
|
||||
description: Command Alias
|
||||
aliases: avVotePartyExtraRequired
|
||||
adminvoteRunCMD:
|
||||
description: Command Alias
|
||||
aliases: avRunCMD
|
||||
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
VotingPlugin.Mod:
|
||||
description: Allows mod access player commands
|
||||
description: Allows mod commands
|
||||
VotingPlugin.Admin:
|
||||
description: Allows admin access player commands
|
||||
description: Allows admincommands
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Allows players to get remined on login if they can vote
|
||||
default: true
|
||||
@@ -217,4 +238,11 @@ permissions:
|
||||
VotingPlugin.NoRemind:
|
||||
description: Ignore vote reminding
|
||||
default: false
|
||||
VotingPlugin.Sign.Create:
|
||||
description: Permission to create sign
|
||||
VotingPlugin.Admin.GenerateServiceSite:
|
||||
description: Permission for generating votesite message
|
||||
VotingPlugin.Login.RemindVotes.Any:
|
||||
description: Remind if player can vote on any website, rather than all
|
||||
default: false
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
time: '${timestamp}'
|
||||
profile: ${build.profile.id}
|
||||
+193
-30
@@ -1,15 +1,17 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.12.6</version>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>6.1.3</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>VotingPlugin</name>
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<github.global.server>github</github.global.server>
|
||||
<project.build.sourceEncoding>Cp1252</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
@@ -25,6 +27,8 @@
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>bungee.yml</include>
|
||||
<include>votingpluginversion.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
@@ -33,6 +37,34 @@
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<versionRange>[1,)</versionRange>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -44,6 +76,25 @@
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.12.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>delombok</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<addOutputDirectory>false</addOutputDirectory>
|
||||
<outputDirectory>${project.basedir}/target/delombok</outputDirectory>
|
||||
<sourceDirectory>${project.basedir}/src</sourceDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
@@ -54,26 +105,30 @@
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>com.Ben12345rocks.AdvancedCore</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.AdvancedCore</shadedPattern>
|
||||
<pattern>com.bencodez.advancedcore</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.advancedcore</shadedPattern>
|
||||
</relocation>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.mrten.mysqlapi</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.mysqlapi</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.mysqlapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.HikariCP</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.HikariCP</shadedPattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.HikariCP</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j.slf4j-simple</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.slf4j-simple</shadedPattern>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>xyz.upperlevel.spigot.book</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.upperlevel.book</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
@@ -92,7 +147,6 @@
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
@@ -108,6 +162,9 @@
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@@ -132,12 +189,37 @@
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<repositoryName>VotingPlugin</repositoryName>
|
||||
<repositoryOwner>Ben12345rocks</repositoryOwner>
|
||||
<repositoryOwner>BenCodez</repositoryOwner>
|
||||
<server>github</server>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${user.home}/Documents/Test Server/plugins</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/target</directory>
|
||||
<includes>
|
||||
<include>VotingPlugin.jar</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
<overwrite>true</overwrite>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
@@ -148,20 +230,33 @@
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>maven-central</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bintray-repo</id>
|
||||
<url>https://dl.bintray.com/nuvotifier/maven/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.Ben12345rocks</groupId>
|
||||
<artifactId>AdvancedCore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- <dependency> <groupId>com.Ben12345rocks</groupId> <artifactId>AdvancedCore</artifactId>
|
||||
<version>LATEST</version> <scope>compile</scope> </dependency> -->
|
||||
<!--<dependency> <groupId>com.github.Ben12345rocks</groupId> <artifactId>AdvancedCore</artifactId>
|
||||
<version>3.0-SNAPSHOT</version> </dependency> -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.12.2-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@@ -172,18 +267,86 @@
|
||||
<systemPath>${project.basedir}/Jars/Votifier.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.swifteh</groupId>
|
||||
<artifactId>GAL</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/GAListener.jar</systemPath>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mythicacraft</groupId>
|
||||
<artifactId>voteroulette</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vexsoftware</groupId>
|
||||
<artifactId>nuvotifier-universal</artifactId>
|
||||
<version>2.3.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tchristofferson</groupId>
|
||||
<artifactId>ConfigUpdater</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>4.5.6</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>MVdWPlaceholderAPI</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/VoteRoulette.jar</systemPath>
|
||||
<systemPath>${project.basedir}/Jars/MVdWPlaceholderAPI.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>prod</id>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
<properties>
|
||||
<build.profile.id>prod</build.profile.id>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.bencodez</groupId>
|
||||
<artifactId>advancedcore</artifactId>
|
||||
<version>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>prod2</id>
|
||||
<properties>
|
||||
<build.profile.id>prod2</build.profile.id>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>AdvancedCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dev</id>
|
||||
<properties>
|
||||
<build.profile.id>dev</build.profile.id>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>AdvancedCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,854 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Scoreboards.SimpleScoreboard;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Commands.
|
||||
*/
|
||||
public class Commands {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The instance. */
|
||||
static Commands instance = new Commands();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of Commands.
|
||||
*
|
||||
* @return single instance of Commands
|
||||
*/
|
||||
public static Commands getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*/
|
||||
private Commands() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public Commands(Main plugin) {
|
||||
Commands.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin help.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
* @param page
|
||||
* the page
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelp(CommandSender sender, int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> text = adminHelpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
if ((text.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add(StringUtils.getInstance().stringToComp("&3&lVotingPlugin Admin Help " + (page + 1) + "/" + maxPage));
|
||||
msg.add(StringUtils.getInstance().stringToComp("&3&l() = Needed"));
|
||||
msg.add(StringUtils.getInstance().stringToComp("&3&lAliases: adminvote, av"));
|
||||
|
||||
for (int i = pagesize * page; (i < text.size()) && (i < ((page + 1) * pagesize) - 1); i++) {
|
||||
msg.add(text.get(i));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin help text.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
|
||||
boolean requirePerms = Config.getInstance().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.adminVoteCommand) {
|
||||
if (sender.hasPermission(cmdHandle.getPerm()) && requirePerms) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
} else {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
msg.add(unsorted.get(cmd));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
public String[] best(CommandSender sender, String name) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add(config.getFormatCommandsVoteBestTitle());
|
||||
msg.addAll(config.getFormatCommandsVoteBestLines());
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("HighestDailyTotal", "" + user.getHighestDailyTotal());
|
||||
placeholders.put("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal());
|
||||
placeholders.put("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal());
|
||||
|
||||
placeholders.put("player", name);
|
||||
|
||||
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.getInstance().convert(ArrayUtils.getInstance().colorize(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* Command vote today.
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] commandVoteToday(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
String[] voteToday = voteToday();
|
||||
|
||||
int maxPage = voteToday.length / pagesize;
|
||||
if ((voteToday.length % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add("&cToday's Votes " + page + "/" + maxPage);
|
||||
msg.add("&cPlayerName : VoteSite : Time");
|
||||
page--;
|
||||
|
||||
for (int i = pagesize * page; (i < voteToday.length) && (i < ((page + 1) * pagesize)); i++) {
|
||||
msg.add(voteToday[i]);
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public String[] listPerms(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&c&lCommand : Permissions (seperated by |)");
|
||||
|
||||
for (CommandHandler handle : plugin.voteCommand) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
msg.add("&c" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : false");
|
||||
}
|
||||
} else {
|
||||
msg.add(handle.getHelpLineCommand("/vote") + " : " + handle.getPerm());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.adminVoteCommand) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
msg.add("&c" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : false");
|
||||
}
|
||||
} else {
|
||||
msg.add(handle.getHelpLineCommand("/av") + " : " + handle.getPerm());
|
||||
}
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
if (sender instanceof Player) {
|
||||
if (sender.hasPermission(perm)) {
|
||||
msg.add("&a" + perm.getName() + " : true");
|
||||
} else {
|
||||
msg.add("&c" + perm.getName() + " : false");
|
||||
}
|
||||
} else {
|
||||
msg.add(perm.getName());
|
||||
}
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public void listPerms(CommandSender sender, String player, int page) {
|
||||
Player p = Bukkit.getPlayer(player);
|
||||
if (p != null) {
|
||||
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
|
||||
for (CommandHandler handle : plugin.voteCommand) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
msg.add("&c" + handle.getHelpLineCommand("/vote") + " : " + handle.getPerm() + " : false");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.adminVoteCommand) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&a" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : true");
|
||||
} else {
|
||||
msg.add("&c" + handle.getHelpLineCommand("/av") + " : " + handle.getPerm() + " : false");
|
||||
}
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
if (p.hasPermission(perm)) {
|
||||
msg.add("&a" + perm.getName() + " : true");
|
||||
} else {
|
||||
msg.add("&c" + perm.getName() + " : false");
|
||||
}
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
|
||||
int maxPage = msg.size() / pagesize;
|
||||
if ((msg.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
text.add("&c&lCommand : Permissions (seperated by |) " + page + "/" + maxPage);
|
||||
|
||||
for (int i = pagesize * page - pagesize; i < msg.size() && i < pagesize * page; i++) {
|
||||
text.add(msg.get(i));
|
||||
}
|
||||
sender.sendMessage(ArrayUtils.getInstance().convert(ArrayUtils.getInstance().colorize(text)));
|
||||
} else {
|
||||
sender.sendMessage(StringUtils.getInstance().colorize("&cPlayer not online: " + player));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Player info.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] playerInfo(User user) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
// title
|
||||
msg.add("&cPlayer '" + user.getPlayerName() + "' Info");
|
||||
|
||||
// last vote
|
||||
msg.addAll(ArrayUtils.getInstance().convert(voteCommandLast(user)));
|
||||
|
||||
// next vote
|
||||
msg.addAll(ArrayUtils.getInstance().convert(voteCommandNext(user)));
|
||||
|
||||
// total
|
||||
msg.addAll(ArrayUtils.getInstance().convert(voteCommandTotal(user)));
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send top voter monthly score board.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterAllTimeScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterAllTime.keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = StringUtils.getInstance().colorize(config.getFormatCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page).replace("%maxpages%", "" + pageSize).replace("%Top%", "All"));
|
||||
|
||||
SimpleScoreboard scoreboard = new SimpleScoreboard(title);
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterAllTime.get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send top voter daily score board.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterDailyScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterDaily.keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = StringUtils.getInstance().colorize(config.getFormatCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page).replace("%maxpages%", "" + pageSize).replace("%Top%", "Daily"));
|
||||
|
||||
SimpleScoreboard scoreboard = new SimpleScoreboard(title);
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterDaily.get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send top voter monthly score board.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterMonthlyScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterMonthly.keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = StringUtils.getInstance().colorize(config.getFormatCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page).replace("%maxpages%", "" + pageSize).replace("%Top%", "Monthly"));
|
||||
|
||||
SimpleScoreboard scoreboard = new SimpleScoreboard(title);
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterMonthly.get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
}
|
||||
}, 90);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send top voter weekly score board.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendTopVoterWeeklyScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
|
||||
int pageSize = (users.size() / pagesize);
|
||||
if ((users.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = StringUtils.getInstance().colorize(config.getFormatCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page).replace("%maxpages%", "" + pageSize).replace("%Top%", "Weekly"));
|
||||
|
||||
SimpleScoreboard scoreboard = new SimpleScoreboard(title);
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < users.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
scoreboard.add("" + (i + 1) + ": " + users.get(i).getPlayerName(),
|
||||
plugin.topVoterWeekly.get(users.get(i)));
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
}
|
||||
}, 90);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send vote today score board.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param page
|
||||
* the page
|
||||
*/
|
||||
public void sendVoteTodayScoreBoard(Player player, int page) {
|
||||
if (AdvancedCoreHook.getInstance().isSendScoreboards()) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
|
||||
String[] voteToday = voteToday();
|
||||
|
||||
int maxPage = voteToday.length / pagesize;
|
||||
if ((voteToday.length % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
SimpleScoreboard scoreboard = new SimpleScoreboard("&cToday's Votes " + page + "/" + maxPage);
|
||||
|
||||
for (int i = pagesize * page; (i < voteToday.length) && (i < ((page + 1) * pagesize)); i++) {
|
||||
scoreboard.add(voteToday[i], i);
|
||||
}
|
||||
scoreboard.build();
|
||||
scoreboard.send(player);
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
SimpleScoreboard clear = new SimpleScoreboard("Empty");
|
||||
clear.send(player);
|
||||
}
|
||||
}, 90);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public String[] streak(CommandSender sender, String name) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add(config.getFormatCommandsVoteStreakTitle());
|
||||
msg.addAll(config.getFormatCommandsVoteStreakLines());
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("DailyStreak", "" + user.getDayVoteStreak());
|
||||
placeholders.put("WeeklyStreak", "" + user.getWeekVoteStreak());
|
||||
placeholders.put("MonthlyStreak", "" + user.getMonthVoteStreak());
|
||||
|
||||
placeholders.put("BestDailyStreak", "" + user.getBestDayVoteStreak());
|
||||
placeholders.put("BestWeeklyStreak", "" + user.getBestWeekVoteStreak());
|
||||
placeholders.put("BestMonthlyStreak", "" + user.getBestMonthVoteStreak());
|
||||
|
||||
placeholders.put("player", name);
|
||||
|
||||
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.getInstance().convert(ArrayUtils.getInstance().colorize(msg));
|
||||
}
|
||||
|
||||
public void updateVoteToday(ArrayList<User> users) {
|
||||
plugin.voteToday.clear();
|
||||
|
||||
for (User user : users) {
|
||||
HashMap<VoteSite, LocalDateTime> times = new HashMap<VoteSite, LocalDateTime>();
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if ((LocalDateTime.now().getDayOfMonth() == MiscUtils.getInstance().getDayFromMili(time))
|
||||
&& (LocalDateTime.now().getMonthValue() == MiscUtils.getInstance().getMonthFromMili(time))
|
||||
&& (LocalDateTime.now().getYear() == MiscUtils.getInstance().getYearFromMili(time))) {
|
||||
|
||||
times.put(voteSite, LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()));
|
||||
|
||||
}
|
||||
}
|
||||
if (times.keySet().size() > 0) {
|
||||
plugin.voteToday.put(user, times);
|
||||
}
|
||||
|
||||
}
|
||||
plugin.debug("Updated VoteToday");
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote command last.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] voteCommandLast(User user) {
|
||||
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(StringUtils.getInstance().replaceIgnoreCase(config.getFormatCommandsVoteLastTitle(), "%player%",
|
||||
playerName));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
msg.add(voteCommandLastLine(user, voteSite));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote command last date.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
* @return the string
|
||||
*/
|
||||
public String voteCommandLastDate(User user, VoteSite voteSite) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time > 0) {
|
||||
Date date = new Date(time);
|
||||
String timeString = new SimpleDateFormat(config.getFormatTimeFormat()).format(date);
|
||||
return timeString;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public String voteCommandLastLine(User user, VoteSite voteSite) {
|
||||
String timeString = voteCommandLastDate(user, voteSite);
|
||||
|
||||
return config.getFormatCommandsVoteLastLine().replace("%Month% %Day%, %Year% %Hour%:%Minute% %ampm%", "%time%")
|
||||
.replace("%time%", timeString).replace("%SiteName%", voteSite.getDisplayName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote command next.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] voteCommandNext(User user) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(StringUtils.getInstance().colorize(StringUtils.getInstance()
|
||||
.replaceIgnoreCase(config.getFormatCommandsVoteNextTitle(), "%player%", playerName)));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
|
||||
String msgLine = config.getFormatCommandsVoteNextLayout();
|
||||
|
||||
msgLine = StringUtils.getInstance().replaceIgnoreCase(msgLine, "%info%",
|
||||
voteCommandNextInfo(user, voteSite));
|
||||
|
||||
msgLine = StringUtils.getInstance().replaceIgnoreCase(msgLine, "%SiteName%", voteSite.getDisplayName());
|
||||
msg.add(StringUtils.getInstance().colorize(msgLine));
|
||||
|
||||
}
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote command next info.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
* @return the string
|
||||
*/
|
||||
public String voteCommandNextInfo(User user, VoteSite voteSite) {
|
||||
String info = new String();
|
||||
|
||||
long time = user.getTime(voteSite);
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
|
||||
|
||||
if (!voteSite.isVoteDelayDaily()) {
|
||||
double votedelay = voteSite.getVoteDelay();
|
||||
if (votedelay == 0) {
|
||||
String errorMsg = config.getFormatCommandsVoteNextInfoError();
|
||||
info = errorMsg;
|
||||
} else {
|
||||
|
||||
LocalDateTime nextvote = lastVote.plusHours((long) votedelay);
|
||||
|
||||
if (time == 0 || now.isAfter(nextvote)) {
|
||||
info = config.getFormatCommandsVoteNextInfoCanVote();
|
||||
} else {
|
||||
Duration dur = Duration.between(now, nextvote);
|
||||
|
||||
long diffHours = dur.getSeconds() / (60 * 60);
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
|
||||
|
||||
String timeMsg = config.getFormatCommandsVoteNextInfoTime();
|
||||
timeMsg = StringUtils.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Long.toString(diffHours));
|
||||
timeMsg = StringUtils.getInstance().replaceIgnoreCase(timeMsg, "%minutes%",
|
||||
Long.toString(diffMinutes));
|
||||
info = timeMsg;
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (lastVote.getDayOfYear() == now.getDayOfYear() && lastVote.getYear() == now.getYear()) {
|
||||
LocalDateTime midnight = LocalDateTime.now().plusDays(1).withHour(0).withMinute(0);
|
||||
Duration dur = Duration.between(now, midnight);
|
||||
|
||||
int diffHours = (int) (dur.getSeconds() / (60 * 60));
|
||||
long diffMinutes = dur.getSeconds() / 60 - diffHours * 60;
|
||||
|
||||
String timeMsg = config.getFormatCommandsVoteNextInfoVoteDelayDaily();
|
||||
timeMsg = StringUtils.getInstance().replaceIgnoreCase(timeMsg, "%hours%", Integer.toString(diffHours));
|
||||
timeMsg = StringUtils.getInstance().replaceIgnoreCase(timeMsg, "%minutes%", Long.toString(diffMinutes));
|
||||
info = timeMsg;
|
||||
|
||||
} else {
|
||||
info = config.getFormatCommandsVoteNextInfoCanVote();
|
||||
}
|
||||
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote command total.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] voteCommandTotal(User user) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
int daily = user.getDailyTotal();
|
||||
int weekly = user.getWeeklyTotal();
|
||||
int month = user.getMonthTotal();
|
||||
int all = user.getAllTimeTotal();
|
||||
|
||||
for (String s : config.getFormatCommandsVoteTotal()) {
|
||||
String str = StringUtils.getInstance().replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
|
||||
str = StringUtils.getInstance().replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
|
||||
str = StringUtils.getInstance().replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
|
||||
str = StringUtils.getInstance().replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
|
||||
str = StringUtils.getInstance().replaceIgnoreCase(str, "%player%", user.getPlayerName());
|
||||
msg.add(str);
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote command total all.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] voteCommandTotalAll() {
|
||||
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
|
||||
int daily = 0;
|
||||
int weekly = 0;
|
||||
int month = 0;
|
||||
int all = 0;
|
||||
|
||||
for (String uuid : uuids) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
daily += user.getDailyTotal();
|
||||
weekly += user.getWeeklyTotal();
|
||||
month += user.getMonthTotal();
|
||||
all += user.getAllTimeTotal();
|
||||
}
|
||||
|
||||
for (String s : config.getFormatCommandsVoteTotalAll()) {
|
||||
String str = StringUtils.getInstance().replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
|
||||
str = StringUtils.getInstance().replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
|
||||
str = StringUtils.getInstance().replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
|
||||
str = StringUtils.getInstance().replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
|
||||
msg.add(str);
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote help text.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> texts = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
texts.add(StringUtils.getInstance().stringToComp(config.getFormatCommandsVoteHelpTitle()));
|
||||
|
||||
boolean requirePerms = config.getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.voteCommand) {
|
||||
if (cmdHandle.hasPerm(sender)) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote"));
|
||||
} else if (!requirePerms) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote"));
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
texts.add(unsorted.get(cmd));
|
||||
}
|
||||
return texts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote today.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] voteToday() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
|
||||
msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " + timeString);
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public String[] voteURLs(User user) {
|
||||
ArrayList<String> sites = new ArrayList<String>();
|
||||
|
||||
List<String> title = config.getFormatCommandsVoteText();
|
||||
if (title != null) {
|
||||
sites.addAll(title);
|
||||
}
|
||||
if (config.getFormatCommandsVoteAutoInputSites()) {
|
||||
int counter = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
counter++;
|
||||
String voteURL = voteSite.getVoteURL();
|
||||
String msg = config.getFormatCommandsVoteURLS();
|
||||
msg = StringUtils.getInstance().colorize(msg);
|
||||
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%num%", Integer.toString(counter));
|
||||
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%url%", voteURL);
|
||||
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%SiteName%", voteSite.getDisplayName());
|
||||
msg = StringUtils.getInstance().replaceIgnoreCase(msg, "%player%", user.getPlayerName());
|
||||
sites.add(msg);
|
||||
}
|
||||
}
|
||||
if (user != null) {
|
||||
HashMap<String, String> phs = new HashMap<String, String>();
|
||||
phs.put("DailyTotal", "" + user.getDailyTotal());
|
||||
phs.put("WeekTotal", "" + user.getWeeklyTotal());
|
||||
phs.put("MonthTotal", "" + user.getMonthTotal());
|
||||
phs.put("Total", "" + user.getAllTimeTotal());
|
||||
|
||||
sites = ArrayUtils.getInstance().replacePlaceHolder(sites, phs);
|
||||
}
|
||||
sites = ArrayUtils.getInstance().colorize(sites);
|
||||
return ArrayUtils.getInstance().convert(sites);
|
||||
}
|
||||
|
||||
}
|
||||
-77
@@ -1,77 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.Executers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAdminVote.
|
||||
*/
|
||||
public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
/** The instance. */
|
||||
private static CommandAdminVote instance = new CommandAdminVote();
|
||||
|
||||
/**
|
||||
* Gets the single instance of CommandAdminVote.
|
||||
*
|
||||
* @return single instance of CommandAdminVote
|
||||
*/
|
||||
public static CommandAdminVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** The config. */
|
||||
Config config = Config.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
/** The vote sites. */
|
||||
ConfigVoteSites voteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/**
|
||||
* Instantiates a new command admin vote.
|
||||
*/
|
||||
private CommandAdminVote() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command admin vote.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CommandAdminVote(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (CommandHandler commandHandler : plugin.adminVoteCommand) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,306 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.InputMethod;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequestBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListener;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class AdminGUI {
|
||||
static AdminGUI instance = new AdminGUI();
|
||||
|
||||
/**
|
||||
* Gets the single instance of Commands.
|
||||
*
|
||||
* @return single instance of Commands
|
||||
*/
|
||||
public static AdminGUI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*/
|
||||
private AdminGUI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI.
|
||||
*
|
||||
* @return ArrayList of buttons
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("&cOnly enabled sites are listed in this section");
|
||||
lore.add("&cMiddle Click to create");
|
||||
buttons.add(new BInventoryButton("&cVoteSites", ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
ConfigVoteSites.getInstance().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openAdminGUIVoteSites(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lore = new ArrayList<String>();
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE, 1, (short) 3)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().performCommand("av reload");
|
||||
}
|
||||
|
||||
});
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void loadHook() {
|
||||
for (BInventoryButton b : adminGUIButtons()) {
|
||||
com.Ben12345rocks.AdvancedCore.Commands.GUI.AdminGUI.getInstance().addButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote sites.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public void openAdminGUIVoteSites(Player player) {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
lore.add("Name: " + voteSite.getDisplayName());
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
// lore.add("Rewards: " +
|
||||
// ArrayUtils.getInstance().makeStringList(voteSite.getRewards()));
|
||||
|
||||
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote site site.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
*/
|
||||
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
|
||||
BInventory inv = new BInventory("VoteSite: " + voteSite.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", voteSite);
|
||||
|
||||
inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ArrayList<String> playerNames = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
new ValueRequestBuilder(new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
VotiferEvent.playerVote(value, site.getServiceSite(), false);
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
.allowCustomOption(true).request(event.getWhoClicked());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetPriority", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestNumber(player, "" + voteSite.getPriority(), null, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
ConfigVoteSites.getInstance().setPriority(voteSite.getKey(), value.intValue());
|
||||
player.sendMessage("Set Priority");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetServiceSite", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setServiceSite(siteName, value);
|
||||
player.sendMessage("Set ServiceSite");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetName", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
ConfigVoteSites.getInstance().setDisplayName(voteSite.getKey(), value);
|
||||
player.sendMessage("Set name");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteURL", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getVoteURL(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteURL(siteName, value);
|
||||
player.sendMessage("Set VoteURL");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteDelay", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestNumber(player, "" + voteSite.getVoteDelay(), null, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelay(siteName, value.intValue());
|
||||
player.sendMessage("Set VoteDelay");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("SetEnabled", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + ConfigVoteSites.getInstance().getVoteSiteEnabled(voteSite.getKey()),
|
||||
new BooleanListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setEnabled(siteName, value);
|
||||
player.sendMessage("Set Enabled");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
@@ -1,681 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoterHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteShop.VoteShop;
|
||||
|
||||
public class PlayerGUIs {
|
||||
static PlayerGUIs instance = new PlayerGUIs();
|
||||
|
||||
/**
|
||||
* Gets the single instance of Commands.
|
||||
*
|
||||
* @return single instance of Commands
|
||||
*/
|
||||
public static PlayerGUIs getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*/
|
||||
private PlayerGUIs() {
|
||||
}
|
||||
|
||||
public ItemBuilder getBackButton() {
|
||||
ConfigurationSection sec = Config.getInstance().getBackButton();
|
||||
if (sec != null) {
|
||||
return new ItemBuilder(sec);
|
||||
}
|
||||
return new ItemBuilder(Material.PAPER, 1).setName("&8Back to VoteGUI");
|
||||
}
|
||||
|
||||
public User getSelectedPlayer(Player player) {
|
||||
User str = (User) PlayerUtils.getInstance().getPlayerMeta(player, "SelectedPlayerGUIs");
|
||||
return str;
|
||||
}
|
||||
|
||||
public void openVoteBest(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteBestName(), "player", user.getPlayerName()));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestDayBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestWeekBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestMonthBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteGUI(Player player, User user) {
|
||||
if (user == null) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
setSelectedPlayer(player, user);
|
||||
}
|
||||
if ((!player.getName().equals(user.getPlayerName())
|
||||
&& !player.hasPermission("VotingPlugin.Commands.Vote.GUI.Other")
|
||||
&& !player.hasPermission("VotingPlugin.Mod"))
|
||||
|| (!player.hasPermission("VotingPlugin.Commands.Vote.GUI")
|
||||
&& !player.hasPermission("VotingPlugin.Player"))) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize(AdvancedCoreHook.getInstance().getFormatNoPerms()));
|
||||
return;
|
||||
}
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteGUIName(), "player", user.getPlayerName()));
|
||||
|
||||
for (String slot : Config.getInstance().getVoteGUISlots()) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteGUISlotSection(slot));
|
||||
|
||||
String[] lore = new String[1];
|
||||
|
||||
lore = ArrayUtils.getInstance().convert(Config.getInstance().getVoteGUISlotLore(slot));
|
||||
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
lore = Commands.getInstance().voteURLs(user);
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
lore = Commands.getInstance().voteCommandNext(user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
lore = Commands.getInstance().voteCommandLast(user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
lore = Commands.getInstance().voteCommandTotal(user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
String str = Config.getInstance().getVoteTopDefault();
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterMonthly(1);
|
||||
} else if (str.equalsIgnoreCase("weekly")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterWeekly(1);
|
||||
} else if (str.equalsIgnoreCase("daily")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterDaily(1);
|
||||
} else {
|
||||
lore = TopVoterHandler.getInstance().topVoterAllTime(1);
|
||||
}
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
lore = Commands.getInstance().voteToday();
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
lore = new String[] { "Click to view help" };
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("points", "" + user.getPoints());
|
||||
|
||||
builder.setPlaceholders(placeholders);
|
||||
builder.setLore(ArrayUtils.getInstance().convert(lore));
|
||||
|
||||
inv.addButton(Config.getInstance().getVoteGUISlotSlot(slot), new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
String cmd = Config.getInstance().getVoteGUISlotCommand(slot);
|
||||
User user = getSelectedPlayer(player);
|
||||
if (!cmd.equals("")) {
|
||||
player.performCommand(cmd);
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
openVoteURL(player);
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
openVoteNext(player, user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
openVoteLast(player, user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
openVoteTotal(player, user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
openVoteTop(player, null);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
openVoteToday(player);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
VoteShop.getInstance().voteShop(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteLast(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteLastName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandLastLine(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteLastBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteNext(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteNextName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandNextInfo(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteNextBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteStreak(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteStreakName(), "player", user.getPlayerName()));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteStreakBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteToday(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
|
||||
String msg = "&6" + user.getPlayerName() + " : " + voteSite.getDisplayName() + " : " + timeString;
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(user.getPlayerName(), new String[] { msg },
|
||||
MiscUtils.getInstance().setSkullOwner(user.getOfflinePlayer())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = UserManager.getInstance()
|
||||
.getVotingPluginUser(clickEvent.getClickedItem().getItemMeta().getDisplayName());
|
||||
openVoteGUI(player, user);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTodayBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteTop(Player player, TopVoter top) {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
BInventory inv = null;
|
||||
Set<Entry<User, Integer>> users = null;
|
||||
String topVoter = "";
|
||||
if (top.equals(TopVoter.Monthly)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterMonthly();
|
||||
users = plugin.topVoterMonthly.entrySet();
|
||||
} else if (top.equals(TopVoter.Weekly)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterWeekly();
|
||||
users = plugin.topVoterWeekly.entrySet();
|
||||
} else if (top.equals(TopVoter.Daily)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterDaily();
|
||||
users = plugin.topVoterDaily.entrySet();
|
||||
} else {
|
||||
topVoter = Config.getInstance().getFormatTopVoterAllTime();
|
||||
users = plugin.topVoterAllTime.entrySet();
|
||||
}
|
||||
inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteTopName(),
|
||||
"topvoter", topVoter));
|
||||
int pos = 1;
|
||||
for (Entry<User, Integer> entry : users) {
|
||||
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(MiscUtils.getInstance().setSkullOwner(entry.getKey().getOfflinePlayer()))
|
||||
.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore())
|
||||
.addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// ItemBuilder item = new ItemBuilder(clickEvent.getClickedItem());
|
||||
// String name = ChatColor.stripColor(item.getName()).split(":")[1].trim();
|
||||
String name = (String) clickEvent.getButton().getData("player");
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()));
|
||||
pos++;
|
||||
}
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Config.getInstance().getGUIVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
openVoteTop(player, cur.next());
|
||||
} else {
|
||||
openVoteTop(player, cur.prev());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(new BInventoryButton(getBackButton().setSlot(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteTotal(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTotalName(), "player", user.getPlayerName()));
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalDayTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getDailyTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalWeekTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getWeeklyTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalMonthTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getMonthTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalAllTimeTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getAllTimeTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteTotalBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote URL.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public void openVoteURL(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteURLName());
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
|
||||
int count = 0;
|
||||
if (Config.getInstance().getVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = new ItemBuilder(
|
||||
Config.getInstance().getVoteURLAlreadyVotedAllUrlsButtonItemSection());
|
||||
if (user.canVoteAll()) {
|
||||
builderAll = new ItemBuilder(Config.getInstance().getVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
|
||||
if (!builderAll.hasCustomDisplayName()) {
|
||||
builderAll.setName("&4All Voting Sites");
|
||||
}
|
||||
if (!builderAll.hasCustomLore()) {
|
||||
builderAll.setLore("&cClick Me");
|
||||
}
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builderAll) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
|
||||
Player player = event.getWhoClicked();
|
||||
player.closeInventory();
|
||||
user.sendMessage(Commands.getInstance().voteURLs(user));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteURLAlreadyVotedItemSection());
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(Config.getInstance().getVoteURLCanVoteItemSection());
|
||||
} else {
|
||||
builder.addLoreLine(Config.getInstance().getVoteURLNextVote().replace("%Info%",
|
||||
Commands.getInstance().voteCommandNextInfo(user, voteSite)));
|
||||
}
|
||||
|
||||
builder.setName(Config.getInstance().getVoteURLSiteName().replace("%Name%", voteSite.getDisplayName()));
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(
|
||||
StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteURLBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteURL(Player player, String voteSite) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
VoteSite site = plugin.getVoteSite(voteSite);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteURLSiteName(), "site", site.getDisplayName()));
|
||||
inv.setMeta(player, "VoteSite", site);
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.BOW).setName("&4URL").addLoreLine("Click to see URL")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VoteSite site = (VoteSite) clickEvent.getMeta("VoteSite");
|
||||
clickEvent.getWhoClicked().sendMessage(site.getVoteURL());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&4Next Vote")
|
||||
.addLoreLine(Commands.getInstance().voteCommandNextInfo(user, site))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
openVoteURL(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.WATCH).setName("&4Last Vote")
|
||||
.addLoreLine(Commands.getInstance().voteCommandLastLine(user, site))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
openVoteURL(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteURLBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void setSelectedPlayer(Player player, User user) {
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "SelectedPlayerGUIs", user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote reward.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param siteName
|
||||
* the site name
|
||||
*/
|
||||
public void voteReward(Player player, String siteName) {
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteRewardName());
|
||||
|
||||
if ((siteName == null) || (siteName == "")) {
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
try {
|
||||
ItemBuilder builder = voteSite.getItem();
|
||||
final VoteSite site = voteSite;
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
player.performCommand("vote reward " + site.getKey());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (String itemName : Config.getInstance().getVoteSiteItems(siteName)) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteSiteItemsSection(siteName, itemName));
|
||||
|
||||
inv.addButton(Config.getInstance().getVoteSiteItemsSlot(siteName, itemName),
|
||||
new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,58 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerInteract.
|
||||
*/
|
||||
public class PlayerInteract implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player interact.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerInteract(Main plugin) {
|
||||
PlayerInteract.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player interact.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
// plugin.debug("Checking for sign click");
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
// plugin.debug(player.getName() + " right clicked a sign");
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
UserManager.getInstance().getVotingPluginUser(player).sendMessage(sign.getRightClickMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(Main plugin) {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player login.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (event.getPlayer() == null
|
||||
|| (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() == null)) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player != null) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
if (user.getData().hasData()) {
|
||||
// give offline vote (if they voted
|
||||
// offline)
|
||||
|
||||
user.offVote();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}, 20L);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteAllSitesEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private User user;
|
||||
|
||||
/** The cancelled. */
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteAllSitesEvent(User user) {
|
||||
super();
|
||||
setUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* the user to set
|
||||
*/
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** The player. */
|
||||
private String player;
|
||||
|
||||
/** The vote site. */
|
||||
private VoteSite voteSite;
|
||||
|
||||
/** The cancelled. */
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername) {
|
||||
super();
|
||||
setPlayer(voteUsername);
|
||||
setVoteSite(voteSite);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site.
|
||||
*
|
||||
* @return the vote site
|
||||
*/
|
||||
public VoteSite getVoteSite() {
|
||||
return voteSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
public void setPlayer(String voteUsername) {
|
||||
this.player = voteUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote site.
|
||||
*
|
||||
* @param voteSite
|
||||
* the new vote site
|
||||
*/
|
||||
public void setVoteSite(VoteSite voteSite) {
|
||||
this.voteSite = voteSite;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class VotiferEvent implements Listener {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
private static Object object = new Object();
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL) {
|
||||
playerVote(playerName, voteSiteURL, true);
|
||||
}
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL, final boolean realVote) {
|
||||
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName) && !config.allowUnJoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(voteSiteURL);
|
||||
if (voteSite == null) {
|
||||
if (!Config.getInstance().getDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + voteSiteURL + "'");
|
||||
plugin.getLogger().warning(
|
||||
"Please read here on how to fix it: https://github.com/Ben12345rocks/VotingPlugin/wiki/Common-Problems");
|
||||
|
||||
ArrayList<String> services = new ArrayList<String>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger()
|
||||
.warning("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
|
||||
// vote party
|
||||
VoteParty.getInstance().vote(user, realVote);
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (config.getBroadCastVotesEnabled()) {
|
||||
if (!Config.getInstance().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
user.setTime(voteSite);
|
||||
|
||||
OtherVoteReward.getInstance().checkFirstVote(user);
|
||||
|
||||
if (user.isReminded()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
|
||||
if (user.isOnline() || voteSite.isGiveOffline()) {
|
||||
user.playerVote(voteSite, true, false);
|
||||
user.closeInv();
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(user.getOfflineVotes()));
|
||||
plugin.debug(
|
||||
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if (Config.getInstance().getCountFakeVotes() || realVote) {
|
||||
if (Config.getInstance().getAddTotals()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
|
||||
OtherVoteReward.getInstance().checkAllSites(user);
|
||||
OtherVoteReward.getInstance().checkCumualativeVotes(user);
|
||||
OtherVoteReward.getInstance().checkMilestone(user);
|
||||
|
||||
if (Config.getInstance().getClearCacheOnVote()) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().removePlayer(user.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VotiferEvent(Main plugin) {
|
||||
VotiferEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onVotiferEvent(VotifierEvent event) {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
final String voteSite = vote.getServiceName();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Recieved a vote from '" + voteSite + "' by player '" + voteUsername + "'!");
|
||||
|
||||
plugin.debug("PlayerUsername: " + voteUsername);
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String voteSiteName = plugin.getVoteSiteName(voteSite);
|
||||
|
||||
ArrayList<String> sites = configVoteSites.getVoteSitesNames();
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteName) && Config.getInstance().getAutoCreateVoteSites()) {
|
||||
plugin.getLogger()
|
||||
.warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
} else if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
plugin.getLogger().warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName), voteUsername);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
playerVote(voteUsername, voteSite, true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,942 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionDefault;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Javascript.JavascriptPlaceholderRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Logger.Logger;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Metrics.BStatsMetrics;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Metrics.MCStatsMetrics;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.CommandLoader;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Executers.CommandAdminVote;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Executers.CommandVote;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.GUI.AdminGUI;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.TabCompleter.AdminVoteTabCompleter;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.TabCompleter.VoteTabCompleter;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.BlockBreak;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerInteract;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerJoinEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.SignChange;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotingPluginUpdateEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.Signs;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoterHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.Util.Updater.CheckUpdate;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
/**
|
||||
* The Class Main.
|
||||
*/
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
/** The config. */
|
||||
public static Config config;
|
||||
|
||||
/** The config vote sites. */
|
||||
public static ConfigVoteSites configVoteSites;
|
||||
|
||||
/** The plugin. */
|
||||
public static Main plugin;
|
||||
|
||||
/** The top voter monthly. */
|
||||
public LinkedHashMap<User, Integer> topVoterAllTime;
|
||||
|
||||
/** The top voter monthly. */
|
||||
public LinkedHashMap<User, Integer> topVoterMonthly;
|
||||
|
||||
/** The top voter weekly. */
|
||||
public LinkedHashMap<User, Integer> topVoterWeekly;
|
||||
|
||||
/** The top voter daily. */
|
||||
public LinkedHashMap<User, Integer> topVoterDaily;
|
||||
|
||||
/** The updater. */
|
||||
public Updater updater;
|
||||
|
||||
/** The vote command. */
|
||||
public ArrayList<CommandHandler> voteCommand;
|
||||
|
||||
/** The admin vote command. */
|
||||
public ArrayList<CommandHandler> adminVoteCommand;
|
||||
|
||||
/** The vote sites. */
|
||||
private List<VoteSite> voteSites;
|
||||
|
||||
/** The vote today. */
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> voteToday;
|
||||
|
||||
/** The signs. */
|
||||
public ArrayList<SignHandler> signs;
|
||||
|
||||
/** The vote log. */
|
||||
public Logger voteLog;
|
||||
|
||||
private boolean update = true;
|
||||
|
||||
private boolean updateStarted = false;
|
||||
|
||||
/**
|
||||
* Check votifier.
|
||||
*/
|
||||
public void checkVotifier() {
|
||||
try {
|
||||
Class.forName("com.vexsoftware.votifier.model.VotifierEvent");
|
||||
} catch (ClassNotFoundException e) {
|
||||
plugin.getLogger()
|
||||
.warning("No VotifierEvent found, install Votifier, NuVotifier, or another Votifier plugin");
|
||||
}
|
||||
}
|
||||
|
||||
public void convertDataStorage(UserStorage from, UserStorage to) {
|
||||
if (from == null || to == null) {
|
||||
throw new RuntimeException("Invalid Storage Method");
|
||||
}
|
||||
UserStorage cur = AdvancedCoreHook.getInstance().getStorageType();
|
||||
AdvancedCoreHook.getInstance().setStorageType(from);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
HashMap<User, HashMap<String, String>> data = new HashMap<User, HashMap<String, String>>();
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
try {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
|
||||
HashMap<String, String> values = new HashMap<String, String>();
|
||||
for (String key : user.getData().getKeys()) {
|
||||
values.put(key, user.getData().getString(key));
|
||||
}
|
||||
data.put(user, values);
|
||||
debug("[Convert] Added " + uuid);
|
||||
} catch (Exception e) {
|
||||
AdvancedCoreHook.getInstance().debug(e);
|
||||
plugin.getLogger().warning("Exception occoured for '" + uuid + "': " + e.getMessage()
|
||||
+ ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getLogger().info("Finished getting data from " + from.toString());
|
||||
|
||||
AdvancedCoreHook.getInstance().setStorageType(to);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
for (Entry<User, HashMap<String, String>> entry : data.entrySet()) {
|
||||
try {
|
||||
for (Entry<String, String> values : entry.getValue().entrySet()) {
|
||||
entry.getKey().getData().setString(values.getKey(), values.getValue());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
plugin.getLogger().warning("Exception occoured for '" + entry.getKey().getUUID() + "': "
|
||||
+ e.getMessage() + ", turn debug on to see full stack traces");
|
||||
}
|
||||
}
|
||||
AdvancedCoreHook.getInstance().setStorageType(cur);
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
|
||||
plugin.getLogger().info("Finished convertting");
|
||||
}
|
||||
|
||||
public ArrayList<User> convertSet(Set<User> set) {
|
||||
return new ArrayList<User>(set);
|
||||
}
|
||||
|
||||
/**
|
||||
* Debug.
|
||||
*
|
||||
* @param message
|
||||
* the message
|
||||
*/
|
||||
public void debug(String message) {
|
||||
AdvancedCoreHook.getInstance().debug(plugin, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the user.
|
||||
*
|
||||
* @param uuid
|
||||
* the uuid
|
||||
* @return the user
|
||||
*/
|
||||
public User getUser(UUID uuid) {
|
||||
return UserManager.getInstance().getVotingPluginUser(uuid);
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return UserManager.getInstance();
|
||||
}
|
||||
|
||||
public VoteParty getVoteParty() {
|
||||
return VoteParty.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site.
|
||||
*
|
||||
* @param site
|
||||
* the site name
|
||||
* @return the vote site
|
||||
*/
|
||||
public VoteSite getVoteSite(String site) {
|
||||
String siteName = getVoteSiteName(site);
|
||||
for (VoteSite voteSite : getVoteSites()) {
|
||||
if (voteSite.getKey().equalsIgnoreCase(siteName) || voteSite.getDisplayName().equals(siteName)) {
|
||||
return voteSite;
|
||||
}
|
||||
}
|
||||
if (Config.getInstance().getAutoCreateVoteSites() && !configVoteSites.getVoteSitesNames().contains(siteName)) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
return new VoteSite(siteName.replace(".", "_"));
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site name.
|
||||
*
|
||||
* @param url
|
||||
* the url
|
||||
* @return the vote site name
|
||||
*/
|
||||
public String getVoteSiteName(String url) {
|
||||
ArrayList<String> sites = ConfigVoteSites.getInstance().getVoteSitesNames();
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
if (sites != null) {
|
||||
for (String siteName : sites) {
|
||||
String URL = ConfigVoteSites.getInstance().getServiceSite(siteName);
|
||||
if (URL != null) {
|
||||
if (URL.equalsIgnoreCase(url)) {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String siteName : sites) {
|
||||
if (siteName.equalsIgnoreCase(url)) {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
|
||||
}
|
||||
|
||||
public List<VoteSite> getVoteSites() {
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
public boolean hasVoteSite(String site) {
|
||||
String siteName = getVoteSiteName(site);
|
||||
for (VoteSite voteSite : getVoteSites()) {
|
||||
if (voteSite.getKey().equalsIgnoreCase(siteName) || voteSite.getDisplayName().equals(siteName)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void loadTimer() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
AdvancedCoreHook.getInstance().getTimer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
}, 1000, 1000 * 60 * Config.getInstance().getDelayBetweenUpdates());
|
||||
}
|
||||
}, 40L);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Load vote sites.
|
||||
*/
|
||||
public void loadVoteSites() {
|
||||
configVoteSites.setup();
|
||||
voteSites = Collections.synchronizedList(new ArrayList<VoteSite>());
|
||||
voteSites.addAll(configVoteSites.getVoteSitesLoad());
|
||||
|
||||
if (voteSites.size() == 0) {
|
||||
plugin.getLogger().warning("Detected no voting sites, this may mean something isn't properly setup");
|
||||
}
|
||||
|
||||
plugin.debug("Loaded VoteSites");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Log vote.
|
||||
*
|
||||
* @param date
|
||||
* the date
|
||||
* @param playerName
|
||||
* the player name
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
*/
|
||||
public void logVote(Date date, String playerName, String voteSite) {
|
||||
if (Config.getInstance().getLogVotesToFile()) {
|
||||
String str = new SimpleDateFormat("EEE, d MMM yyyy HH:mm").format(date);
|
||||
voteLog.logToFile(str + ": " + playerName + " voted on " + voteSite);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Metrics.
|
||||
*/
|
||||
private void metrics() {
|
||||
try {
|
||||
MCStatsMetrics metrics = new MCStatsMetrics(this);
|
||||
metrics.start();
|
||||
plugin.debug("Loaded Metrics");
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info("Can't submit metrics stats");
|
||||
}
|
||||
|
||||
BStatsMetrics metrics = new BStatsMetrics(this);
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_firstvote") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(ConfigVoteSites.getInstance().getData(),
|
||||
ConfigVoteSites.getInstance().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getAllSitesRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (Config.getInstance().getCumulativeVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
for (String cum : Config.getInstance().getCumulativeVotes()) {
|
||||
if (Config.getInstance().getCumulativeRewardEnabled(Integer.parseInt(cum))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_voteparty") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (!Config.getInstance().getVotePartyEnabled()) {
|
||||
return "False";
|
||||
} else {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_milestone") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (Config.getInstance().getMilestoneVotes().size() == 0) {
|
||||
return "False";
|
||||
} else {
|
||||
for (String milestone : Config.getInstance().getMilestoneVotes()) {
|
||||
if (Config.getInstance().getMilestoneRewardEnabled(Integer.parseInt(milestone))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
for (String s : Config.getInstance().getVoteStreakVotes("Day")) {
|
||||
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled("Day", s)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getVoteStreakRewardsPath("Day", s))) {
|
||||
return "True";
|
||||
}
|
||||
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakweek") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
for (String s : Config.getInstance().getVoteStreakVotes("Week")) {
|
||||
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled("Week", s)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getVoteStreakRewardsPath("Week", s))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakmonth") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
for (String s : Config.getInstance().getVoteStreakVotes("Month")) {
|
||||
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled("Month", s)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getVoteStreakRewardsPath("Month", s))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofsites") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.voteSites.size();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + RewardHandler.getInstance().getRewards().size();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getAutoCreateVoteSites();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("sendscoreboards") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getSendScoreboards();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofuser") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size();
|
||||
int num = total / 100;
|
||||
num = num * 100;
|
||||
int num2 = (total + 100) / 100;
|
||||
num2 = num2 * 100;
|
||||
return "" + num + "-" + num2;
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return Config.getInstance().getDataStorage().toUpperCase();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getDisableCheckOnWorldChange();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votereminding_enabled") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getVoteRemindingEnabled();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Today") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIToday();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_TopVoter") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUITopVoter();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Last") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUILast();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Next") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUINext();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Total") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUITotal();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Vote") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIVote();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Best") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIBest();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("UseGUI_Streak") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getCommandsUseGUIStreak();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getLoadTopVoterMonthly();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getLoadTopVoterWeekly();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + Config.getInstance().getLoadTopVoterDaily();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().storeSigns();
|
||||
}
|
||||
}, 0);
|
||||
HandlerList.unregisterAll(plugin);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
|
||||
setupFiles();
|
||||
loadVoteSites();
|
||||
updateAdvancedCoreHook();
|
||||
AdvancedCoreHook.getInstance().loadHook(this);
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
debug("UseBatchUpdates: " + AdvancedCoreHook.getInstance().getMysql().isUseBatchUpdates());
|
||||
}
|
||||
registerCommands();
|
||||
registerEvents();
|
||||
checkVotifier();
|
||||
|
||||
CheckUpdate.getInstance().startUp();
|
||||
|
||||
VoteReminding.getInstance().loadRemindChecking();
|
||||
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().loadSigns();
|
||||
}
|
||||
});
|
||||
|
||||
topVoterMonthly = new LinkedHashMap<User, Integer>();
|
||||
topVoterWeekly = new LinkedHashMap<User, Integer>();
|
||||
topVoterDaily = new LinkedHashMap<User, Integer>();
|
||||
voteToday = new LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>>();
|
||||
topVoterAllTime = new LinkedHashMap<User, Integer>();
|
||||
|
||||
voteLog = new Logger(plugin, new File(plugin.getDataFolder() + File.separator + "Log", "votelog.txt"));
|
||||
|
||||
AdminGUI.getInstance().loadHook();
|
||||
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
VoteParty.getInstance().check();
|
||||
}
|
||||
VoteParty.getInstance().register();
|
||||
|
||||
TopVoterHandler.getInstance().register();
|
||||
|
||||
metrics();
|
||||
|
||||
AdvancedCoreHook.getInstance().getJavascriptEngineRequests().add(new JavascriptPlaceholderRequest("User") {
|
||||
|
||||
@Override
|
||||
public Object getObject(OfflinePlayer player) {
|
||||
return getUserManager().getVotingPluginUser(player);
|
||||
}
|
||||
});
|
||||
|
||||
loadTimer();
|
||||
|
||||
plugin.getLogger().info("Enabled VotingPlugin " + plugin.getDescription().getVersion());
|
||||
|
||||
ArrayList<String> services = ServerData.getInstance().getServiceSites();
|
||||
for (VoteSite site : getVoteSites()) {
|
||||
if (!site.hasRewards()) {
|
||||
plugin.getLogger().warning("No rewards detected for the site: " + site.getKey()
|
||||
+ ". See https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards on how to add rewards");
|
||||
}
|
||||
|
||||
boolean contains = false;
|
||||
for (String service : services) {
|
||||
if (service.equalsIgnoreCase(site.getServiceSite())) {
|
||||
contains = true;
|
||||
}
|
||||
}
|
||||
if (!contains) {
|
||||
plugin.getLogger().warning("No vote has been recieved from " + site.getServiceSite()
|
||||
+ ", may be an invalid service site. Vote on the site and look in console for a service site, if you get nothing then there is an issue with votifier");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterAllTime() {
|
||||
return topVoterAllTime;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterMonthly() {
|
||||
return topVoterMonthly;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterWeekly() {
|
||||
return topVoterWeekly;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> getTopVoterDaily() {
|
||||
return topVoterDaily;
|
||||
}
|
||||
|
||||
public Updater getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getVoteCommand() {
|
||||
return voteCommand;
|
||||
}
|
||||
|
||||
public ArrayList<CommandHandler> getAdminVoteCommand() {
|
||||
return adminVoteCommand;
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, HashMap<VoteSite, LocalDateTime>> getVoteToday() {
|
||||
return voteToday;
|
||||
}
|
||||
|
||||
public ArrayList<SignHandler> getSigns() {
|
||||
return signs;
|
||||
}
|
||||
|
||||
public Logger getVoteLog() {
|
||||
return voteLog;
|
||||
}
|
||||
|
||||
public boolean isUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
public boolean isUpdateStarted() {
|
||||
return updateStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register commands.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
CommandLoader.getInstance().loadCommands();
|
||||
CommandLoader.getInstance().loadAliases();
|
||||
|
||||
// /vote, /v
|
||||
getCommand("vote").setExecutor(new CommandVote(this));
|
||||
getCommand("vote").setTabCompleter(new VoteTabCompleter());
|
||||
// getCommand("v").setExecutor(new CommandVote(this));
|
||||
// getCommand("v").setTabCompleter(new VoteTabCompleter());
|
||||
|
||||
// /adminvote, /av
|
||||
getCommand("adminvote").setExecutor(new CommandAdminVote(this));
|
||||
getCommand("adminvote").setTabCompleter(new AdminVoteTabCompleter());
|
||||
getCommand("av").setExecutor(new CommandAdminVote(this));
|
||||
getCommand("av").setTabCompleter(new AdminVoteTabCompleter());
|
||||
|
||||
Permission perm = Bukkit.getPluginManager().getPermission("VotingPlugin.Player");
|
||||
if (perm != null) {
|
||||
if (Config.getInstance().getGiveDefaultPermission()) {
|
||||
perm.setDefault(PermissionDefault.TRUE);
|
||||
} else {
|
||||
perm.setDefault(PermissionDefault.OP);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Loaded Commands");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Register events.
|
||||
*/
|
||||
private void registerEvents() {
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
pm.registerEvents(new PlayerJoinEvent(this), this);
|
||||
pm.registerEvents(new VotiferEvent(this), this);
|
||||
|
||||
pm.registerEvents(new SignChange(this), this);
|
||||
|
||||
pm.registerEvents(new BlockBreak(this), this);
|
||||
|
||||
pm.registerEvents(new PlayerInteract(this), this);
|
||||
|
||||
pm.registerEvents(new VotingPluginUpdateEvent(this), this);
|
||||
|
||||
plugin.debug("Loaded Events");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload.
|
||||
*/
|
||||
public void reload() {
|
||||
setUpdate(true);
|
||||
config.reloadData();
|
||||
configVoteSites.reloadData();
|
||||
updateAdvancedCoreHook();
|
||||
plugin.loadVoteSites();
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
AdvancedCoreHook.getInstance().reload();
|
||||
// loadTimer();
|
||||
|
||||
}
|
||||
|
||||
public void setUpdate(boolean update) {
|
||||
this.update = update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup files.
|
||||
*/
|
||||
public void setupFiles() {
|
||||
try {
|
||||
config = Config.getInstance();
|
||||
config.setup();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load Config.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
try {
|
||||
configVoteSites = ConfigVoteSites.getInstance();
|
||||
configVoteSites.setup();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
plugin.getLogger().severe("Failed to load VoteSites.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}, 10);
|
||||
}
|
||||
|
||||
plugin.debug("Loaded Files");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update.
|
||||
*/
|
||||
public void update() {
|
||||
if (update && plugin != null && !updateStarted) {
|
||||
updateStarted = true;
|
||||
update = false;
|
||||
|
||||
synchronized (plugin) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
if (AdvancedCoreHook.getInstance().getMysql() == null) {
|
||||
plugin.debug("MySQL not loaded yet");
|
||||
return;
|
||||
} else if (Config.getInstance().getClearCacheOnUpdate()) {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCache();
|
||||
} else {
|
||||
AdvancedCoreHook.getInstance().getMysql().clearCacheBasic();
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Starting background task");
|
||||
long time = System.currentTimeMillis();
|
||||
try {
|
||||
ArrayList<String> uuids = UserManager.getInstance().getAllUUIDs();
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
for (String uuid : uuids) {
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
users.add(user);
|
||||
// AdvancedCoreHook.getInstance().extraDebug("Loading " + uuid);
|
||||
// java.lang.Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
update = false;
|
||||
long time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Finished loading player data in " + time1 + " seconds, " + users.size() + " users");
|
||||
TopVoterHandler.getInstance().updateTopVoters(users);
|
||||
Commands.getInstance().updateVoteToday(users);
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UserManager.getInstance().getVotingPluginUser(player).offVote();
|
||||
}
|
||||
time1 = ((System.currentTimeMillis() - time) / 1000);
|
||||
plugin.debug("Background task finished in " + time1 + " seconds");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
plugin.getLogger().info("Looks like something went wrong.");
|
||||
}
|
||||
}
|
||||
|
||||
updateStarted = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateAdvancedCoreHook() {
|
||||
AdvancedCoreHook.getInstance().getJavascriptEngine().put("VotingPlugin", this);
|
||||
AdvancedCoreHook.getInstance().allowDownloadingFromSpigot(15358);
|
||||
AdvancedCoreHook.getInstance().setConfigData(Config.getInstance().getData());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
|
||||
public enum TopVoter {
|
||||
AllTime, Monthly, Weekly, Daily;
|
||||
|
||||
public static TopVoter getDefault() {
|
||||
TopVoter top = getTopVoter(Config.getInstance().getVoteTopDefault());
|
||||
if (top != null) {
|
||||
return top;
|
||||
}
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public static TopVoter getTopVoter(String str) {
|
||||
for (TopVoter value : values()) {
|
||||
if (value.toString().equalsIgnoreCase(str)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int next = i + 1;
|
||||
if (next > list.size() - 1) {
|
||||
next = 0;
|
||||
}
|
||||
return TopVoter.values()[next];
|
||||
}
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
public TopVoter prev() {
|
||||
switch (this) {
|
||||
case AllTime:
|
||||
return Daily;
|
||||
case Daily:
|
||||
return Weekly;
|
||||
case Monthly:
|
||||
return AllTime;
|
||||
case Weekly:
|
||||
return Monthly;
|
||||
default:
|
||||
return AllTime;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,800 +1,30 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class User.
|
||||
*/
|
||||
public class User extends com.Ben12345rocks.AdvancedCore.Objects.User {
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new user.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
@Deprecated
|
||||
public User(Player player) {
|
||||
super(plugin, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new user.
|
||||
*
|
||||
* @param playerName
|
||||
* the player name
|
||||
*/
|
||||
@Deprecated
|
||||
public User(String playerName) {
|
||||
super(plugin, playerName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new user.
|
||||
*
|
||||
* @param uuid
|
||||
* the uuid
|
||||
*/
|
||||
@Deprecated
|
||||
public User(UUID uuid) {
|
||||
super(plugin, uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new user.
|
||||
*
|
||||
* @param uuid
|
||||
* the uuid
|
||||
* @param loadName
|
||||
* the load name
|
||||
*/
|
||||
@Deprecated
|
||||
public User(UUID uuid, boolean loadName) {
|
||||
super(plugin, uuid, loadName);
|
||||
}
|
||||
|
||||
public void addAllTimeTotal() {
|
||||
setAllTimeTotal(getAllTimeTotal() + 1);
|
||||
}
|
||||
|
||||
public void addDayVoteStreak() {
|
||||
setDayVoteStreak(getDayVoteStreak() + 1);
|
||||
}
|
||||
|
||||
public void addMonthTotal() {
|
||||
setMonthTotal(getMonthTotal() + 1);
|
||||
}
|
||||
|
||||
public void addMonthVoteStreak() {
|
||||
setMonthVoteStreak(getMonthVoteStreak() + 1);
|
||||
}
|
||||
|
||||
public void addOfflineOtherReward(String reward) {
|
||||
ArrayList<String> offlineOtherRewards = getOfflineOtherRewards();
|
||||
offlineOtherRewards.add(reward);
|
||||
setOfflineOtherRewards(offlineOtherRewards);
|
||||
}
|
||||
|
||||
public void addOfflineVote(String voteSiteName) {
|
||||
ArrayList<String> offlineVotes = getOfflineVotes();
|
||||
offlineVotes.add(voteSiteName);
|
||||
setOfflineVotes(offlineVotes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the points.
|
||||
*/
|
||||
public void addPoints() {
|
||||
int points = Config.getInstance().getPointsOnVote();
|
||||
if (points != 0) {
|
||||
addPoints(points);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the points.
|
||||
*
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void addPoints(int value) {
|
||||
setPoints(getPoints() + value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the total.
|
||||
*
|
||||
*/
|
||||
public void addTotal() {
|
||||
setMilestoneCount(getMilestoneCount() + 1);
|
||||
addMonthTotal();
|
||||
addAllTimeTotal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the total daily.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void addTotalDaily() {
|
||||
setDailyTotal(getDailyTotal() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the total weekly.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public void addTotalWeekly() {
|
||||
setWeeklyTotal(getWeeklyTotal() + 1);
|
||||
}
|
||||
|
||||
public void addWeekVoteStreak() {
|
||||
setWeekVoteStreak(getWeekVoteStreak() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Can vote all.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canVoteAll() {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
boolean canVote = canVoteSite(voteSite);
|
||||
if (!canVote) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can vote site.
|
||||
*
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean canVoteSite(VoteSite voteSite) {
|
||||
|
||||
String siteName = voteSite.getKey();
|
||||
long time = getTime(voteSite);
|
||||
if (time == 0) {
|
||||
return true;
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime lastVote = LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault());
|
||||
|
||||
if (!voteSite.isVoteDelayDaily()) {
|
||||
int votedelay = ConfigVoteSites.getInstance().getVoteDelay(siteName);
|
||||
|
||||
if (votedelay == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
LocalDateTime nextvote = lastVote.plusHours(votedelay);
|
||||
|
||||
return now.isAfter(nextvote);
|
||||
} else {
|
||||
if (now.getDayOfYear() != lastVote.getDayOfYear() && now.getYear() != lastVote.getYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all votes.
|
||||
*
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkAllVotes() {
|
||||
User user = this;
|
||||
|
||||
ArrayList<Integer> months = new ArrayList<Integer>();
|
||||
ArrayList<Integer> days = new ArrayList<Integer>();
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
long time = user.getTime(voteSite);
|
||||
if (time != 0) {
|
||||
months.add(MiscUtils.getInstance().getMonthFromMili(time));
|
||||
days.add(MiscUtils.getInstance().getDayFromMili(time));
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check months
|
||||
for (int i = 0; i < months.size(); i++) {
|
||||
if (!months.get(0).equals(months.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// check days
|
||||
for (int i = 0; i < days.size(); i++) {
|
||||
if (!days.get(0).equals(days.get(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clearTotals() {
|
||||
setAllTimeTotal(0);
|
||||
resetDailyTotalVotes();
|
||||
resetMonthlyTotalVotes();
|
||||
setWeeklyTotal(0);
|
||||
}
|
||||
|
||||
public int getAllTimeTotal() {
|
||||
return getUserData().getInt("AllTimeTotal");
|
||||
}
|
||||
|
||||
public int getBestDayVoteStreak() {
|
||||
return getData().getInt("BestDayVoteStreak");
|
||||
}
|
||||
|
||||
public int getBestMonthVoteStreak() {
|
||||
return getData().getInt("BestMonthVoteStreak");
|
||||
}
|
||||
|
||||
public int getBestWeekVoteStreak() {
|
||||
return getData().getInt("BestWeekVoteStreak");
|
||||
}
|
||||
|
||||
public int getDailyTotal() {
|
||||
return getUserData().getInt("DailyTotal");
|
||||
}
|
||||
|
||||
public int getDayVoteStreak() {
|
||||
return getData().getInt("DayVoteStreak");
|
||||
}
|
||||
|
||||
public HashMap<String, Boolean> getHasGottenMilestone() {
|
||||
HashMap<String, Boolean> hasGottenMilestone = new HashMap<String, Boolean>();
|
||||
ArrayList<String> milestoneList = getUserData().getStringList("GottenMileStones");
|
||||
for (String str : milestoneList) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1) {
|
||||
boolean gotten = Boolean.parseBoolean(data[1]);
|
||||
hasGottenMilestone.put(data[0], gotten);
|
||||
}
|
||||
}
|
||||
return hasGottenMilestone;
|
||||
}
|
||||
|
||||
public int getHighestDailyTotal() {
|
||||
return getData().getInt("HighestDailyTotal");
|
||||
}
|
||||
|
||||
public int getHighestMonthlyTotal() {
|
||||
return getData().getInt("HighestMonthlyTotal");
|
||||
}
|
||||
|
||||
public int getHighestWeeklyTotal() {
|
||||
return getData().getInt("HighestWeeklyTotal");
|
||||
}
|
||||
|
||||
public HashMap<VoteSite, Long> getLastVotes() {
|
||||
HashMap<VoteSite, Long> lastVotes = new HashMap<VoteSite, Long>();
|
||||
ArrayList<String> LastVotesList = getUserData().getStringList("LastVotes");
|
||||
for (String str : LastVotesList) {
|
||||
String[] data = str.split("//");
|
||||
if (data.length > 1 && plugin.hasVoteSite(data[0])) {
|
||||
VoteSite site = plugin.getVoteSite(data[0]);
|
||||
if (site != null) {
|
||||
long time = 0;
|
||||
try {
|
||||
time = Long.parseLong(data[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
time = 0;
|
||||
plugin.debug("Not long: " + data[1]);
|
||||
}
|
||||
lastVotes.put(site, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
return lastVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the last vote times sorted.
|
||||
*
|
||||
* @return the last vote times sorted
|
||||
*/
|
||||
public HashMap<VoteSite, Long> getLastVoteTimesSorted() {
|
||||
LinkedHashMap<VoteSite, Long> times = new LinkedHashMap<VoteSite, Long>();
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
times.put(voteSite, getTime(voteSite));
|
||||
}
|
||||
LinkedHashMap<VoteSite, Long> sorted = (LinkedHashMap<VoteSite, Long>) times.entrySet().stream()
|
||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
return sorted;
|
||||
}
|
||||
|
||||
public int getMilestoneCount() {
|
||||
return getData().getInt("MilestoneCount", getAllTimeTotal());
|
||||
}
|
||||
|
||||
public int getMonthTotal() {
|
||||
return getData().getInt("MonthTotal");
|
||||
}
|
||||
|
||||
public int getLastMonthTotal() {
|
||||
return getData().getInt("LastMonthTotal");
|
||||
}
|
||||
|
||||
public int getMonthVoteStreak() {
|
||||
return getData().getInt("MonthVoteStreak");
|
||||
}
|
||||
|
||||
public ArrayList<String> getOfflineOtherRewards() {
|
||||
return getUserData().getStringList("OfflineOtherRewards");
|
||||
}
|
||||
|
||||
public ArrayList<String> getOfflineVotes() {
|
||||
return getUserData().getStringList("OfflineVotes");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the points.
|
||||
*
|
||||
* @return the points
|
||||
*/
|
||||
public int getPoints() {
|
||||
return getUserData().getInt("Points");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time.
|
||||
*
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
* @return the time
|
||||
*/
|
||||
public long getTime(VoteSite voteSite) {
|
||||
HashMap<VoteSite, Long> lastVotes = getLastVotes();
|
||||
if (lastVotes.containsKey(voteSite)) {
|
||||
return lastVotes.get(voteSite);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int getVotePartyVotes() {
|
||||
return getUserData().getInt("VotePartyVotes");
|
||||
}
|
||||
|
||||
public int getWeeklyTotal() {
|
||||
return getUserData().getInt("WeeklyTotal");
|
||||
}
|
||||
|
||||
public int getWeekVoteStreak() {
|
||||
return getData().getInt("WeekVoteStreak");
|
||||
}
|
||||
|
||||
/**
|
||||
* Give daily top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveDailyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getDailyAwardRewardsPath(place))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Daily").send(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give monthly top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveMonthlyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMonthlyAwardRewardsPath(place))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Monthly").send(this);
|
||||
}
|
||||
|
||||
public void giveOfflineOtherRewards() {
|
||||
ArrayList<String> offlineRewards = getOfflineOtherRewards();
|
||||
for (String str : offlineRewards) {
|
||||
if (str.equalsIgnoreCase("FirstVote")) {
|
||||
OtherVoteReward.getInstance().giveFirstVoteRewards(this, false);
|
||||
} else if (str.equalsIgnoreCase("AllSites")) {
|
||||
OtherVoteReward.getInstance().giveAllSitesRewards(this, false);
|
||||
} else if (str.equalsIgnoreCase("VoteParty")) {
|
||||
VoteParty.getInstance().giveReward(this);
|
||||
} else if (str.contains("Cumulative")) {
|
||||
String st = str.substring("Cumulative".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int votesRequired = Integer.parseInt(st);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getCumulativeRewardEnabled(votesRequired)) {
|
||||
OtherVoteReward.getInstance().giveCumulativeVoteReward(this, false, votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("MileStone")) {
|
||||
String st = str.substring("MileStone".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int votesRequired = Integer.parseInt(st);
|
||||
if (votesRequired > 0) {
|
||||
if (Config.getInstance().getMilestoneRewardEnabled(votesRequired)) {
|
||||
OtherVoteReward.getInstance().giveMilestoneVoteReward(this, true, votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("MonthlyTopVoter")) {
|
||||
String st = str.substring("MontlyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
giveMonthlyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("WeeklyTopVoter")) {
|
||||
String st = str.substring("WeeklyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
giveWeeklyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("DailyTopVoter")) {
|
||||
String st = str.substring("DailyTopVoter".length());
|
||||
if (StringUtils.getInstance().isInt(st)) {
|
||||
int place = Integer.parseInt(st);
|
||||
if (place > 0) {
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
giveDailyTopVoterAward(place);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (str.contains("VoteStreak")) {
|
||||
String[] args = str.split("_");
|
||||
if (args.length > 2) {
|
||||
String type = args[1];
|
||||
String st = args[2];
|
||||
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled(type, st)) {
|
||||
OtherVoteReward.getInstance().giveVoteStreakReward(this, false, type, "" + st, -1);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Reward handle for " + str + " does not exist!");
|
||||
}
|
||||
|
||||
}
|
||||
if (!offlineRewards.isEmpty()) {
|
||||
setOfflineOtherRewards(new ArrayList<String>());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Give weekly top voter award.
|
||||
*
|
||||
* @param place
|
||||
* the place
|
||||
*/
|
||||
public void giveWeeklyTopVoterAward(int place) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getWeeklyAwardRewardsPath(place))
|
||||
.withPlaceHolder("place", "" + place).withPlaceHolder("topvoter", "Weekly").send(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for gotten first vote.
|
||||
*
|
||||
* @return true if user got the first vote reward
|
||||
*/
|
||||
public boolean hasGottenFirstVote() {
|
||||
return getAllTimeTotal() != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for gotten milestone.
|
||||
*
|
||||
* @param votesRequired
|
||||
* the votes required
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean hasGottenMilestone(int votesRequired) {
|
||||
HashMap<String, Boolean> hasGottenMilestone = getHasGottenMilestone();
|
||||
if (hasGottenMilestone.containsKey("" + votesRequired)) {
|
||||
return hasGottenMilestone.get("" + votesRequired);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isReminded() {
|
||||
return Boolean.valueOf(getUserData().getString("Reminded"));
|
||||
}
|
||||
|
||||
public boolean isTopVoterIgnore() {
|
||||
return Boolean.valueOf(getUserData().getString("TopVoterIgnore"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Login message.
|
||||
*/
|
||||
public void loginMessage() {
|
||||
if (Config.getInstance().getVoteRemindingRemindOnLogin()) {
|
||||
VoteReminding.getInstance().runRemindLogin(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Off vote.
|
||||
*/
|
||||
public void offVote() {
|
||||
AdvancedCoreHook.getInstance().extraDebug("Checking offline vote site votes");
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
boolean topVoterIngorePerm = player.hasPermission("VotingPlugin.TopVoter.Ignore");
|
||||
if (isTopVoterIgnore() != topVoterIngorePerm) {
|
||||
setTopVoterIgnore(topVoterIngorePerm);
|
||||
}
|
||||
ArrayList<String> offlineVotes = getOfflineVotes();
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(offlineVotes));
|
||||
if (offlineVotes.size() > 0) {
|
||||
sendVoteEffects(true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < offlineVotes.size(); i++) {
|
||||
if (plugin.hasVoteSite(offlineVotes.get(i))) {
|
||||
plugin.debug("Giving offline site reward: " + offlineVotes.get(i));
|
||||
playerVote(plugin.getVoteSite(offlineVotes.get(i)), false, true);
|
||||
} else {
|
||||
plugin.debug("Site doesn't exist: " + offlineVotes.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
|
||||
giveOfflineOtherRewards();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Player vote.
|
||||
*
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
* @param online
|
||||
* the online
|
||||
* @param broadcast
|
||||
* the broadcast
|
||||
*/
|
||||
public void playerVote(VoteSite voteSite, boolean online, boolean broadcast) {
|
||||
if (Config.getInstance().getFormatBroadcastWhenOnline() && Config.getInstance().getBroadCastVotesEnabled()
|
||||
&& broadcast) {
|
||||
voteSite.broadcastVote(this);
|
||||
}
|
||||
voteSite.giveSiteReward(this, online);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the points.
|
||||
*
|
||||
* @param points
|
||||
* the points
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean removePoints(int points) {
|
||||
if (getPoints() >= points) {
|
||||
setPoints(getPoints() - points);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetDailyTotalVotes() {
|
||||
setDailyTotal(0);
|
||||
}
|
||||
|
||||
public void resetMonthlyTotalVotes() {
|
||||
setLastMonthTotal(getMonthTotal());
|
||||
setMonthTotal(0);
|
||||
}
|
||||
|
||||
public void resetWeeklyTotalVotes() {
|
||||
setWeeklyTotal(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send vote effects.
|
||||
*
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void sendVoteEffects(boolean online) {
|
||||
RewardHandler.getInstance().giveReward(this, Config.getInstance().getData(),
|
||||
Config.getInstance().getAnySiteRewardsPath(), online);
|
||||
}
|
||||
|
||||
public void setAllTimeTotal(int allTimeTotal) {
|
||||
getUserData().setInt("AllTimeTotal", allTimeTotal);
|
||||
}
|
||||
|
||||
public void setBestDayVoteStreak(int streak) {
|
||||
getData().setInt("BestDayVoteStreak", streak);
|
||||
}
|
||||
|
||||
public void setBestMonthVoteStreak(int streak) {
|
||||
getData().setInt("BestMonthVoteStreak", streak);
|
||||
}
|
||||
|
||||
public void setBestWeekVoteStreak(int streak) {
|
||||
getData().setInt("BestWeekVoteStreak", streak);
|
||||
}
|
||||
|
||||
public void setDailyTotal(int total) {
|
||||
getUserData().setInt("DailyTotal", total);
|
||||
}
|
||||
|
||||
public void setDayVoteStreak(int streak) {
|
||||
getData().setInt("DayVoteStreak", streak);
|
||||
if (getBestDayVoteStreak() < streak) {
|
||||
setBestDayVoteStreak(streak);
|
||||
}
|
||||
}
|
||||
|
||||
public void setHasGotteMilestone(int votesRequired, boolean b) {
|
||||
HashMap<String, Boolean> hasGottenMilestone = getHasGottenMilestone();
|
||||
hasGottenMilestone.put("" + votesRequired, b);
|
||||
setHasGottenMilestone(hasGottenMilestone);
|
||||
}
|
||||
|
||||
public void setHasGottenMilestone(HashMap<String, Boolean> hasGottenMilestone) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<String, Boolean> entry : hasGottenMilestone.entrySet()) {
|
||||
String str = entry.getKey() + "//" + entry.getValue().booleanValue();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList("GottenMileStones", data);
|
||||
}
|
||||
|
||||
public void setHighestDailyTotal(int total) {
|
||||
getData().setInt("HighestDailyTotal", total);
|
||||
}
|
||||
|
||||
public void setHighestMonthlyTotal(int total) {
|
||||
getData().setInt("HighestMonthlyTotal", total);
|
||||
}
|
||||
|
||||
public void setHighestWeeklyTotal(int total) {
|
||||
getData().setInt("HighestWeeklyTotal", total);
|
||||
}
|
||||
|
||||
public void setLastVotes(HashMap<VoteSite, Long> lastVotes) {
|
||||
ArrayList<String> data = new ArrayList<String>();
|
||||
for (Entry<VoteSite, Long> entry : lastVotes.entrySet()) {
|
||||
String str = entry.getKey().getKey() + "//" + entry.getValue().longValue();
|
||||
data.add(str);
|
||||
}
|
||||
getUserData().setStringList("LastVotes", data);
|
||||
}
|
||||
|
||||
public void setMilestoneCount(int value) {
|
||||
getData().setInt("MilestoneCount", value);
|
||||
}
|
||||
|
||||
public void setMonthTotal(int total) {
|
||||
getData().setInt("MonthTotal", total);
|
||||
}
|
||||
|
||||
public void setLastMonthTotal(int total) {
|
||||
getData().setInt("LastMonthTotal", total);
|
||||
}
|
||||
|
||||
public void setMonthVoteStreak(int streak) {
|
||||
getData().setInt("MonthVoteStreak", streak);
|
||||
if (getBestMonthVoteStreak() < streak) {
|
||||
setBestMonthVoteStreak(streak);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOfflineOtherRewards(ArrayList<String> offlineOtherRewards) {
|
||||
getUserData().setStringList("OfflineOtherRewards", offlineOtherRewards);
|
||||
}
|
||||
|
||||
public void setOfflineVotes(ArrayList<String> offlineVotes) {
|
||||
getUserData().setStringList("OfflineVotes", offlineVotes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the points.
|
||||
*
|
||||
* @param value
|
||||
* the new points
|
||||
*/
|
||||
public void setPoints(int value) {
|
||||
getUserData().setInt("Points", value);
|
||||
}
|
||||
|
||||
public void setReminded(boolean reminded) {
|
||||
getUserData().setString("Reminded", "" + reminded);
|
||||
}
|
||||
|
||||
public void setTime(VoteSite voteSite) {
|
||||
setTime(voteSite, LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli());
|
||||
}
|
||||
|
||||
public void setTime(VoteSite voteSite, Long time) {
|
||||
HashMap<VoteSite, Long> lastVotes = getLastVotes();
|
||||
lastVotes.put(voteSite, time);
|
||||
setLastVotes(lastVotes);
|
||||
}
|
||||
|
||||
public void setTopVoterIgnore(boolean topVoterIgnore) {
|
||||
getUserData().setString("TopVoterIgnore", "" + topVoterIgnore);
|
||||
}
|
||||
|
||||
public void setVotePartyVotes(int value) {
|
||||
getUserData().setInt("VotePartyVotes", value);
|
||||
}
|
||||
|
||||
public void setWeeklyTotal(int total) {
|
||||
getUserData().setInt("WeeklyTotal", total);
|
||||
}
|
||||
|
||||
public void setWeekVoteStreak(int streak) {
|
||||
getData().setInt("WeekVoteStreak", streak);
|
||||
if (getBestWeekVoteStreak() < streak) {
|
||||
setBestWeekVoteStreak(streak);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldBeReminded() {
|
||||
Player player = getPlayer();
|
||||
if (player != null) {
|
||||
if (player.hasPermission("VotingPlugin.NoRemind")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void clearOfflineRewards() {
|
||||
setOfflineVotes(new ArrayList<String>());
|
||||
setOfflineRewards(new ArrayList<String>());
|
||||
setOfflineOtherRewards(new ArrayList<String>());
|
||||
}
|
||||
|
||||
}
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
@Deprecated
|
||||
public class User {
|
||||
private VotingPluginUser user;
|
||||
public User(Player p) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
return user.getPoints();
|
||||
}
|
||||
|
||||
public void setPoints(int points) {
|
||||
user.setPoints(points);
|
||||
}
|
||||
|
||||
public void addPoints(int points) {
|
||||
user.addPoints(points);
|
||||
}
|
||||
|
||||
public boolean removePoints(int points) {
|
||||
return user.removePoints(points);
|
||||
}
|
||||
}
|
||||
@@ -1,320 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteSite.
|
||||
*/
|
||||
public class VoteSite {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/** The vote URL. */
|
||||
private String voteURL;
|
||||
|
||||
/** The service site. */
|
||||
private String serviceSite;
|
||||
|
||||
/** The site name. */
|
||||
private String key;
|
||||
|
||||
private String displayName;
|
||||
|
||||
/** The vote delay. */
|
||||
private double voteDelay;
|
||||
|
||||
/** The enabled. */
|
||||
private boolean enabled;
|
||||
|
||||
private boolean voteDelayDaily;
|
||||
|
||||
/** The priority. */
|
||||
private int priority;
|
||||
|
||||
private ConfigurationSection item;
|
||||
|
||||
private boolean giveOffline;
|
||||
|
||||
/**
|
||||
* Instantiates a new vote site.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VoteSite(Main plugin) {
|
||||
VoteSite.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
*/
|
||||
public VoteSite(String siteName) {
|
||||
key = siteName.replace(".", "_");
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast vote.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void broadcastVote(User user) {
|
||||
if (!user.isVanished()) {
|
||||
String playerName = user.getPlayerName();
|
||||
String bc = StringUtils.getInstance().colorize(config.getFormatBroadCastMsg());
|
||||
bc = bc.replace("%player%", playerName).replace("%SiteName%", getDisplayName());
|
||||
MiscUtils.getInstance().broadcast(bc);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the displayName
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
public ItemBuilder getItem() {
|
||||
if (item == null) {
|
||||
plugin.getLogger().warning("Invalid item section in site: " + key);
|
||||
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid item for site: " + key)
|
||||
.setLore("&cInvalid item for site: " + key);
|
||||
} else {
|
||||
return new ItemBuilder(item);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
* @return the priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service site.
|
||||
*
|
||||
* @return the service site
|
||||
*/
|
||||
public String getServiceSite() {
|
||||
return serviceSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
* @return the vote delay
|
||||
*/
|
||||
public double getVoteDelay() {
|
||||
return voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL() {
|
||||
return voteURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveRewards(User user, boolean online) {
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getRewardsPath(key)).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getEverySiteRewardPath()).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
}
|
||||
|
||||
public boolean hasRewards() {
|
||||
return RewardHandler.getInstance().hasRewards(configVoteSites.getData(), configVoteSites.getRewardsPath(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Give site reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveSiteReward(User user, boolean online) {
|
||||
giveRewards(user, online);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the.
|
||||
*/
|
||||
public void init() {
|
||||
setVoteURL(configVoteSites.getVoteURL(key));
|
||||
setServiceSite(configVoteSites.getServiceSite(key));
|
||||
setVoteDelay(configVoteSites.getVoteDelay(key));
|
||||
setEnabled(configVoteSites.getVoteSiteEnabled(key));
|
||||
setPriority(configVoteSites.getPriority(key));
|
||||
displayName = configVoteSites.getDisplayName(key);
|
||||
if (displayName == null || displayName.equals("")) {
|
||||
displayName = key;
|
||||
}
|
||||
item = configVoteSites.getItem(key);
|
||||
voteDelayDaily = configVoteSites.getVoteSiteResetVoteDelayDaily(key);
|
||||
giveOffline = configVoteSites.getVoteSiteGiveOffline(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is enabled.
|
||||
*
|
||||
* @return true, if is enabled
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the giveOffline
|
||||
*/
|
||||
public boolean isGiveOffline() {
|
||||
return giveOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the voteDelayDaily
|
||||
*/
|
||||
public boolean isVoteDelayDaily() {
|
||||
return voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayName
|
||||
* the displayName to set
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param enabled
|
||||
* the new enabled
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param giveOffline
|
||||
* the giveOffline to set
|
||||
*/
|
||||
public void setGiveOffline(boolean giveOffline) {
|
||||
this.giveOffline = giveOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* the item to set
|
||||
*/
|
||||
public void setItem(ConfigurationSection item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* the key to set
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
* @param priority
|
||||
* the new priority
|
||||
*/
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the service site.
|
||||
*
|
||||
* @param serviceSite
|
||||
* the new service site
|
||||
*/
|
||||
public void setServiceSite(String serviceSite) {
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote delay.
|
||||
*
|
||||
* @param voteDelay
|
||||
* the new vote delay
|
||||
*/
|
||||
public void setVoteDelay(double voteDelay) {
|
||||
this.voteDelay = voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param voteDelayDaily
|
||||
* the voteDelayDaily to set
|
||||
*/
|
||||
public void setVoteDelayDaily(boolean voteDelayDaily) {
|
||||
this.voteDelayDaily = voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
* @param voteURL
|
||||
* the new vote URL
|
||||
*/
|
||||
public void setVoteURL(String voteURL) {
|
||||
this.voteURL = voteURL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,288 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.OtherRewards;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteAllSitesEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OtherVoteReward.
|
||||
*/
|
||||
public class OtherVoteReward {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The instance. */
|
||||
static OtherVoteReward instance = new OtherVoteReward();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of OtherVoteReward.
|
||||
*
|
||||
* @return single instance of OtherVoteReward
|
||||
*/
|
||||
public static OtherVoteReward getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new other vote reward.
|
||||
*/
|
||||
private OtherVoteReward() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new other vote reward.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public OtherVoteReward(Main plugin) {
|
||||
OtherVoteReward.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all sites.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkAllSites(User user) {
|
||||
boolean checkAllVotes = user.checkAllVotes();
|
||||
if (checkAllVotes) {
|
||||
giveAllSitesRewards(user, user.isOnline());
|
||||
}
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check cumualative votes.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkCumualativeVotes(User user) {
|
||||
boolean gotCumulative = false;
|
||||
Set<String> votes = Config.getInstance().getCumulativeVotes();
|
||||
for (String vote : votes) {
|
||||
if (StringUtils.getInstance().isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getCumulativeRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getCumulativeRewardsPath(votesRequired))) {
|
||||
int total = 0;
|
||||
if (Config.getInstance().getCumulativeVotesInSameDay(votesRequired)) {
|
||||
total = user.getDailyTotal();
|
||||
} else if (Config.getInstance().getCumulativeVotesInSameWeek(votesRequired)) {
|
||||
total = user.getWeeklyTotal();
|
||||
} else {
|
||||
total = user.getAllTimeTotal();
|
||||
}
|
||||
|
||||
if ((total % votesRequired) == 0 && total != 0) {
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired);
|
||||
gotCumulative = true;
|
||||
}
|
||||
|
||||
if (gotCumulative) {
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid cumulative number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotCumulative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check first vote.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkFirstVote(User user) {
|
||||
if (RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVote()) {
|
||||
giveFirstVoteRewards(user, user.isOnline());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check milestone.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkMilestone(User user) {
|
||||
boolean gotMilestone = false;
|
||||
Set<String> votes = Config.getInstance().getMilestoneVotes();
|
||||
for (String vote : votes) {
|
||||
if (StringUtils.getInstance().isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getMilestoneRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getMilestoneRewardsPath(votesRequired))) {
|
||||
|
||||
int userVotesTotal = user.getMilestoneCount();
|
||||
if (userVotesTotal >= votesRequired && !user.hasGottenMilestone(votesRequired)) {
|
||||
giveMilestoneVoteReward(user, user.isOnline(), votesRequired);
|
||||
user.setHasGotteMilestone(votesRequired, true);
|
||||
plugin.debug(user.getPlayerName() + " got milestone " + votesRequired);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid milestone number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotMilestone;
|
||||
}
|
||||
|
||||
public boolean checkVoteStreak(User user, String type) {
|
||||
boolean gotReward = false;
|
||||
|
||||
Set<String> streaks = Config.getInstance().getVoteStreakVotes(type);
|
||||
for (String streak : streaks) {
|
||||
String s = streak.replaceAll("-", "");
|
||||
boolean multiple = false;
|
||||
if (streak.contains("-")) {
|
||||
// multiple
|
||||
multiple = true;
|
||||
}
|
||||
if (StringUtils.getInstance().isInt(s)) {
|
||||
int streakRequired = Integer.parseInt(s);
|
||||
if (streakRequired != 0) {
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled(type, streak)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().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);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + " for " + type);
|
||||
}
|
||||
} else {
|
||||
if (curStreak != 0 && curStreak % streakRequired == 0) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, streakRequired + "-", curStreak);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + "* for " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return gotReward;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Give all sites rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveAllSitesRewards(User user, boolean online) {
|
||||
PlayerVoteAllSitesEvent event = new PlayerVoteAllSitesEvent(user);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getAllSitesRewardPath(), online);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give cumulative vote reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
* @param cumulative
|
||||
* the cumulative
|
||||
*/
|
||||
public void giveCumulativeVoteReward(User user, boolean online, int cumulative) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getCumulativeRewardsPath(cumulative))
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give first vote rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveFirstVoteRewards(User user, boolean online) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath(), online);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give milestone vote reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
* @param milestone
|
||||
* the milestone
|
||||
*/
|
||||
public void giveMilestoneVoteReward(User user, boolean online, int milestone) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMilestoneRewardsPath(milestone))
|
||||
.setOnline(online).withPlaceHolder("Milestone", "" + milestone).send(user);
|
||||
}
|
||||
|
||||
public void giveVoteStreakReward(User user, boolean online, String type, String string, int votes) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVoteStreakRewardsPath(type, string))
|
||||
.setOnline(online).withPlaceHolder("Type", type).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Signs.
|
||||
*/
|
||||
public class Signs {
|
||||
|
||||
/** The instance. */
|
||||
static Signs instance = new Signs();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of Signs.
|
||||
*
|
||||
* @return single instance of Signs
|
||||
*/
|
||||
public static Signs getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new signs.
|
||||
*/
|
||||
private Signs() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new signs.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public Signs(Main plugin) {
|
||||
Signs.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign from location.
|
||||
*
|
||||
* @param loc
|
||||
* the loc
|
||||
* @return the sign from location
|
||||
*/
|
||||
public String getSignFromLocation(Location loc) {
|
||||
for (String sign : ServerData.getInstance().getSigns()) {
|
||||
if (ServerData.getInstance().getSignLocation(sign).equals(loc)) {
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load signs.
|
||||
*/
|
||||
public void loadSigns() {
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
for (String sign : ServerData.getInstance().getSigns()) {
|
||||
// plugin.getLogger().info("Loading sign " + sign);
|
||||
plugin.signs.add(new SignHandler(sign, ServerData.getInstance().getSignLocation(sign),
|
||||
ServerData.getInstance().getSignData(sign), ServerData.getInstance().getSignPosition(sign)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store signs.
|
||||
*/
|
||||
public void storeSigns() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
sign.storeSign();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update signs.
|
||||
*/
|
||||
public void updateSigns() {
|
||||
for (int i = plugin.signs.size() - 1; i >= 0; i--) {
|
||||
if (!plugin.signs.get(i).isValid()) {
|
||||
plugin.debug("Sign " + i + " invalid, removing from data.");
|
||||
plugin.signs.get(i).removeSign();
|
||||
plugin.signs.remove(i);
|
||||
} else {
|
||||
plugin.signs.get(i).updateLines();
|
||||
plugin.signs.get(i).updateSign(i * 3);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Signs updated");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,649 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.TopVoter;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.PreDateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.WeekChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFileHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class TopVoterHandler implements Listener {
|
||||
/** The instance. */
|
||||
static TopVoterHandler instance = new TopVoterHandler();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of TopVoter.
|
||||
*
|
||||
* @return single instance of TopVoter
|
||||
*/
|
||||
public static TopVoterHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new top voter.
|
||||
*/
|
||||
private TopVoterHandler() {
|
||||
}
|
||||
|
||||
public ArrayList<String> getTopVoterBlackList() {
|
||||
return Config.getInstance().getBlackList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters weekly.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
|
||||
public String[] getTopVotersWeekly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine().replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%", "" + plugin.topVoterWeekly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onDateChanged(DateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPreDateChanged(PreDateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getDailyTotal() == 0 && user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
} else {
|
||||
user.addDayVoteStreak();
|
||||
}
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Day");
|
||||
|
||||
if (user.getHighestDailyTotal() < user.getDailyTotal()) {
|
||||
user.setHighestDailyTotal(user.getDailyTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersDaily()) {
|
||||
plugin.debug("Storing TopVoters Daily");
|
||||
storeDailyTopVoters();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
Set<String> places = Config.getInstance().getDailyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterDaily.keySet()) {
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getDailyTotal() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveDailyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
lastTotal = user.getDailyTotal();
|
||||
}
|
||||
}
|
||||
resetDailyTotals();
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getMonthTotal() == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
} else {
|
||||
user.addMonthVoteStreak();
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Month");
|
||||
}
|
||||
|
||||
if (user.getHighestMonthlyTotal() < user.getMonthTotal()) {
|
||||
user.setHighestMonthlyTotal(user.getMonthTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersMonthly()) {
|
||||
plugin.debug("Storing TopVoters Monthly");
|
||||
storeMonthlyTopVoters();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
Set<String> places = Config.getInstance().getMonthlyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterMonthly.keySet()) {
|
||||
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getMonthTotal() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveMonthlyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
lastTotal = user.getMonthTotal();
|
||||
}
|
||||
}
|
||||
resetMonthlyTotals();
|
||||
|
||||
if (Config.getInstance().getResetMilestonesMonthly()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setMilestoneCount(0);
|
||||
user.setHasGottenMilestone(new HashMap<String, Boolean>());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getWeeklyTotal() == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
} else {
|
||||
user.addWeekVoteStreak();
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Week");
|
||||
}
|
||||
|
||||
if (user.getHighestWeeklyTotal() < user.getWeeklyTotal()) {
|
||||
user.setHighestWeeklyTotal(user.getWeeklyTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersWeekly()) {
|
||||
plugin.debug("Storing TopVoters Weekly");
|
||||
storeWeeklyTopVoters();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
Set<String> places = Config.getInstance().getWeeklyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterWeekly.keySet()) {
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getWeeklyTotal() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.giveWeeklyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
lastTotal = user.getWeeklyTotal();
|
||||
}
|
||||
}
|
||||
resetWeeklyTotals();
|
||||
|
||||
}
|
||||
|
||||
public void register() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void resetDailyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getDailyTotal() != 0) {
|
||||
user.resetDailyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetMonthlyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getMonthTotal() != 0) {
|
||||
user.resetMonthlyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetWeeklyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getWeeklyTotal() != 0) {
|
||||
user.resetWeeklyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> sortByValues(LinkedHashMap<User, Integer> topVoterAllTime,
|
||||
final boolean order) {
|
||||
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(topVoterAllTime.entrySet());
|
||||
|
||||
// Sorting the list based on values
|
||||
Collections.sort(list, new Comparator<Entry<User, Integer>>() {
|
||||
@Override
|
||||
public int compare(Entry<User, Integer> o1, Entry<User, Integer> o2) {
|
||||
if (order) {
|
||||
return o1.getValue().compareTo(o2.getValue());
|
||||
} else {
|
||||
return o2.getValue().compareTo(o1.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Maintaining insertion order with the help of LinkedList
|
||||
LinkedHashMap<User, Integer> sortedMap = new LinkedHashMap<User, Integer>();
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
public void storeDailyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(5);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
int day = time.getDayOfMonth();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Daily" + File.separator + year + "_" + month + "_" + day + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Day", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
public void storeMonthlyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(10);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Monthly" + File.separator + month + "_" + year + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Month", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
public void storeWeeklyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(10);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
int week = time.getDayOfYear();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Weekly" + File.separator + year + "_" + month + "_" + week + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Week", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter all time
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterAllTime(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "All Time");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter weekly.
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterDaily(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "Daily");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter monthly
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterMonthly(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "Monthly");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters all time
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVotersAllTime() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(plugin.topVoterAllTime.entrySet());
|
||||
int i = 0;
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
} catch (Exception ex) {
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
|
||||
msg.add(line);
|
||||
i++;
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters daily.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
|
||||
public String[] topVotersDaily() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterDaily.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
line = line.replace("%player%", users.get(i).getPlayerName());
|
||||
} catch (Exception ex) {
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
line = line.replace("%votes%", "" + plugin.topVoterMonthly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVotersMonthly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(plugin.topVoterMonthly.entrySet());
|
||||
int i = 0;
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
} catch (Exception ex) {
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
|
||||
msg.add(line);
|
||||
i++;
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter weekly.
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterWeekly(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "Weekly");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public synchronized void updateTopVoters(ArrayList<User> users1) {
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
ArrayList<String> blackList = getTopVoterBlackList();
|
||||
for (User user : users1) {
|
||||
if (!blackList.contains(user.getPlayerName())) {
|
||||
if ((!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore())
|
||||
&& !user.isBanned()) {
|
||||
users.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.topVoterAllTime.clear();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
for (User user : users) {
|
||||
int total = user.getAllTimeTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterAllTime.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterAllTime = sortByValues(plugin.topVoterAllTime, false);
|
||||
plugin.debug("All Time TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterMonthly.clear();
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
for (User user : users) {
|
||||
int total = user.getMonthTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterMonthly.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterMonthly = sortByValues(plugin.topVoterMonthly, false);
|
||||
plugin.debug("Monthly TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly.clear();
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
for (User user : users) {
|
||||
int total = user.getWeeklyTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterWeekly.put(user, total);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly = sortByValues(plugin.topVoterWeekly, false);
|
||||
plugin.debug("Weekly TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterDaily.clear();
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
for (User user : users) {
|
||||
int total = user.getDailyTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterDaily.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterDaily = sortByValues(plugin.topVoterDaily, false);
|
||||
plugin.debug("Daily TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.debug("Updated TopVoter");
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.UserManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class UserManager {
|
||||
/** The instance. */
|
||||
static UserManager instance = new UserManager();
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of UserManager.
|
||||
*
|
||||
* @return single instance of UserManager
|
||||
*/
|
||||
public static UserManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public UserManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllUUIDs() {
|
||||
return com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().getAllUUIDs();
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(OfflinePlayer player) {
|
||||
return getVotingPluginUser(player.getName());
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(Player player) {
|
||||
return getVotingPluginUser(player.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public User getVotingPluginUser(String playerName) {
|
||||
return new User(com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().getProperName(playerName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public User getVotingPluginUser(UUID uuid) {
|
||||
return new User(uuid);
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(java.util.UUID uuid) {
|
||||
return getVotingPluginUser(new UUID(uuid.toString()));
|
||||
}
|
||||
}
|
||||
@@ -1,255 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlaceHolders.
|
||||
*/
|
||||
public class PlaceHolders {
|
||||
|
||||
/** The instance. */
|
||||
static PlaceHolders instance = new PlaceHolders();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of PlaceHolders.
|
||||
*
|
||||
* @return single instance of PlaceHolders
|
||||
*/
|
||||
public static PlaceHolders getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*/
|
||||
private PlaceHolders() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlaceHolders(Main plugin) {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
public synchronized String getPlaceHolder(Player p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
|
||||
// %VotingPlugin_total% - Total votes of all vote sites
|
||||
if (identifier.equalsIgnoreCase("total")) {
|
||||
return Integer.toString(user.getMonthTotal());
|
||||
} else if (identifier.equalsIgnoreCase("alltimetotal")) {
|
||||
return Integer.toString(user.getAllTimeTotal());
|
||||
} else if (identifier.equalsIgnoreCase("lastmonthtotal")) {
|
||||
return Integer.toString(user.getLastMonthTotal());
|
||||
}
|
||||
|
||||
String[] args = identifier.split("_");
|
||||
if (args.length > 1 && args[0].equalsIgnoreCase("total")) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
return Integer.toString(user.getAllTimeTotal());
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
return Integer.toString(user.getMonthTotal());
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
return Integer.toString(user.getWeeklyTotal());
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
return Integer.toString(user.getDailyTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (identifier.equalsIgnoreCase("BestDailyTotal")) {
|
||||
return "" + user.getHighestDailyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("BestWeeklyTotal")) {
|
||||
return "" + user.getHighestWeeklyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("BestMonthlyTotal")) {
|
||||
return "" + user.getHighestMonthlyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("DailyVoteStreak")) {
|
||||
return "" + user.getDayVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("WeeklyVoteStreak")) {
|
||||
return "" + user.getWeekVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("MonthlyVoteStreak")) {
|
||||
return "" + user.getMonthVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestDailyVoteStreak")) {
|
||||
return "" + user.getBestDayVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestWeeklyVoteStreak")) {
|
||||
return "" + user.getBestWeekVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestMonthlyVoteStreak")) {
|
||||
return "" + user.getBestMonthVoteStreak();
|
||||
}
|
||||
|
||||
// %VotingPlugin_points% - Total votes of all vote sites
|
||||
if (identifier.equalsIgnoreCase("points")) {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
// vote party rewards
|
||||
if (identifier.equalsIgnoreCase("VotePartyVotesNeeded")) {
|
||||
return Integer.toString(VoteParty.getInstance().getNeededVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesCurrent")) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesRequired")) {
|
||||
return Integer.toString(Config.getInstance().getVotePartyVotesRequired());
|
||||
}
|
||||
|
||||
// %VotingPlugin_canvote% - Whether or not a player can vote on all
|
||||
// sites
|
||||
if (identifier.equalsIgnoreCase("canvote")) {
|
||||
return Boolean.toString(user.canVoteAll());
|
||||
}
|
||||
|
||||
// %VotingPlugin_next_SITENAME% - Next time you can vote for voteSite
|
||||
if (startsWithIgnoreCase(identifier, "next")) {
|
||||
if (args.length > 1) {
|
||||
String str = args[1];
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
str += "_" + args[i];
|
||||
}
|
||||
return playerNextVote(user, str);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// %VotingPlugin_last_SITENAME% - Next time you can vote for voteSite
|
||||
if (startsWithIgnoreCase(identifier, "last")) {
|
||||
if (args.length > 1) {
|
||||
String str = args[1];
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
str += "_" + args[i];
|
||||
}
|
||||
return playerLastVote(user, str);
|
||||
}
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[0].equalsIgnoreCase("top")) {
|
||||
if (StringUtils.getInstance().isInt(args[2])) {
|
||||
int number = Integer.parseInt(args[2]);
|
||||
int num = 1;
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
} else if (args[2].equalsIgnoreCase("Position")) {
|
||||
int num = 1;
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public String playerLastVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
return Commands.getInstance().voteCommandLastDate(user, voteSite);
|
||||
}
|
||||
|
||||
public String playerNextVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
return Commands.getInstance().voteCommandNextInfo(user, voteSite);
|
||||
}
|
||||
|
||||
public boolean startsWithIgnoreCase(String str1, String str2) {
|
||||
return str1.toLowerCase().startsWith(str2.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,271 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteParty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotePartyEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteParty.
|
||||
*/
|
||||
public class VoteParty implements Listener {
|
||||
|
||||
/** The instance. */
|
||||
static VoteParty instance = new VoteParty();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of VoteParty.
|
||||
*
|
||||
* @return single instance of VoteParty
|
||||
*/
|
||||
public static VoteParty getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote party.
|
||||
*/
|
||||
private VoteParty() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote party.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VoteParty(Main plugin) {
|
||||
VoteParty.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addTotal(User user) {
|
||||
setTotalVotes(getTotalVotes() + 1);
|
||||
user.setVotePartyVotes(user.getVotePartyVotes() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the vote player.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void addVotePlayer(User user) {
|
||||
String uuid = user.getUUID();
|
||||
ArrayList<String> voted = getVotedUsers();
|
||||
if (voted == null) {
|
||||
voted = new ArrayList<String>();
|
||||
}
|
||||
if (!voted.contains(uuid)) {
|
||||
voted.add(uuid);
|
||||
setVotedUsers(voted);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check.
|
||||
*/
|
||||
public void check() {
|
||||
if (getTotalVotes() >= Config.getInstance().getVotePartyVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - Config.getInstance().getVotePartyVotesRequired());
|
||||
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
giveRewards();
|
||||
MiscUtils.getInstance().broadcast(Config.getInstance().getVotePartyBroadcast());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Command vote party.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
*/
|
||||
public void commandVoteParty(CommandSender sender) {
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
ArrayList<String> msg = Config.getInstance().getFormatCommandsVoteParty();
|
||||
int votesRequired = Config.getInstance().getVotePartyVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("votesrequired", "" + votesRequired);
|
||||
placeholders.put("neededvotes", "" + neededVotes);
|
||||
placeholders.put("votes", "" + votes);
|
||||
msg = ArrayUtils.getInstance().colorize(ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders));
|
||||
sender.sendMessage(ArrayUtils.getInstance().convert(msg));
|
||||
} else {
|
||||
sender.sendMessage(StringUtils.getInstance().colorize("&cVoteParty not enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the needed votes.
|
||||
*
|
||||
* @return the needed votes
|
||||
*/
|
||||
public int getNeededVotes() {
|
||||
int votesRequired = Config.getInstance().getVotePartyVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
return neededVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total votes.
|
||||
*
|
||||
* @return the total votes
|
||||
*/
|
||||
public int getTotalVotes() {
|
||||
return ServerData.getInstance().getData().getInt("VoteParty.Total");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the voted users.
|
||||
*
|
||||
* @return the voted users
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotedUsers() {
|
||||
ArrayList<String> list = (ArrayList<String>) ServerData.getInstance().getData().getList("VoteParty.Voted");
|
||||
if (list != null) {
|
||||
return list;
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Give reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void giveReward(User user) {
|
||||
/*
|
||||
* if (PlayerUtils.getInstance().isPlayerOnline(user.getPlayerName())) { if
|
||||
* (user.getVotePartyVotes() >= Config.getInstance().getUserVotesRequired()) {
|
||||
* RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
* Config.getInstance().getVotePartyRewardsPath()); } } else {
|
||||
* user.addOfflineOtherReward("VoteParty"); }
|
||||
*/
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVotePartyRewardsPath())
|
||||
.setOnline(user.isOnline())
|
||||
.withPlaceHolder("VotesRequired", "" + Config.getInstance().getVotePartyVotesRequired()).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give rewards.
|
||||
*/
|
||||
public void giveRewards() {
|
||||
for (final String cmd : Config.getInstance().getVotePartyCommands()) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVotePartyGiveAllPlayers()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
giveReward(user);
|
||||
}
|
||||
} else {
|
||||
for (String uuid : getVotedUsers()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
giveReward(user);
|
||||
}
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
if (Config.getInstance().getVotePartyResetEachDay()) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
if (Config.getInstance().getVotePartyResetMontly()) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
setVotedUsers(new ArrayList<String>());
|
||||
setTotalVotes(0);
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getVotePartyVotes() != 0) {
|
||||
user.setVotePartyVotes(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total votes.
|
||||
*
|
||||
* @param value
|
||||
* the new total votes
|
||||
*/
|
||||
public void setTotalVotes(int value) {
|
||||
ServerData.getInstance().getData().set("VoteParty.Total", value);
|
||||
ServerData.getInstance().saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the voted users.
|
||||
*
|
||||
* @param value
|
||||
* the new voted users
|
||||
*/
|
||||
public void setVotedUsers(ArrayList<String> value) {
|
||||
ServerData.getInstance().getData().set("VoteParty.Voted", value);
|
||||
ServerData.getInstance().saveData();
|
||||
}
|
||||
|
||||
public synchronized void vote(User user, boolean realVote) {
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
if (Config.getInstance().getVotePartyCountFakeVotes() || realVote) {
|
||||
addTotal(user);
|
||||
addVotePlayer(user);
|
||||
check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteReminding;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteReminding.
|
||||
*/
|
||||
public class VoteReminding {
|
||||
|
||||
/** The instance. */
|
||||
static VoteReminding instance = new VoteReminding();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of VoteReminding.
|
||||
*
|
||||
* @return single instance of VoteReminding
|
||||
*/
|
||||
public static VoteReminding getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*/
|
||||
private VoteReminding() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VoteReminding(Main plugin) {
|
||||
VoteReminding.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check remind.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void checkRemind(User user) {
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
if (PlayerUtils.getInstance().hasServerPermission(playerName, "VotingPlugin.Login.RemindVotes")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(playerName, "VotingPlugin.Player")) {
|
||||
if (user.canVoteAll()) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
if (!Config.getInstance().getVoteRemindingRemindOnlyOnce()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
} else if (!user.isReminded()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void giveReward(User user) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVoteRemindingRewardsPath())
|
||||
.setGiveOffline(false).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load remind checking.
|
||||
*/
|
||||
public void loadRemindChecking() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
}, 10, Config.getInstance().getVoteRemindingRemindDelay() * 20 * 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run remind.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void runRemind(User user) {
|
||||
if (Config.getInstance().getVoteRemindingEnabled() && user.canVoteAll() && user.shouldBeReminded()) {
|
||||
user.setReminded(true);
|
||||
giveReward(user);
|
||||
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void runRemindLogin(User user) {
|
||||
if (Config.getInstance().getVoteRemindingEnabled()
|
||||
&& (!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || user.canVoteAll())
|
||||
&& user.shouldBeReminded()) {
|
||||
giveReward(user);
|
||||
if (user.getData().hasData()) {
|
||||
user.setReminded(true);
|
||||
}
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteShop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.GUI.PlayerGUIs;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class VoteShop {
|
||||
static VoteShop instance = new VoteShop();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static VoteShop getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private VoteShop() {
|
||||
}
|
||||
|
||||
public VoteShop(Main plugin) {
|
||||
VoteShop.plugin = plugin;
|
||||
}
|
||||
|
||||
public void voteShop(Player player) {
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
|
||||
if (identifier != null) {
|
||||
if (user.removePoints(points)) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier));
|
||||
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getFormatShopFailedMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,263 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.pluginmessage.PluginMessageHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.bungee.BungeeMethod;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeHandler {
|
||||
@Getter
|
||||
private ClientHandler clientHandler;
|
||||
|
||||
private EncryptionHandler encryptionHandler;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
public BungeeHandler(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void close() {
|
||||
socketHandler.closeConnection();
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
plugin.debug("Loading bungee handler");
|
||||
|
||||
method = BungeeMethod.getByName(plugin.getBungeeSettings().getBungeeMethod());
|
||||
|
||||
plugin.getLogger().info("Using BungeeMethod: " + method.toString());
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
plugin.registerBungeeChannels("vp:vp");
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Vote") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
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 + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
BungeeMessageData text = new BungeeMessageData(args.get(6));
|
||||
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text);
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
if (wasOnline || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.size() > 4 && Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteOnline") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
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));
|
||||
plugin.debug("pluginmessaging voteonline received from " + player + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid),
|
||||
player);
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time, text);
|
||||
|
||||
if (!plugin.getBungeeSettings().isBungeeBroadcast()) {
|
||||
if (Boolean.valueOf(args.get(4)) || plugin.getBungeeSettings().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (args.size() > 4 && Boolean.valueOf(args.get(5))) {
|
||||
plugin.getServerData().addServiceSite(service);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteUpdate") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String player = args.get(0);
|
||||
plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(player));
|
||||
user.clearCache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(1);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
VoteSite site = plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
plugin.getPluginMessaging().add(new PluginMessageHandler("Status") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String server = args.get(0);
|
||||
plugin.getPluginMessaging().sendPluginMessage("statusokay", server);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
} 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());
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevote") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 4) {
|
||||
plugin.extraDebug("BungeeVote from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVote(data[3], new BungeeMessageData(data[4]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevoteonline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 4) {
|
||||
plugin.extraDebug("BungeeVoteOnline from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
VotingPluginUser user = null;
|
||||
if (!uuid.isEmpty()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
} else {
|
||||
user = UserManager.getInstance().getVotingPluginUser(data[2]);
|
||||
}
|
||||
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVoteOnline(data[3], new BungeeMessageData(data[4]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeBroadcast") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 2) {
|
||||
VoteSite site = plugin.getVoteSite(data[1]);
|
||||
String p = data[3];
|
||||
VotingPluginUser user = UserManager.getInstance().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);
|
||||
}
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.injected.RewardInject;
|
||||
import com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInject;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
public class VotingPluginHooks {
|
||||
private static VotingPluginHooks instance = new VotingPluginHooks();
|
||||
|
||||
public static VotingPluginHooks getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void addCustomRequirement(RequirementInject inject) {
|
||||
RewardHandler.getInstance().addInjectedRequirements(inject);
|
||||
}
|
||||
|
||||
public void addCustomReward(RewardInject inject) {
|
||||
RewardHandler.getInstance().addInjectedReward(inject);
|
||||
}
|
||||
|
||||
public VotingPluginMain getMainClass() {
|
||||
return VotingPluginMain.plugin;
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return UserManager.getInstance();
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,243 @@
|
||||
package com.bencodez.votingplugin;
|
||||
|
||||
import com.bencodez.advancedcore.api.metrics.BStatsMetrics;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
|
||||
public class VotingPluginMetrics {
|
||||
|
||||
public void load(VotingPluginMain plugin) {
|
||||
BStatsMetrics metrics = new BStatsMetrics(plugin);
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_firstvote") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getFirstVoteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_everysite") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getConfigVoteSites().getData(),
|
||||
plugin.getConfigVoteSites().getEverySiteRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_allsites") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAllSitesRewardPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_cumulative") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
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") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (!plugin.getSpecialRewardsConfig().getVotePartyEnabled()) {
|
||||
return "False";
|
||||
} else {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_milestone") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
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";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_anysitereward") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getAnySiteRewardsPath())) {
|
||||
return "True";
|
||||
} else {
|
||||
return "False";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakday") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Day")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Day", s)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Day", s))) {
|
||||
return "True";
|
||||
}
|
||||
|
||||
}
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakweek") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Week")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Week", s)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Week", s))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("extrarewards_votestreakmonth") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
for (String s : plugin.getSpecialRewardsConfig().getVoteStreakVotes("Month")) {
|
||||
|
||||
if (plugin.getSpecialRewardsConfig().getVoteStreakRewardEnabled("Month", s)
|
||||
&& RewardHandler.getInstance().hasRewards(plugin.getSpecialRewardsConfig().getData(),
|
||||
plugin.getSpecialRewardsConfig().getVoteStreakRewardsPath("Month", s))) {
|
||||
return "True";
|
||||
}
|
||||
}
|
||||
|
||||
return "False";
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofsites") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.getVoteSites().size();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofrewards") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + RewardHandler.getInstance().getRewards().size();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("autocreatevotesites") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.getConfigFile().isAutoCreateVoteSites();
|
||||
}
|
||||
});
|
||||
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("numberofusers") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
int total = UserManager.getInstance().getAllUUIDs().size();
|
||||
if (total < 1000) {
|
||||
return "<1000";
|
||||
} else if (total > 10000) {
|
||||
return ">10000";
|
||||
} else {
|
||||
return "1000-10000";
|
||||
}
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("data_storage") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return plugin.getOptions().getStorageType().toString();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("DisableCheckOnWorldChange") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.getOptions().isDisableCheckOnWorldChange();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("votereminding_enabled") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.getConfigFile().getVoteRemindingEnabled();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Monthly") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterMonthly();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Weekly") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterWeekly();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("LoadTopVoter_Daily") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return "" + plugin.getConfigFile().getLoadTopVoterDaily();
|
||||
}
|
||||
});
|
||||
metrics.addCustomChart(new BStatsMetrics.SimplePie("bungeemethod") {
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
if (plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
return "" + plugin.getBungeeHandler().getMethod().toString();
|
||||
} else {
|
||||
return "Disabled";
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,771 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.config.ConfigurationProvider;
|
||||
import net.md_5.bungee.config.YamlConfiguration;
|
||||
|
||||
/**
|
||||
* bStats collects some data for plugin authors.
|
||||
* <p>
|
||||
* Check out https://bStats.org/ to learn more about bStats!
|
||||
*/
|
||||
public class BStatsMetricsBungee {
|
||||
|
||||
static {
|
||||
// You can use the property to disable the check in your test environment
|
||||
if (System.getProperty("bstats.relocatecheck") == null
|
||||
|| !System.getProperty("bstats.relocatecheck").equals("false")) {
|
||||
// Maven's Relocate is clever and changes strings, too. So we have to use this
|
||||
// little "trick" ... :D
|
||||
final String defaultPackage = new String(new byte[] { 'o', 'r', 'g', '.', 'b', 's', 't', 'a', 't', 's', '.',
|
||||
'b', 'u', 'n', 'g', 'e', 'e', 'c', 'o', 'r', 'd' });
|
||||
final String examplePackage = new String(
|
||||
new byte[] { 'y', 'o', 'u', 'r', '.', 'p', 'a', 'c', 'k', 'a', 'g', 'e' });
|
||||
// We want to make sure nobody just copy & pastes the example and use the wrong
|
||||
// package names
|
||||
if (BStatsMetricsBungee.class.getPackage().getName().equals(defaultPackage)
|
||||
|| BStatsMetricsBungee.class.getPackage().getName().equals(examplePackage)) {
|
||||
throw new IllegalStateException("bStats Metrics class has not been relocated correctly!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The version of this bStats class
|
||||
public static final int B_STATS_VERSION = 1;
|
||||
|
||||
// The url to which the data is sent
|
||||
private static final String URL = "https://bStats.org/submitData/bungeecord";
|
||||
|
||||
// The plugin
|
||||
private final Plugin plugin;
|
||||
|
||||
// The plugin id
|
||||
private final int pluginId;
|
||||
|
||||
// Is bStats enabled on this server?
|
||||
private boolean enabled;
|
||||
|
||||
// The uuid of the server
|
||||
private String serverUUID;
|
||||
|
||||
// Should failed requests be logged?
|
||||
private boolean logFailedRequests = false;
|
||||
|
||||
// Should the sent data be logged?
|
||||
private static boolean logSentData;
|
||||
|
||||
// Should the response text be logged?
|
||||
private static boolean logResponseStatusText;
|
||||
|
||||
// A list with all known metrics class objects including this one
|
||||
private static final List<Object> knownMetricsInstances = new ArrayList<>();
|
||||
|
||||
// A list with all custom charts
|
||||
private final List<CustomChart> charts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param plugin The plugin which stats should be submitted.
|
||||
* @param pluginId The id of the plugin. It can be found at
|
||||
* <a href="https://bstats.org/what-is-my-plugin-id">What is my
|
||||
* plugin id?</a>
|
||||
*/
|
||||
public BStatsMetricsBungee(Plugin plugin, int pluginId) {
|
||||
this.plugin = plugin;
|
||||
this.pluginId = pluginId;
|
||||
|
||||
try {
|
||||
loadConfig();
|
||||
} catch (IOException e) {
|
||||
// Failed to load configuration
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to load bStats config!", e);
|
||||
return;
|
||||
}
|
||||
|
||||
// We are not allowed to send data about this server :(
|
||||
if (!enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
Class<?> usedMetricsClass = getFirstBStatsClass();
|
||||
if (usedMetricsClass == null) {
|
||||
// Failed to get first metrics class
|
||||
return;
|
||||
}
|
||||
if (usedMetricsClass == getClass()) {
|
||||
// We are the first! :)
|
||||
linkMetrics(this);
|
||||
startSubmitting();
|
||||
} else {
|
||||
// We aren't the first so we link to the first metrics class
|
||||
try {
|
||||
usedMetricsClass.getMethod("linkMetrics", Object.class).invoke(null, this);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING,
|
||||
"Failed to link to first metrics class " + usedMetricsClass.getName() + "!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if bStats is enabled.
|
||||
*
|
||||
* @return Whether bStats is enabled or not.
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom chart.
|
||||
*
|
||||
* @param chart The chart to add.
|
||||
*/
|
||||
public void addCustomChart(CustomChart chart) {
|
||||
if (chart == null) {
|
||||
plugin.getLogger().log(Level.WARNING, "Chart cannot be null");
|
||||
}
|
||||
charts.add(chart);
|
||||
}
|
||||
|
||||
/**
|
||||
* Links an other metrics class with this class. This method is called using
|
||||
* Reflection.
|
||||
*
|
||||
* @param metrics An object of the metrics class to link.
|
||||
*/
|
||||
public static void linkMetrics(Object metrics) {
|
||||
knownMetricsInstances.add(metrics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the plugin specific data. This method is called using Reflection.
|
||||
*
|
||||
* @return The plugin specific data.
|
||||
*/
|
||||
public JsonObject getPluginData() {
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
String pluginName = plugin.getDescription().getName();
|
||||
String pluginVersion = plugin.getDescription().getVersion();
|
||||
|
||||
data.addProperty("pluginName", pluginName);
|
||||
data.addProperty("id", pluginId);
|
||||
data.addProperty("pluginVersion", pluginVersion);
|
||||
|
||||
JsonArray customCharts = new JsonArray();
|
||||
for (CustomChart customChart : charts) {
|
||||
// Add the data of the custom charts
|
||||
JsonObject chart = customChart.getRequestJsonObject(plugin.getLogger(), logFailedRequests);
|
||||
if (chart == null) { // If the chart is null, we skip it
|
||||
continue;
|
||||
}
|
||||
customCharts.add(chart);
|
||||
}
|
||||
data.add("customCharts", customCharts);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private void startSubmitting() {
|
||||
// The data collection is async, as well as sending the data
|
||||
// Bungeecord does not have a main thread, everything is async
|
||||
plugin.getProxy().getScheduler().schedule(plugin, this::submitData, 2, 30, TimeUnit.MINUTES);
|
||||
// Submit the data every 30 minutes, first time after 2 minutes to give other
|
||||
// plugins enough time to start
|
||||
// WARNING: Changing the frequency has no effect but your plugin WILL be
|
||||
// blocked/deleted!
|
||||
// WARNING: Just don't do it!
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the server specific data.
|
||||
*
|
||||
* @return The server specific data.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private JsonObject getServerData() {
|
||||
// Minecraft specific data
|
||||
int playerAmount = Math.min(plugin.getProxy().getOnlineCount(), 500);
|
||||
int onlineMode = plugin.getProxy().getConfig().isOnlineMode() ? 1 : 0;
|
||||
String bungeecordVersion = plugin.getProxy().getVersion();
|
||||
int managedServers = plugin.getProxy().getServers().size();
|
||||
|
||||
// OS/Java specific data
|
||||
String javaVersion = System.getProperty("java.version");
|
||||
String osName = System.getProperty("os.name");
|
||||
String osArch = System.getProperty("os.arch");
|
||||
String osVersion = System.getProperty("os.version");
|
||||
int coreCount = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
JsonObject data = new JsonObject();
|
||||
|
||||
data.addProperty("serverUUID", serverUUID);
|
||||
|
||||
data.addProperty("playerAmount", playerAmount);
|
||||
data.addProperty("managedServers", managedServers);
|
||||
data.addProperty("onlineMode", onlineMode);
|
||||
data.addProperty("bungeecordVersion", bungeecordVersion);
|
||||
|
||||
data.addProperty("javaVersion", javaVersion);
|
||||
data.addProperty("osName", osName);
|
||||
data.addProperty("osArch", osArch);
|
||||
data.addProperty("osVersion", osVersion);
|
||||
data.addProperty("coreCount", coreCount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects the data and sends it afterwards.
|
||||
*/
|
||||
private void submitData() {
|
||||
final JsonObject data = getServerData();
|
||||
|
||||
final JsonArray pluginData = new JsonArray();
|
||||
// Search for all other bStats Metrics classes to get their plugin data
|
||||
for (Object metrics : knownMetricsInstances) {
|
||||
try {
|
||||
Object plugin = metrics.getClass().getMethod("getPluginData").invoke(metrics);
|
||||
if (plugin instanceof JsonObject) {
|
||||
pluginData.add((JsonObject) plugin);
|
||||
}
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
data.add("plugins", pluginData);
|
||||
|
||||
try {
|
||||
// Send the data
|
||||
sendData(plugin, data);
|
||||
} catch (Exception e) {
|
||||
// Something went wrong! :(
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats!", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the bStats configuration.
|
||||
*
|
||||
* @throws IOException If something did not work :(
|
||||
*/
|
||||
private void loadConfig() throws IOException {
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
bStatsFolder.mkdirs();
|
||||
File configFile = new File(bStatsFolder, "config.yml");
|
||||
if (!configFile.exists()) {
|
||||
writeFile(configFile,
|
||||
"#bStats collects some data for plugin authors like how many servers are using their plugins.",
|
||||
"#To honor their work, you should not disable it.",
|
||||
"#This has nearly no effect on the server performance!",
|
||||
"#Check out https://bStats.org/ to learn more :)", "enabled: true",
|
||||
"serverUuid: \"" + UUID.randomUUID() + "\"", "logFailedRequests: false", "logSentData: false",
|
||||
"logResponseStatusText: false");
|
||||
}
|
||||
|
||||
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
|
||||
|
||||
// Load configuration
|
||||
enabled = configuration.getBoolean("enabled", true);
|
||||
serverUUID = configuration.getString("serverUuid");
|
||||
logFailedRequests = configuration.getBoolean("logFailedRequests", false);
|
||||
logSentData = configuration.getBoolean("logSentData", false);
|
||||
logResponseStatusText = configuration.getBoolean("logResponseStatusText", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the first bStat Metrics class.
|
||||
*
|
||||
* @return The first bStats metrics class.
|
||||
*/
|
||||
private Class<?> getFirstBStatsClass() {
|
||||
File bStatsFolder = new File(plugin.getDataFolder().getParentFile(), "bStats");
|
||||
bStatsFolder.mkdirs();
|
||||
File tempFile = new File(bStatsFolder, "temp.txt");
|
||||
|
||||
try {
|
||||
String className = readFile(tempFile);
|
||||
if (className != null) {
|
||||
try {
|
||||
// Let's check if a class with the given name exists.
|
||||
return Class.forName(className);
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
}
|
||||
}
|
||||
writeFile(tempFile, getClass().getName());
|
||||
return getClass();
|
||||
} catch (IOException e) {
|
||||
if (logFailedRequests) {
|
||||
plugin.getLogger().log(Level.WARNING, "Failed to get first bStats class!", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads the first line of the file.
|
||||
*
|
||||
* @param file The file to read. Cannot be null.
|
||||
* @return The first line of the file or {@code null} if the file does not exist
|
||||
* or is empty.
|
||||
* @throws IOException If something did not work :(
|
||||
*/
|
||||
private String readFile(File file) throws IOException {
|
||||
if (!file.exists()) {
|
||||
return null;
|
||||
}
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(file))) {
|
||||
return bufferedReader.readLine();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a String to a file. It also adds a note for the user,
|
||||
*
|
||||
* @param file The file to write to. Cannot be null.
|
||||
* @param lines The lines to write.
|
||||
* @throws IOException If something did not work :(
|
||||
*/
|
||||
private void writeFile(File file, String... lines) throws IOException {
|
||||
try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file))) {
|
||||
for (String line : lines) {
|
||||
bufferedWriter.write(line);
|
||||
bufferedWriter.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data to the bStats server.
|
||||
*
|
||||
* @param plugin Any plugin. It's just used to get a logger instance.
|
||||
* @param data The data to send.
|
||||
* @throws Exception If the request failed.
|
||||
*/
|
||||
private static void sendData(Plugin plugin, JsonObject data) throws Exception {
|
||||
if (data == null) {
|
||||
throw new IllegalArgumentException("Data cannot be null");
|
||||
}
|
||||
if (logSentData) {
|
||||
plugin.getLogger().info("Sending data to bStats: " + data);
|
||||
}
|
||||
|
||||
HttpsURLConnection connection = (HttpsURLConnection) new URL(URL).openConnection();
|
||||
|
||||
// Compress the data to save bandwidth
|
||||
byte[] compressedData = compress(data.toString());
|
||||
|
||||
// Add headers
|
||||
connection.setRequestMethod("POST");
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.addRequestProperty("Content-Encoding", "gzip"); // We gzip our request
|
||||
connection.addRequestProperty("Content-Length", String.valueOf(compressedData.length));
|
||||
connection.setRequestProperty("Content-Type", "application/json"); // We send our data in JSON format
|
||||
connection.setRequestProperty("User-Agent", "MC-Server/" + B_STATS_VERSION);
|
||||
|
||||
// Send data
|
||||
connection.setDoOutput(true);
|
||||
try (DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream())) {
|
||||
outputStream.write(compressedData);
|
||||
}
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
if (logResponseStatusText) {
|
||||
plugin.getLogger().info("Sent data to bStats and received response: " + builder);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gzips the given String.
|
||||
*
|
||||
* @param str The string to gzip.
|
||||
* @return The gzipped String.
|
||||
* @throws IOException If the compression failed.
|
||||
*/
|
||||
private static byte[] compress(final String str) throws IOException {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
try (GZIPOutputStream gzip = new GZIPOutputStream(outputStream)) {
|
||||
gzip.write(str.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
return outputStream.toByteArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom chart.
|
||||
*/
|
||||
public static abstract class CustomChart {
|
||||
|
||||
// The id of the chart
|
||||
private final String chartId;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
*/
|
||||
CustomChart(String chartId) {
|
||||
if (chartId == null || chartId.isEmpty()) {
|
||||
throw new IllegalArgumentException("ChartId cannot be null or empty!");
|
||||
}
|
||||
this.chartId = chartId;
|
||||
}
|
||||
|
||||
private JsonObject getRequestJsonObject(Logger logger, boolean logFailedRequests) {
|
||||
JsonObject chart = new JsonObject();
|
||||
chart.addProperty("chartId", chartId);
|
||||
try {
|
||||
JsonObject data = getChartData();
|
||||
if (data == null) {
|
||||
// If the data is null we don't send the chart.
|
||||
return null;
|
||||
}
|
||||
chart.add("data", data);
|
||||
} catch (Throwable t) {
|
||||
if (logFailedRequests) {
|
||||
logger.log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return chart;
|
||||
}
|
||||
|
||||
protected abstract JsonObject getChartData() throws Exception;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple pie.
|
||||
*/
|
||||
public static class SimplePie extends CustomChart {
|
||||
|
||||
private final Callable<String> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimplePie(String chartId, Callable<String> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
String value = callable.call();
|
||||
if (value == null || value.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced pie.
|
||||
*/
|
||||
public static class AdvancedPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedPie(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom drilldown pie.
|
||||
*/
|
||||
public static class DrilldownPie extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Map<String, Integer>>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public DrilldownPie(String chartId, Callable<Map<String, Map<String, Integer>>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Map<String, Integer>> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean reallyAllSkipped = true;
|
||||
for (Map.Entry<String, Map<String, Integer>> entryValues : map.entrySet()) {
|
||||
JsonObject value = new JsonObject();
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> valueEntry : map.get(entryValues.getKey()).entrySet()) {
|
||||
value.addProperty(valueEntry.getKey(), valueEntry.getValue());
|
||||
allSkipped = false;
|
||||
}
|
||||
if (!allSkipped) {
|
||||
reallyAllSkipped = false;
|
||||
values.add(entryValues.getKey(), value);
|
||||
}
|
||||
}
|
||||
if (reallyAllSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom single line chart.
|
||||
*/
|
||||
public static class SingleLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Integer> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SingleLineChart(String chartId, Callable<Integer> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
int value = callable.call();
|
||||
if (value == 0) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.addProperty("value", value);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom multi line chart.
|
||||
*/
|
||||
public static class MultiLineChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public MultiLineChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
if (entry.getValue() == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
values.addProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom simple bar chart.
|
||||
*/
|
||||
public static class SimpleBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, Integer>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public SimpleBarChart(String chartId, Callable<Map<String, Integer>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, Integer> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
categoryValues.add(new JsonPrimitive(entry.getValue()));
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom advanced bar chart.
|
||||
*/
|
||||
public static class AdvancedBarChart extends CustomChart {
|
||||
|
||||
private final Callable<Map<String, int[]>> callable;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*
|
||||
* @param chartId The id of the chart.
|
||||
* @param callable The callable which is used to request the chart data.
|
||||
*/
|
||||
public AdvancedBarChart(String chartId, Callable<Map<String, int[]>> callable) {
|
||||
super(chartId);
|
||||
this.callable = callable;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected JsonObject getChartData() throws Exception {
|
||||
JsonObject data = new JsonObject();
|
||||
JsonObject values = new JsonObject();
|
||||
Map<String, int[]> map = callable.call();
|
||||
if (map == null || map.isEmpty()) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
boolean allSkipped = true;
|
||||
for (Map.Entry<String, int[]> entry : map.entrySet()) {
|
||||
if (entry.getValue().length == 0) {
|
||||
continue; // Skip this invalid
|
||||
}
|
||||
allSkipped = false;
|
||||
JsonArray categoryValues = new JsonArray();
|
||||
for (int categoryValue : entry.getValue()) {
|
||||
categoryValues.add(new JsonPrimitive(categoryValue));
|
||||
}
|
||||
values.add(entry.getKey(), categoryValues);
|
||||
}
|
||||
if (allSkipped) {
|
||||
// Null = skip the chart
|
||||
return null;
|
||||
}
|
||||
data.add("values", values);
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeMessageData {
|
||||
|
||||
// Message string
|
||||
// alltimetotal//monthtotal//weeklytotal//dailytotal//points//milestonecount
|
||||
|
||||
@Getter
|
||||
private int allTimeTotal = 0;
|
||||
@Getter
|
||||
private int monthTotal = 0;
|
||||
@Getter
|
||||
private int weeklyTotal = 0;
|
||||
@Getter
|
||||
private int dailyTotal = 0;
|
||||
@Getter
|
||||
private int points = 0;
|
||||
@Getter
|
||||
private int milestoneCount = 0;
|
||||
|
||||
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]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return allTimeTotal + "//" + monthTotal + "//" + weeklyTotal + "//" + dailyTotal + "//" + points + "//"
|
||||
+ milestoneCount;
|
||||
}
|
||||
|
||||
public BungeeMessageData(int allTimeTotal, int monthTotal, int weeklyTotal, int dailyTotal, int points,
|
||||
int milestoneCount) {
|
||||
this.allTimeTotal = allTimeTotal;
|
||||
this.monthTotal = monthTotal;
|
||||
this.weeklyTotal = weeklyTotal;
|
||||
this.dailyTotal = dailyTotal;
|
||||
this.points = points;
|
||||
this.milestoneCount = milestoneCount;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
public enum BungeeMethod {
|
||||
MYSQL, PLUGINMESSAGING, SOCKETS;
|
||||
|
||||
public static BungeeMethod getByName(String str) {
|
||||
for (BungeeMethod method : values()) {
|
||||
if (method.toString().equalsIgnoreCase(str)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
return SOCKETS;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.ResultSetMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.advancedcore.api.user.userstorage.mysql.api.queries.Query;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.DataType;
|
||||
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
public class BungeeMySQL {
|
||||
private List<String> columns = Collections.synchronizedList(new ArrayList<String>());
|
||||
|
||||
private List<String> intColumns = new ArrayList<String>();
|
||||
|
||||
// private HashMap<String, ArrayList<Column>> table;
|
||||
|
||||
// ConcurrentMap<String, ArrayList<Column>> table = new
|
||||
// ConcurrentHashMap<String, ArrayList<Column>>();
|
||||
|
||||
private com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL mysql;
|
||||
|
||||
private String name;
|
||||
|
||||
private Object object2 = new Object();
|
||||
|
||||
private Object object3 = new Object();
|
||||
|
||||
private Object object4 = new Object();
|
||||
|
||||
private Set<String> uuids = Collections.synchronizedSet(new HashSet<String>());
|
||||
|
||||
public BungeeMySQL(String tableName, Configuration section) {
|
||||
String tablePrefix = section.getString("Prefix");
|
||||
String hostName = section.getString("Host");
|
||||
int port = section.getInt("Port");
|
||||
String user = section.getString("Username");
|
||||
String pass = section.getString("Password");
|
||||
String database = section.getString("Database");
|
||||
long lifeTime = section.getLong("MaxLifeTime", -1);
|
||||
int maxThreads = section.getInt("MaxConnections", 1);
|
||||
String str = section.getString("Line", "");
|
||||
if (maxThreads < 1) {
|
||||
maxThreads = 1;
|
||||
}
|
||||
boolean useSSL = section.getBoolean("UseSSL", false);
|
||||
boolean publicKeyRetrieval = section.getBoolean("PublicKeyRetrieval", false);
|
||||
if (!section.getString("Name", "").isEmpty()) {
|
||||
tableName = section.getString("Name", "");
|
||||
}
|
||||
|
||||
name = tableName;
|
||||
if (tablePrefix != null) {
|
||||
name = tablePrefix + tableName;
|
||||
}
|
||||
mysql = new com.bencodez.advancedcore.api.user.userstorage.mysql.api.MySQL(maxThreads);
|
||||
if (!mysql.connect(hostName, "" + port, user, pass, database, useSSL, lifeTime, str, publicKeyRetrieval)) {
|
||||
|
||||
}
|
||||
try {
|
||||
Query q = new Query(mysql, "USE " + database + ";");
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String sql = "CREATE TABLE IF NOT EXISTS " + getName() + " (";
|
||||
sql += "uuid VARCHAR(37),";
|
||||
sql += "PRIMARY KEY ( uuid )";
|
||||
sql += ");";
|
||||
Query query;
|
||||
try {
|
||||
query = new Query(mysql, sql);
|
||||
|
||||
query.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
loadData();
|
||||
|
||||
// tempoary to improve performance from old tables
|
||||
// addToQue("ALTER TABLE " + getName() + " MODIFY uuid VARCHAR(37);");
|
||||
alterColumnType("uuid", "VARCHAR(37)");
|
||||
}
|
||||
|
||||
public void addColumn(String column, DataType dataType) {
|
||||
synchronized (object3) {
|
||||
String sql = "ALTER TABLE " + getName() + " ADD COLUMN " + column + " text" + ";";
|
||||
try {
|
||||
Query query = new Query(mysql, sql);
|
||||
query.executeUpdate();
|
||||
|
||||
getColumns().add(column);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void alterColumnType(String column, String newType) {
|
||||
checkColumn(column, DataType.STRING);
|
||||
if (newType.contains("INT")) {
|
||||
try {
|
||||
new Query(mysql, "UPDATE " + getName() + " SET " + column + " = '0' where trim(coalesce(" + column
|
||||
+ ", '')) = '';").executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
;
|
||||
if (!intColumns.contains(column)) {
|
||||
intColumns.add(column);
|
||||
}
|
||||
}
|
||||
try {
|
||||
new Query(mysql, "ALTER TABLE " + getName() + " MODIFY " + column + " " + newType + ";")
|
||||
.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void checkColumn(String column, DataType dataType) {
|
||||
synchronized (object4) {
|
||||
if (!getColumns().contains(column)) {
|
||||
if (!getColumnsQueury().contains(column)) {
|
||||
addColumn(column, dataType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
clearCacheBasic();
|
||||
}
|
||||
|
||||
public void clearCacheBasic() {
|
||||
columns.clear();
|
||||
columns.addAll(getColumnsQueury());
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
}
|
||||
|
||||
public void close() {
|
||||
mysql.disconnect();
|
||||
}
|
||||
|
||||
public boolean containsKeyQuery(String index) {
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
while (rs.next()) {
|
||||
if (rs.getString("uuid").equals(index)) {
|
||||
rs.close();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> getColumns() {
|
||||
if (columns == null || columns.size() == 0) {
|
||||
loadData();
|
||||
}
|
||||
return columns;
|
||||
}
|
||||
|
||||
public ArrayList<String> getColumnsQueury() {
|
||||
ArrayList<String> columns = new ArrayList<String>();
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement("SELECT * FROM " + getName() + ";")) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, "SELECT * FROM " + getName() + ";"); ResultSet
|
||||
* rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
ResultSetMetaData metadata = rs.getMetaData();
|
||||
int columnCount = 0;
|
||||
if (metadata != null) {
|
||||
columnCount = metadata.getColumnCount();
|
||||
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String columnName = metadata.getColumnName(i);
|
||||
columns.add(columnName);
|
||||
}
|
||||
rs.close();
|
||||
return columns;
|
||||
}
|
||||
rs.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return columns;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<Column> getExactQuery(Column column) {
|
||||
ArrayList<Column> result = new ArrayList<>();
|
||||
String query = "SELECT * FROM " + getName() + " WHERE `" + column.getName() + "`='"
|
||||
+ column.getValue().toString() + "';";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); sql.setParameter(1,
|
||||
* column.getValue().toString()); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= rs.getMetaData().getColumnCount(); i++) {
|
||||
String columnName = rs.getMetaData().getColumnLabel(i);
|
||||
Column rCol = null;
|
||||
if (intColumns.contains(columnName)) {
|
||||
rCol = new Column(columnName, DataType.INTEGER);
|
||||
} else {
|
||||
rCol = new Column(columnName, DataType.STRING);
|
||||
}
|
||||
// System.out.println(i + " " +
|
||||
// rs.getMetaData().getColumnLabel(i));
|
||||
rCol.setValue(rs.getString(i));
|
||||
// System.out.println(rCol.getValue());
|
||||
result.add(rCol);
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
return result;
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
|
||||
for (String col : getColumns()) {
|
||||
result.add(new Column(col, DataType.STRING));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public ArrayList<String> getNamesQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
|
||||
checkColumn("PlayerName", DataType.STRING);
|
||||
ArrayList<Column> rows = getRowsNameQuery();
|
||||
if (rows != null) {
|
||||
for (Column c : rows) {
|
||||
uuids.add((String) c.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsNameQuery() {
|
||||
ArrayList<Column> result = new ArrayList<Column>();
|
||||
String sqlStr = "SELECT PlayerName FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("PlayerName", rs.getString("PlayerName"), DataType.STRING);
|
||||
result.add(rCol);
|
||||
}
|
||||
sql.close();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public ArrayList<Column> getRowsQuery() {
|
||||
ArrayList<Column> result = new ArrayList<Column>();
|
||||
String sqlStr = "SELECT uuid FROM " + getName() + ";";
|
||||
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(sqlStr)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query query = new Query(mysql, sql); ResultSet rs = query.executeQuery();
|
||||
*/
|
||||
|
||||
while (rs.next()) {
|
||||
Column rCol = new Column("uuid", rs.getString("uuid"), DataType.STRING);
|
||||
result.add(rCol);
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
String query = "SELECT uuid FROM " + getName() + " WHERE " + "PlayerName" + "='" + playerName + "';";
|
||||
try (Connection conn = mysql.getConnectionManager().getConnection();
|
||||
PreparedStatement sql = conn.prepareStatement(query)) {
|
||||
ResultSet rs = sql.executeQuery();
|
||||
/*
|
||||
* Query sql = new Query(mysql, query); ResultSet rs = sql.executeQuery();
|
||||
*/
|
||||
if (rs.next()) {
|
||||
String uuid = rs.getString("uuid");
|
||||
if (uuid != null && !uuid.isEmpty()) {
|
||||
rs.close();
|
||||
return uuid;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set<String> getUuids() {
|
||||
if (uuids == null || uuids.size() == 0) {
|
||||
uuids.clear();
|
||||
uuids.addAll(getUuidsQuery());
|
||||
return uuids;
|
||||
}
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public ArrayList<String> getUuidsQuery() {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
|
||||
ArrayList<Column> rows = getRowsQuery();
|
||||
for (Column c : rows) {
|
||||
uuids.add((String) c.getValue());
|
||||
}
|
||||
|
||||
return uuids;
|
||||
}
|
||||
|
||||
public void insert(String index, String column, Object value, DataType dataType) {
|
||||
insertQuery(index, Arrays.asList(new Column(column, value, dataType)));
|
||||
}
|
||||
|
||||
public void insertQuery(String index, List<Column> cols) {
|
||||
String query = "INSERT " + getName() + " ";
|
||||
|
||||
query += "set uuid='" + index + "', ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "';";
|
||||
} else {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "', ";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
uuids.add(index);
|
||||
new Query(mysql, query).executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean isIntColumn(String key) {
|
||||
return intColumns.contains(key);
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
columns = getColumnsQueury();
|
||||
}
|
||||
|
||||
public void update(String index, List<Column> cols, boolean queue) {
|
||||
for (Column col : cols) {
|
||||
checkColumn(col.getName(), col.getDataType());
|
||||
}
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
for (int i = 0; i < cols.size(); i++) {
|
||||
Column col = cols.get(i);
|
||||
if (i == cols.size() - 1) {
|
||||
if (col.getDataType().equals(DataType.STRING)) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "';";
|
||||
} else {
|
||||
query += col.getName() + "=" + col.getValue().toString() + ";";
|
||||
}
|
||||
} else {
|
||||
if (col.getDataType().equals(DataType.STRING)) {
|
||||
query += col.getName() + "='" + col.getValue().toString() + "', ";
|
||||
} else {
|
||||
query += col.getName() + "=" + col.getValue().toString() + ", ";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdateAsync();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
insertQuery(index, cols);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(String index, String column, Object value, DataType dataType) {
|
||||
checkColumn(column, dataType);
|
||||
if (getUuids().contains(index)) {
|
||||
synchronized (object2) {
|
||||
String query = "UPDATE " + getName() + " SET ";
|
||||
|
||||
if (dataType == DataType.STRING) {
|
||||
query += column + "='" + value.toString() + "'";
|
||||
} else {
|
||||
query += column + "=" + value;
|
||||
|
||||
}
|
||||
query += " WHERE `uuid`=";
|
||||
query += "'" + index + "';";
|
||||
|
||||
try {
|
||||
Query q = new Query(mysql, query);
|
||||
q.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
insert(index, column, value, dataType);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
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 List<String> getBlockedServers() {
|
||||
return getData().getStringList("BlockedServers");
|
||||
}
|
||||
|
||||
public boolean getBroadcast() {
|
||||
return getData().getBoolean("Broadcast", false);
|
||||
}
|
||||
|
||||
public boolean getAllowUnJoined() {
|
||||
return getData().getBoolean("AllowUnJoined",false);
|
||||
}
|
||||
|
||||
public String getBungeeHost() {
|
||||
return getData().getString("BungeeServer.Host", "");
|
||||
}
|
||||
|
||||
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 String getFallBack() {
|
||||
return getData().getString("FallBackServer", "");
|
||||
}
|
||||
|
||||
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 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
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.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());
|
||||
}
|
||||
}
|
||||
|
||||
private void addPlayer(String uuid, String playerName) {
|
||||
getData().set("NonVotedPlayers." + playerName + ".UUID", uuid);
|
||||
getData().set("NonVotedPlayers." + playerName + ".LastTime", System.currentTimeMillis());
|
||||
}
|
||||
|
||||
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 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 file = new File(bungee.getDataFolder(), "nonvotedplayerscache.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "nonvotedplayerscache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
|
||||
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 VoteCache {
|
||||
private VotingPluginBungee bungee;
|
||||
@Getter
|
||||
private Configuration data;
|
||||
|
||||
public VoteCache(VotingPluginBungee bungee) {
|
||||
this.bungee = bungee;
|
||||
}
|
||||
|
||||
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());
|
||||
save();
|
||||
}
|
||||
|
||||
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());
|
||||
save();
|
||||
}
|
||||
|
||||
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 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 file = new File(bungee.getDataFolder(), "votecache.yml");
|
||||
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
data = ConfigurationProvider.getProvider(YamlConfiguration.class)
|
||||
.load(new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
try {
|
||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(data,
|
||||
new File(bungee.getDataFolder(), "votecache.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,675 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.encryption.EncryptionHandler;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.Column;
|
||||
import com.bencodez.advancedcore.api.user.userstorage.sql.DataType;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.ClientHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketHandler;
|
||||
import com.bencodez.advancedcore.bungeeapi.sockets.SocketReceiver;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.vexsoftware.votifier.bungee.events.VotifierEvent;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
public class VotingPluginBungee extends Plugin implements net.md_5.bungee.api.plugin.Listener {
|
||||
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedOnlineVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<String, ArrayList<OfflineBungeeVote>> cachedVotes = new HashMap<String, ArrayList<OfflineBungeeVote>>();
|
||||
|
||||
private HashMap<String, ClientHandler> clientHandles;
|
||||
|
||||
@Getter
|
||||
private Config config;
|
||||
|
||||
private EncryptionHandler encryptionHandler;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
@Getter
|
||||
private BungeeMySQL mysql;
|
||||
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
private VoteCache voteCacheFile;
|
||||
|
||||
private NonVotedPlayersCache nonVotedPlayersCache;
|
||||
|
||||
public void checkCachedVotes(String server) {
|
||||
if (getProxy().getServerInfo(server) != null) {
|
||||
if (!getProxy().getServerInfo(server).getPlayers().isEmpty()) {
|
||||
if (cachedVotes.containsKey(server) && !config.getBlockedServers().contains(server)) {
|
||||
ArrayList<OfflineBungeeVote> c = cachedVotes.get(server);
|
||||
if (!c.isEmpty()) {
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendPluginMessageServer(server, "Vote", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText());
|
||||
}
|
||||
cachedVotes.put(server, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkOnlineVotes(ProxiedPlayer player, String uuid, String server) {
|
||||
if (player != null && player.isConnected() && cachedOnlineVotes.containsKey(uuid)) {
|
||||
ArrayList<OfflineBungeeVote> c = cachedOnlineVotes.get(uuid);
|
||||
if (!c.isEmpty()) {
|
||||
if (server == null) {
|
||||
server = getProxy().getPlayer(UUID.fromString(uuid)).getServer().getInfo().getName();
|
||||
}
|
||||
if (!config.getBlockedServers().contains(server)) {
|
||||
for (OfflineBungeeVote cache : c) {
|
||||
sendPluginMessageServer(server, "VoteOnline", cache.getPlayerName(), cache.getUuid(),
|
||||
cache.getService(), "" + cache.getTime(), Boolean.FALSE.toString(),
|
||||
"" + cache.isRealVote(), cache.getText());
|
||||
}
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void debug(String msg) {
|
||||
if (config.getDebug()) {
|
||||
getLogger().info("Debug: " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID fetchUUID(String playerName) throws Exception {
|
||||
// Get response from Mojang API
|
||||
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + playerName);
|
||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||
connection.connect();
|
||||
|
||||
if (connection.getResponseCode() == 400) {
|
||||
getProxy().getLogger().info("There is no player with the name \"" + playerName + "\"!");
|
||||
return null;
|
||||
}
|
||||
|
||||
InputStream inputStream = connection.getInputStream();
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
|
||||
|
||||
// Parse JSON response and get UUID
|
||||
JsonElement element = new JsonParser().parse(bufferedReader);
|
||||
JsonObject object = element.getAsJsonObject();
|
||||
String uuidAsString = object.get("id").getAsString();
|
||||
|
||||
// Return UUID
|
||||
return parseUUIDFromString(uuidAsString);
|
||||
}
|
||||
|
||||
public String getProperName(String uuid, String currentName) {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if (p != null && p.isConnected()) {
|
||||
return p.getName();
|
||||
}
|
||||
return currentName;
|
||||
}
|
||||
|
||||
public String getUUID(String playerName) {
|
||||
ProxiedPlayer p = getProxy().getPlayer(playerName);
|
||||
if (p != null && p.isConnected()) {
|
||||
return p.getUniqueId().toString();
|
||||
}
|
||||
String str = mysql.getUUID(playerName);
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
if (nonVotedPlayersCache != null) {
|
||||
return nonVotedPlayersCache.playerExists(playerName);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
private int getValue(ArrayList<Column> cols, String column) {
|
||||
for (Column d : cols) {
|
||||
if (d.getName().equalsIgnoreCase(column)) {
|
||||
|
||||
Object value = d.getValue();
|
||||
int num = 0;
|
||||
if (value instanceof Integer) {
|
||||
try {
|
||||
num = (int) value;
|
||||
} catch (ClassCastException | NullPointerException ex) {
|
||||
}
|
||||
} else if (value instanceof String) {
|
||||
try {
|
||||
num = Integer.parseInt((String) value);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int mysqlUpdate(ArrayList<Column> cols, String uuid, String column, int toAdd) {
|
||||
int num = getValue(cols, column) + toAdd;
|
||||
debug("Setting " + column + " to " + num + " for " + uuid);
|
||||
mysql.update(uuid, column, num, DataType.INTEGER);
|
||||
return num;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedVotes.entrySet()) {
|
||||
String server = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVote(server, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
for (Entry<String, ArrayList<OfflineBungeeVote>> entry : cachedOnlineVotes.entrySet()) {
|
||||
String name = entry.getKey();
|
||||
int num = 0;
|
||||
for (OfflineBungeeVote voteData : entry.getValue()) {
|
||||
voteCacheFile.addVoteOnline(name, num, voteData);
|
||||
num++;
|
||||
}
|
||||
}
|
||||
nonVotedPlayersCache.save();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getProxy().getPluginManager().registerListener(this, this);
|
||||
config = new Config(this);
|
||||
config.load();
|
||||
|
||||
mysql = new BungeeMySQL("VotingPlugin_Users", config.getData());
|
||||
|
||||
// column types
|
||||
getMysql().alterColumnType("TopVoterIgnore", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("CheckWorld", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("Reminded", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("DisableBroadcast", "VARCHAR(5)");
|
||||
getMysql().alterColumnType("LastOnline", "VARCHAR(20)");
|
||||
getMysql().alterColumnType("PlayerName", "VARCHAR(30)");
|
||||
getMysql().alterColumnType("DailyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("WeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("DayVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("BestDayVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("WeekVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("BestWeekVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("VotePartyVotes", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("MonthVoteStreak", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("Points", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestDailyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("AllTimeTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestMonthlyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("MilestoneCount", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("MonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("HighestWeeklyTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("LastMonthTotal", "INT DEFAULT '0'");
|
||||
getMysql().alterColumnType("OfflineRewards", "MEDIUMTEXT");
|
||||
|
||||
getProxy().getPluginManager().registerCommand(this, new VotingPluginBungeeCommand(this));
|
||||
|
||||
method = BungeeMethod.getByName(config.getBungeeMethod());
|
||||
if (method == null) {
|
||||
method = BungeeMethod.PLUGINMESSAGING;
|
||||
}
|
||||
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
if (method.equals(BungeeMethod.MYSQL)) {
|
||||
// this.getProxy().registerChannel("vp:vp");
|
||||
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
voteCacheFile = new VoteCache(this);
|
||||
voteCacheFile.load();
|
||||
|
||||
nonVotedPlayersCache = new NonVotedPlayersCache(this);
|
||||
nonVotedPlayersCache.load();
|
||||
|
||||
try {
|
||||
for (String server : voteCacheFile.getServers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getServerVotes(server)) {
|
||||
Configuration data = voteCacheFile.getServerVotes(server, num);
|
||||
vote.add(new OfflineBungeeVote(data.getString("Name"), data.getString("UUID"),
|
||||
data.getString("Service"), data.getLong("Time"), data.getBoolean("Real"),
|
||||
data.getString("Text")));
|
||||
}
|
||||
cachedVotes.put(server, vote);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
for (String player : voteCacheFile.getPlayers()) {
|
||||
ArrayList<OfflineBungeeVote> vote = new ArrayList<OfflineBungeeVote>();
|
||||
for (String num : voteCacheFile.getServerVotes(player)) {
|
||||
Configuration data = voteCacheFile.getOnlineVotes(player, num);
|
||||
vote.add(new OfflineBungeeVote(data.getString("Name"), data.getString("UUID"),
|
||||
data.getString("Service"), data.getLong("Time"), data.getBoolean("Real"),
|
||||
data.getString("Text")));
|
||||
}
|
||||
cachedOnlineVotes.put(player, vote);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
voteCacheFile.clearData();
|
||||
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (String server : cachedVotes.keySet()) {
|
||||
checkCachedVotes(server);
|
||||
}
|
||||
|
||||
for (String player : cachedOnlineVotes.keySet()) {
|
||||
checkOnlineVotes(getProxy().getPlayer(UUID.fromString(player)), player, null);
|
||||
}
|
||||
}
|
||||
}, 15l, 30l, TimeUnit.SECONDS);
|
||||
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
debug("Checking nonvotedplayers.yml...");
|
||||
nonVotedPlayersCache.check();
|
||||
}
|
||||
}
|
||||
}, 1l, 60l, TimeUnit.MINUTES);
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(getDataFolder(), "secretkey.key"));
|
||||
|
||||
socketHandler = new SocketHandler(getDescription().getVersion(), config.getBungeeHost(),
|
||||
config.getBungeePort(), encryptionHandler, config.getDebug());
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data.length > 2) {
|
||||
if (data[0].equalsIgnoreCase("Broadcast")) {
|
||||
sendServerMessage(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver() {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 1) {
|
||||
if (data[0].equalsIgnoreCase("StatusOkay")) {
|
||||
String server = data[1];
|
||||
getLogger().info("Voting communicaton okay with " + server);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
clientHandles = new HashMap<String, ClientHandler>();
|
||||
List<String> l = config.getBlockedServers();
|
||||
for (String s : config.getSpigotServers()) {
|
||||
if (!l.contains(s)) {
|
||||
Configuration d = config.getSpigotServerConfiguration(s);
|
||||
clientHandles.put(s, new ClientHandler(d.getString("Host", ""), d.getInt("Port", 1298),
|
||||
encryptionHandler, config.getDebug()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BStatsMetricsBungee metrics = new BStatsMetricsBungee(this, 9453);
|
||||
|
||||
metrics.addCustomChart(
|
||||
new BStatsMetricsBungee.SimplePie("bungee_method", () -> getConfig().getBungeeMethod().toString()));
|
||||
|
||||
metrics.addCustomChart(new BStatsMetricsBungee.SimplePie("sendtoallservers",
|
||||
() -> "" + getConfig().getSendVotesToAllServers()));
|
||||
|
||||
getLogger().info("VotingPlugin loaded, using method: " + method.toString());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent ev) {
|
||||
if (!ev.getTag().equals("vp:vp".toLowerCase())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ev.setCancelled(true);
|
||||
|
||||
if (!(ev.getSender() instanceof Server))
|
||||
return;
|
||||
|
||||
ByteArrayInputStream instream = new ByteArrayInputStream(ev.getData());
|
||||
DataInputStream in = new DataInputStream(instream);
|
||||
try {
|
||||
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(outstream);
|
||||
String subchannel = in.readUTF();
|
||||
int size = in.readInt();
|
||||
|
||||
// check for status message returns
|
||||
if (subchannel.equalsIgnoreCase("statusokay")) {
|
||||
String server = in.readUTF();
|
||||
getLogger().info("Status okay for " + server);
|
||||
return;
|
||||
} else {
|
||||
// reforward message
|
||||
out.writeUTF(subchannel);
|
||||
out.writeInt(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
out.writeUTF(in.readUTF());
|
||||
}
|
||||
for (String send : getProxy().getServers().keySet()) {
|
||||
if (getProxy().getServers().get(send).getPlayers().size() > 0) {
|
||||
getProxy().getServers().get(send).sendData("vp:vp".toLowerCase(), outstream.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PostLoginEvent event) {
|
||||
if (nonVotedPlayersCache != null) {
|
||||
nonVotedPlayersCache.addPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
final String server = event.getServer().getInfo().getName();
|
||||
final String uuid = event.getPlayer().getUniqueId().toString();
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(event.getPlayer(), uuid, server);
|
||||
}
|
||||
|
||||
}, 2, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnected(ServerSwitchEvent event) {
|
||||
final String server = event.getPlayer().getServer().getInfo().getName();
|
||||
final String uuid = event.getPlayer().getUniqueId().toString();
|
||||
getProxy().getScheduler().schedule(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkCachedVotes(server);
|
||||
checkOnlineVotes(event.getPlayer(), uuid, server);
|
||||
}
|
||||
|
||||
}, 2, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVote(VotifierEvent event) {
|
||||
Vote vote = event.getVote();
|
||||
getLogger().info("Vote received " + vote.getUsername() + " from service site " + vote.getServiceName());
|
||||
|
||||
vote(vote.getUsername(), vote.getServiceName(), true);
|
||||
|
||||
}
|
||||
|
||||
private UUID parseUUIDFromString(String uuidAsString) {
|
||||
String[] parts = { "0x" + uuidAsString.substring(0, 8), "0x" + uuidAsString.substring(8, 12),
|
||||
"0x" + uuidAsString.substring(12, 16), "0x" + uuidAsString.substring(16, 20),
|
||||
"0x" + uuidAsString.substring(20, 32) };
|
||||
|
||||
long mostSigBits = Long.decode(parts[0]).longValue();
|
||||
mostSigBits <<= 16;
|
||||
mostSigBits |= Long.decode(parts[1]).longValue();
|
||||
mostSigBits <<= 16;
|
||||
mostSigBits |= Long.decode(parts[2]).longValue();
|
||||
|
||||
long leastSigBits = Long.decode(parts[3]).longValue();
|
||||
leastSigBits <<= 48;
|
||||
leastSigBits |= Long.decode(parts[4]).longValue();
|
||||
|
||||
return new UUID(mostSigBits, leastSigBits);
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
config.load();
|
||||
}
|
||||
|
||||
public void sendPluginMessageServer(String server, String channel, String... messageData) {
|
||||
ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(byteOutStream);
|
||||
try {
|
||||
out.writeUTF(channel);
|
||||
out.writeInt(messageData.length);
|
||||
for (String message : messageData) {
|
||||
out.writeUTF(message);
|
||||
}
|
||||
if (getProxy().getServers().get(server).getPlayers().size() > 0) {
|
||||
getProxy().getServers().get(server).sendData("vp:vp".toLowerCase(), byteOutStream.toByteArray(), false);
|
||||
}
|
||||
out.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
debug("Sending plugin message " + server + " " + channel + " "
|
||||
+ ArrayUtils.getInstance().makeStringList(ArrayUtils.getInstance().convert(messageData)));
|
||||
|
||||
}
|
||||
|
||||
public void sendServerMessage(String... messageData) {
|
||||
for (ClientHandler h : clientHandles.values()) {
|
||||
h.sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendServerMessageServer(String server, String... messageData) {
|
||||
if (clientHandles.containsKey(server)) {
|
||||
clientHandles.get(server).sendMessage(messageData);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendSocketVote(String name, String service, BungeeMessageData text) {
|
||||
String uuid = getUUID(name);
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
sendServerMessage("bungeevote", uuid, name, service, text.toString());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
} else {
|
||||
// online server only
|
||||
ProxiedPlayer p = getProxy().getPlayer(name);
|
||||
|
||||
String server = "";
|
||||
if (p != null && p.isConnected()) {
|
||||
server = p.getServer().getInfo().getName();
|
||||
} else {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
if (config.getBlockedServers().contains(server)) {
|
||||
server = config.getFallBack();
|
||||
}
|
||||
|
||||
sendServerMessageServer(server, "bungeevoteonline", uuid, name, service, text.toString());
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
sendServerMessage("BungeeUpdate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void status(CommandSender sender) {
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendServerMessage("status");
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
ServerInfo info = getProxy().getServerInfo(s);
|
||||
if (info.getPlayers().isEmpty()) {
|
||||
getLogger().info("No players on server " + s + " to send test status message");
|
||||
} else {
|
||||
// send
|
||||
getLogger().info("Sending request for status message on " + s);
|
||||
sendPluginMessageServer(s, "Status", s);
|
||||
}
|
||||
} else {
|
||||
getLogger().info("Ignoring blocked server " + s);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void vote(String player, String service, boolean realVote) {
|
||||
if (player == null || player.isEmpty()) {
|
||||
getLogger().info("No name from vote on " + service);
|
||||
return;
|
||||
}
|
||||
|
||||
String uuid = getUUID(player);
|
||||
if (uuid.isEmpty()) {
|
||||
if (config.getAllowUnJoined()) {
|
||||
UUID u = null;
|
||||
try {
|
||||
u = fetchUUID(player);
|
||||
} catch (Exception e) {
|
||||
if (getConfig().getDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (u == null) {
|
||||
debug("Failed to get uuid for " + player);
|
||||
return;
|
||||
}
|
||||
uuid = u.toString();
|
||||
} else {
|
||||
getLogger().info("Ignoring vote from " + player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
player = getProperName(uuid, player);
|
||||
|
||||
if (!mysql.getUuids().contains(uuid)) {
|
||||
mysql.update(uuid, "PlayerName", player, DataType.STRING);
|
||||
}
|
||||
|
||||
ArrayList<Column> data = mysql.getExactQuery(new Column("uuid", uuid, DataType.STRING));
|
||||
|
||||
BungeeMessageData text = new BungeeMessageData(mysqlUpdate(data, uuid, "AllTimeTotal", 1),
|
||||
mysqlUpdate(data, uuid, "MonthTotal", 1), mysqlUpdate(data, uuid, "WeeklyTotal", 1),
|
||||
mysqlUpdate(data, uuid, "DailyTotal", 1), mysqlUpdate(data, uuid, "Points", 1),
|
||||
mysqlUpdate(data, uuid, "MilestoneCount", 1));
|
||||
|
||||
/*
|
||||
* String text = mysqlUpdate(data, uuid, "AllTimeTotal", 1) + "//" +
|
||||
* mysqlUpdate(data, uuid, "MonthTotal", 1) + "//" + mysqlUpdate(data, uuid,
|
||||
* "WeeklyTotal", 1) + "//" + mysqlUpdate(data, uuid, "DailyTotal", 1) + "//" +
|
||||
* mysqlUpdate(data, uuid, "Points", 1) + "//" + mysqlUpdate(data, uuid,
|
||||
* "MilestoneCount", 1);
|
||||
*/
|
||||
|
||||
long time = LocalDateTime.now().atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
for (String s : getProxy().getServers().keySet()) {
|
||||
if (!config.getBlockedServers().contains(s)) {
|
||||
ServerInfo info = getProxy().getServerInfo(s);
|
||||
if (info.getPlayers().isEmpty()) {
|
||||
// cache
|
||||
if (!cachedVotes.containsKey(s)) {
|
||||
cachedVotes.put(s, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedVotes.get(s);
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedVotes.put(s, list);
|
||||
|
||||
debug("Caching vote for " + player + " on " + service + " for " + s);
|
||||
|
||||
} else {
|
||||
// send
|
||||
sendPluginMessageServer(s, "Vote", player, uuid, service, "" + time,
|
||||
Boolean.TRUE.toString(), "" + realVote, text.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ProxiedPlayer p = getProxy().getPlayer(UUID.fromString(uuid));
|
||||
if (p != null && p.isConnected()
|
||||
&& !config.getBlockedServers().contains(p.getServer().getInfo().getName())) {
|
||||
sendPluginMessageServer(p.getServer().getInfo().getName(), "VoteOnline", player, uuid, service,
|
||||
"" + time, Boolean.TRUE.toString(), "" + realVote, text.toString());
|
||||
} else {
|
||||
if (!cachedOnlineVotes.containsKey(uuid)) {
|
||||
cachedOnlineVotes.put(uuid, new ArrayList<OfflineBungeeVote>());
|
||||
}
|
||||
ArrayList<OfflineBungeeVote> list = cachedOnlineVotes.get(uuid);
|
||||
if (list == null) {
|
||||
list = new ArrayList<OfflineBungeeVote>();
|
||||
}
|
||||
list.add(new OfflineBungeeVote(player, uuid, service, time, realVote, text.toString()));
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
}
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service, text);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.bencodez.votingplugin.bungee;
|
||||
|
||||
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();
|
||||
sender.sendMessage(new TextComponent("Reloading VotingPluginBungee"));
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("vote")) {
|
||||
if (args.length >= 2) {
|
||||
String user = args[1];
|
||||
String site = args[2];
|
||||
bungee.vote(user, site, false);
|
||||
sender.sendMessage(new TextComponent("Sending vote"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("status")) {
|
||||
if (bungee.getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
sender.sendMessage(new TextComponent(
|
||||
"Checking status, waiting for response, check console, method: sockets"));
|
||||
bungee.status(sender);
|
||||
} else if (bungee.getMethod().equals(BungeeMethod.PLUGINMESSAGING)){
|
||||
sender.sendMessage(new TextComponent(
|
||||
"Checking status, waiting for response, check console, method: plugin messaging"));
|
||||
bungee.status(sender);
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("Not using socket/pluginmessage method, command unavailable"));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("help")) {
|
||||
TextComponent[] msg = new TextComponent[3];
|
||||
msg[0] = new TextComponent("&avotingpluginbungee reload - Reload plugin");
|
||||
msg[1] = new TextComponent("&avotingpluginbungee vote (player) (servicesite) - Send bungee vote");
|
||||
msg[2] = new TextComponent("&avotingplugin status - Check socket connection status");
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(new TextComponent("You do not have permission to do this!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,44 @@
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAdminVote.
|
||||
*/
|
||||
public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public CommandAdminVote(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (CommandHandler commandHandler : plugin.getAdminVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+100
-100
@@ -1,100 +1,100 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.Executers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAliases.
|
||||
*/
|
||||
public class CommandAliases implements CommandExecutor {
|
||||
|
||||
/** The plugin. */
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
/** The cmd handle. */
|
||||
private CommandHandler cmdHandle;
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
public CommandAliases(CommandHandler cmdHandle, boolean adminCommand) {
|
||||
this.cmdHandle = cmdHandle;
|
||||
this.adminCommand = adminCommand;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
ArrayList<String> argsNew = new ArrayList<String>();
|
||||
argsNew.add(cmdHandle.getArgs()[0]);
|
||||
for (String arg : args) {
|
||||
argsNew.add(arg);
|
||||
}
|
||||
plugin.debug("Attempting cmd...");
|
||||
plugin.debug("Inputed args: " + ArrayUtils.getInstance().makeStringList(argsNew));
|
||||
|
||||
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.adminVoteCommand);
|
||||
} else {
|
||||
handles.addAll(plugin.voteCommand);
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : handles) {
|
||||
if (cmdHandle.getArgs().length > args.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
argsNew.set(0, arg);
|
||||
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argsNew.size(); i++) {
|
||||
if (i < cmdHandle.getArgs().length) {
|
||||
if (!cmdHandle.argsMatch(argsNew.get(i), i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
if (cmdHandle.runCommand(sender, ArrayUtils.getInstance().convert(argsNew))) {
|
||||
plugin.debug("cmd found, ran cmd");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* for (String arg : cmdHandle.getArgs()[0].split("&")) { argsNew.set(0, arg);
|
||||
* if (cmdHandle.runCommand(sender, Utils.getInstance().convertArray(argsNew)))
|
||||
* { plugin.debug( "cmd found, ran cmd"); return true; } }
|
||||
*/
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAliases.
|
||||
*/
|
||||
public class CommandAliases implements CommandExecutor {
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
/** The cmd handle. */
|
||||
private CommandHandler cmdHandle;
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
public CommandAliases(CommandHandler cmdHandle, boolean adminCommand) {
|
||||
this.cmdHandle = cmdHandle;
|
||||
this.adminCommand = adminCommand;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
ArrayList<String> argsNew = new ArrayList<String>();
|
||||
argsNew.add(cmdHandle.getArgs()[0]);
|
||||
for (String arg : args) {
|
||||
argsNew.add(arg);
|
||||
}
|
||||
plugin.debug("Attempting cmd...");
|
||||
plugin.debug("Inputed args: " + ArrayUtils.getInstance().makeStringList(argsNew));
|
||||
|
||||
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
handles.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : handles) {
|
||||
if (cmdHandle.getArgs().length > args.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
argsNew.set(0, arg);
|
||||
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argsNew.size(); i++) {
|
||||
if (i < cmdHandle.getArgs().length) {
|
||||
if (!cmdHandle.argsMatch(argsNew.get(i), i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
if (cmdHandle.runCommand(sender, ArrayUtils.getInstance().convert(argsNew))) {
|
||||
plugin.debug("cmd found, ran cmd");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* for (String arg : cmdHandle.getArgs()[0].split("&")) { argsNew.set(0, arg);
|
||||
* if (cmdHandle.runCommand(sender, Utils.getInstance().convertArray(argsNew)))
|
||||
* { plugin.debug( "cmd found, ran cmd"); return true; } }
|
||||
*/
|
||||
|
||||
// invalid command
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+68
-69
@@ -1,69 +1,68 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.Executers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandVote.
|
||||
*/
|
||||
public class CommandVote implements CommandExecutor {
|
||||
|
||||
/** The instance. */
|
||||
private static CommandVote instance = new CommandVote();
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of CommandVote.
|
||||
*
|
||||
* @return single instance of CommandVote
|
||||
*/
|
||||
public static CommandVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*/
|
||||
private CommandVote() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CommandVote(Main plugin) {
|
||||
CommandVote.plugin = plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
for (CommandHandler commandHandler : plugin.voteCommand) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
package com.bencodez.votingplugin.commands.executers;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandVote.
|
||||
*/
|
||||
public class CommandVote implements CommandExecutor {
|
||||
|
||||
/** The instance. */
|
||||
private static CommandVote instance = new CommandVote();
|
||||
|
||||
/** The plugin. */
|
||||
private static VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of CommandVote.
|
||||
*
|
||||
* @return single instance of CommandVote
|
||||
*/
|
||||
public static CommandVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*/
|
||||
private CommandVote() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public CommandVote(VotingPluginMain plugin) {
|
||||
CommandVote.plugin = plugin;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
for (CommandHandler commandHandler : plugin.getVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
package com.bencodez.votingplugin.commands.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
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.editgui.EditGUI;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.EditGUIButton;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueBoolean;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueList;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueNumber;
|
||||
import com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.valuerequest.InputMethod;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequest;
|
||||
import com.bencodez.advancedcore.api.valuerequest.ValueRequestBuilder;
|
||||
import com.bencodez.advancedcore.api.valuerequest.listeners.StringListener;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteEvent;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
|
||||
public class AdminGUI {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminGUI(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI.
|
||||
*
|
||||
* @return ArrayList of buttons
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
|
||||
buttons.add(new BInventoryButton("&cVoteSites",
|
||||
new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
plugin.getConfigVoteSites().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openAdminGUIVoteSites(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", new String[] {}, new ItemStack(Material.STONE, 1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
});
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void loadHook() {
|
||||
for (BInventoryButton b : adminGUIButtons()) {
|
||||
com.bencodez.advancedcore.command.gui.AdminGUI.getInstance().addButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote sites.
|
||||
*
|
||||
* @param player the player
|
||||
*/
|
||||
public void openAdminGUIVoteSites(Player player) {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
lore.add("Name: " + voteSite.getDisplayName());
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
|
||||
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote site site.
|
||||
*
|
||||
* @param player the player
|
||||
* @param voteSite the vote site
|
||||
*/
|
||||
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
|
||||
EditGUI inv = new EditGUI("VoteSite: " + voteSite.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", voteSite);
|
||||
|
||||
inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ArrayList<String> playerNames = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
new ValueRequestBuilder(new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
.allowCustomOption(true).request(event.getWhoClicked());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("Priority", voteSite.getPriority()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().setPriority(voteSite.getKey(), num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("ServiceSite", voteSite.getServiceSite()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setServiceSite(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("Name", voteSite.getDisplayName()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().setDisplayName(voteSite.getKey(), value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("VoteURL", voteSite.getVoteURL()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteURL(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelay", 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.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setEnabled(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("ForceOffline", voteSite.isGiveOffline()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setForceOffline(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("VoteDelayDaily", voteSite.isVoteDelayDaily()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
plugin.getConfigVoteSites().setVoteDelayDaily(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
if (voteSite.getSiteData().isList("Rewards")) {
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueList("Rewards", voteSite.getSiteData().getStringList("Rewards")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player p, ArrayList<String> rewards) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
plugin.getConfigVoteSites().set(voteSite.getKey(), "Rewards", rewards);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class AdminVoteHelp extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin help.
|
||||
*
|
||||
* @param sender the sender
|
||||
* @param page the page
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelp(CommandSender sender, int page) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> text = adminHelpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
if ((text.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add(StringParser.getInstance().stringToComp("&6&lVotingPlugin Admin Help " + (page) + "/" + maxPage));
|
||||
msg.add(StringParser.getInstance().stringToComp("&6&l() = Needed"));
|
||||
msg.add(StringParser.getInstance().stringToComp("&6&lAliases: adminvote, av"));
|
||||
|
||||
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
|
||||
msg.add(text.get(i));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin help text.
|
||||
*
|
||||
* @param sender the sender
|
||||
* @return the array list
|
||||
*/
|
||||
public ArrayList<TextComponent> adminHelpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getAdminVoteCommand()) {
|
||||
if (requirePerms && sender.hasPermission(cmdHandle.getPerm())) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
} else {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/adminvote"), cmdHandle.getHelpLine("/adminvote"));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
msg.add(unsorted.get(cmd));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessageJson(adminHelp(sender, page));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
public class AdminVotePerms extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private String playerName;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public AdminVotePerms(VotingPluginMain plugin, CommandSender player, int page, String playerName) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
this.playerName = playerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String[] listPerms(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
msg.add(handle.getHelpLineCommand("/vote") + " : " + handle.getPerm().split(Pattern.quote("|"))[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (sender instanceof Player) {
|
||||
if (handle.hasPerm(sender)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
msg.add(handle.getHelpLineCommand("/av") + " : " + handle.getPerm().split(Pattern.quote("|"))[0]);
|
||||
}
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
if (sender instanceof Player) {
|
||||
Set<String> child = perm.getChildren().keySet();
|
||||
if (child.size() > 0) {
|
||||
if (sender.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
if (sender.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
msg.add(perm.getName());
|
||||
}
|
||||
}
|
||||
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
|
||||
int maxPage = msg.size() / pagesize;
|
||||
if ((msg.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
|
||||
text.add("&c&lCommand : Permissions " + page + "/" + maxPage);
|
||||
|
||||
for (int i = pagesize * page - pagesize; i < msg.size() && i < pagesize * page; i++) {
|
||||
text.add(msg.get(i));
|
||||
}
|
||||
|
||||
text = ArrayUtils.getInstance().colorize(text);
|
||||
|
||||
return ArrayUtils.getInstance().convert(text);
|
||||
}
|
||||
|
||||
public ArrayList<String> listPerms(CommandSender sender, String player, int page) {
|
||||
Player p = Bukkit.getPlayer(player);
|
||||
ArrayList<String> text = new ArrayList<String>();
|
||||
if (p != null) {
|
||||
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/vote") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
if (handle.hasPerm(p)) {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + handle.getHelpLineCommand("/av") + " : "
|
||||
+ handle.getPerm().split(Pattern.quote("|"))[0] + " : &cfalse");
|
||||
}
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
Set<String> child = perm.getChildren().keySet();
|
||||
if (child.size() > 0) {
|
||||
if (p.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
} else {
|
||||
if (p.hasPermission(perm)) {
|
||||
msg.add("&6" + perm.getName() + " : &atrue");
|
||||
} else {
|
||||
msg.add("&6" + perm.getName() + " : &cfalse");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
|
||||
int maxPage = msg.size() / pagesize;
|
||||
if ((msg.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
text.add("&c&lCommand : Permissions for " + player + " " + page + "/" + maxPage);
|
||||
|
||||
for (int i = pagesize * page - pagesize; i < msg.size() && i < pagesize * page; i++) {
|
||||
text.add(msg.get(i));
|
||||
}
|
||||
} else {
|
||||
text.add("&cPlayer not online: " + player);
|
||||
}
|
||||
return ArrayUtils.getInstance().colorize(text);
|
||||
|
||||
}
|
||||
|
||||
public String[] listPermsDev(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("Command");
|
||||
msg.add(" Permissions (seperated by |");
|
||||
msg.add(" Help messasge");
|
||||
msg.add(" ");
|
||||
|
||||
for (CommandHandler handle : plugin.getVoteCommand()) {
|
||||
msg.add(handle.getHelpLineCommand("/vote"));
|
||||
msg.add(" " + handle.getPerm());
|
||||
msg.add(" " + handle.getHelpMessage());
|
||||
}
|
||||
|
||||
for (CommandHandler handle : plugin.getAdminVoteCommand()) {
|
||||
msg.add(handle.getHelpLineCommand("/av"));
|
||||
msg.add(" " + handle.getPerm());
|
||||
msg.add(" " + handle.getHelpMessage());
|
||||
}
|
||||
|
||||
for (Permission perm : plugin.getDescription().getPermissions()) {
|
||||
msg.add(perm.getName() + " : " + perm.getDescription());
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
if (playerName != null) {
|
||||
sendMessage(listPerms(sender, playerName, page));
|
||||
} else {
|
||||
sendMessage(listPerms(sender));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
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.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class AdminVotePlaceholders extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public AdminVotePlaceholders(VotingPluginMain plugin, CommandSender player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "%VotingPlugin_" + identifier + "% - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "%VotingPlugin_" + identifier + "%";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String msg = "";
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg = "%VotingPlugin_" + identifier + "% - " + placeholder.getDescription();
|
||||
} else {
|
||||
msg = "%VotingPlugin_" + identifier + "%";
|
||||
}
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(identifier).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(msg)).build());
|
||||
book.addLayout(layout);
|
||||
|
||||
}
|
||||
|
||||
book.open(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cPlaceholders:");
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("%VotingPlugin_" + identifier + "% - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("%VotingPlugin_" + identifier + "%");
|
||||
}
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "#";
|
||||
}
|
||||
if (placeholder.hasDescription()) {
|
||||
msg.add("%VotingPlugin_" + identifier + "% - " + placeholder.getDescription());
|
||||
} else {
|
||||
msg.add("%VotingPlugin_" + identifier + "%");
|
||||
}
|
||||
}
|
||||
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
package com.bencodez.votingplugin.commands.gui.admin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
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.placeholder.PlaceHolder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class AdminVotePlaceholdersPlayer extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public AdminVotePlaceholdersPlayer(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper("Placeholders");
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user.getOfflinePlayer(), user, identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
String value = placeholder.placeholderRequest(user.getOfflinePlayer(), user, identifier);
|
||||
String msg = identifier + " = " + value;
|
||||
|
||||
Layout layout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
layout.replaceTextComponent("[Json]", BookUtil.TextBuilder.of(msg).color(ChatColor.AQUA)
|
||||
.onHover(BookUtil.HoverAction.showText(value)).build());
|
||||
book.addLayout(layout);
|
||||
}
|
||||
book.open(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cPlaceholders:");
|
||||
VotingPluginUser placeholderUser = user;
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
placeholderUser = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
msg.add("%VotingPlugin_" + identifier + "% = "
|
||||
+ placeholder.placeholderRequest(user.getOfflinePlayer(), placeholderUser, identifier));
|
||||
}
|
||||
|
||||
for (PlaceHolder<VotingPluginUser> placeholder : plugin.getPlaceholders().getNonPlayerPlaceholders()) {
|
||||
String identifier = placeholder.getIdentifier();
|
||||
if (identifier.endsWith("_")) {
|
||||
identifier += "1";
|
||||
}
|
||||
|
||||
msg.add("%VotingPlugin_" + identifier + "% = "
|
||||
+ placeholder.placeholderRequest(user.getOfflinePlayer(), placeholderUser, identifier));
|
||||
}
|
||||
sendMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
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.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteBest extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteBest(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteBestTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteBestLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("HighestDailyTotal", "" + user.getHighestDailyTotal());
|
||||
placeholders.put("HighestWeeklyTotal", "" + user.getHighestWeeklyTotal());
|
||||
placeholders.put("HighestMonthlyTotal", "" + user.getHighestMonthlyTotal());
|
||||
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
|
||||
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteBestName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestDayBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestWeekBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteBestMonthBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodBest().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
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.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteGUI extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteGUI(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
private ItemBuilder getItemSlot(String slot, Player player) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteGUISlotSection(slot));
|
||||
|
||||
String[] lore = new String[1];
|
||||
lore = ArrayUtils.getInstance().convert(plugin.getGui().getChestVoteGUISlotLore(slot));
|
||||
|
||||
String str = plugin.getConfigFile().getVoteTopDefault();
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
lore = new String[] { "&aClick me" };
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteNext(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteLast(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
lore = ArrayUtils.getInstance().convert(new VoteTotal(plugin, player, user).getChat(player));
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterMonthly(1);
|
||||
} else if (str.equalsIgnoreCase("weekly")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterWeekly(1);
|
||||
} else if (str.equalsIgnoreCase("daily")) {
|
||||
lore = plugin.getTopVoterHandler().topVoterDaily(1);
|
||||
} else {
|
||||
lore = plugin.getTopVoterHandler().topVoterAllTime(1);
|
||||
}
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
String[] today = new VoteToday(plugin, player, user, 1).voteTodayGUI();
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
if (today.length > 0) {
|
||||
for (int i = today.length - 1; i < today.length && list.size() < 10 && i >= 0; i--) {
|
||||
list.add(today[i]);
|
||||
}
|
||||
}
|
||||
lore = ArrayUtils.getInstance().convert(list);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
lore = new String[] { "Click to view help" };
|
||||
}
|
||||
}
|
||||
builder.setLore(ArrayUtils.getInstance().convert(lore));
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
/*
|
||||
* BookWrapper book = new
|
||||
* BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
*
|
||||
* // url - click to open Layout urlLayout = new Layout(new
|
||||
* ArrayList<String>(Arrays.asList("[Json]")));
|
||||
* urlLayout.replaceTextComponent("[Json]",
|
||||
* BookUtil.TextBuilder.of(book.colorize("Click me")).onClick(BookUtil.
|
||||
* ClickAction.runCommand("/vote url"))
|
||||
* .onHover(BookUtil.HoverAction.showText("Clicking me opens url GUI")).build())
|
||||
* ; book.addLayout(urlLayout); book.addLine();
|
||||
*
|
||||
* // next - click to open for (VoteSite site : plugin.getVoteSites()) { Layout
|
||||
* nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
* nextLayout.replaceTextComponent("[Json]",
|
||||
* BookUtil.TextBuilder.of(site.getDisplayName())
|
||||
* .onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
* .onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build
|
||||
* ()); book.addLayout(nextLayout); } book.addLine();
|
||||
*
|
||||
* // total - click to open
|
||||
*
|
||||
* // top = click to open
|
||||
*
|
||||
* // today - click to open
|
||||
*
|
||||
* // shop - click to open
|
||||
*
|
||||
* book.open(player);
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
// not available
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (this.user == null) {
|
||||
user = UserManager.getInstance().getVotingPluginUser((Player) player);
|
||||
}
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteGUIName());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
inv.addPlaceholder("points", "" + user.getPoints());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
inv.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
|
||||
for (String slot : plugin.getGui().getChestVoteGUISlots()) {
|
||||
ItemBuilder builder = getItemSlot(slot, player);
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(builder, 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
String cmd = plugin.getGui().getChestVoteGUISlotCommand(slot);
|
||||
if (cmd.equalsIgnoreCase("none")) {
|
||||
return;
|
||||
} else if (!cmd.equals("")) {
|
||||
event.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand(cmd);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
new VoteURL(plugin, player, user, true).open();
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
new VoteNext(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
new VoteLast(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
new VoteTotal(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
new VoteTopVoter(plugin, player, user, TopVoter.getDefault(), 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
new VoteToday(plugin, player, user, 1).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
new VoteShop(plugin, player, user).open(GUIMethod.CHEST);
|
||||
} else if (slot.equalsIgnoreCase("lastmonth")) {
|
||||
new VoteTopVoterLastMonth(plugin, player, user).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
|
||||
if (RewardHandler.getInstance().hasRewards(plugin.getGui().getData(),
|
||||
plugin.getGui().getChestVoteGUISlotRewardsPath(slot))) {
|
||||
RewardHandler.getInstance().giveReward(UserManager.getInstance().getVotingPluginUser(player),
|
||||
plugin.getGui().getData(), plugin.getGui().getChestVoteGUISlotRewardsPath(slot),
|
||||
new RewardOptions().addPlaceholder("identifier", slot));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
ItemBuilder item = getItemSlot(slot, player);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
item.addPlaceholder("points", "" + user.getPoints());
|
||||
item.addPlaceholder("player", user.getPlayerName());
|
||||
item.addPlaceholder("top", plugin.getConfigFile().getVoteTopDefault());
|
||||
return item;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class VoteHelp extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public VoteHelp(VotingPluginMain plugin, CommandSender player, int page) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<TextComponent> helpText(CommandSender sender) {
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
HashMap<String, TextComponent> unsorted = new HashMap<String, TextComponent>();
|
||||
|
||||
boolean requirePerms = plugin.getConfigFile().getFormatCommandsVoteHelpRequirePermission();
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.getVoteCommand()) {
|
||||
if (requirePerms && sender.hasPermission(cmdHandle.getPerm())) {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"),
|
||||
cmdHandle.getHelpLine("/vote", plugin.getConfigFile().getFormatCommandsVoteHelpLine()));
|
||||
} else {
|
||||
unsorted.put(cmdHandle.getHelpLineCommand("/vote"), cmdHandle.getHelpLine("/vote"));
|
||||
}
|
||||
}
|
||||
ArrayList<String> unsortedList = new ArrayList<String>();
|
||||
unsortedList.addAll(unsorted.keySet());
|
||||
Collections.sort(unsortedList, String.CASE_INSENSITIVE_ORDER);
|
||||
for (String cmd : unsortedList) {
|
||||
msg.add(unsorted.get(cmd));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessageJson(voteHelpText(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHAT);
|
||||
}
|
||||
|
||||
public ArrayList<TextComponent> voteHelpText(CommandSender sender) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
ArrayList<TextComponent> msg = new ArrayList<TextComponent>();
|
||||
ArrayList<TextComponent> text = helpText(sender);
|
||||
|
||||
int maxPage = text.size() / pagesize;
|
||||
if ((text.size() % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add(StringParser.getInstance()
|
||||
.stringToComp(plugin.getConfigFile().getFormatCommandsVoteHelpTitle() + " " + page + "/" + maxPage));
|
||||
|
||||
for (int i = pagesize * (page - 1); (i < text.size()) && (i < ((page) * pagesize)); i++) {
|
||||
msg.add(text.get(i));
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
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.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteLast extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteLast(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(StringParser.getInstance().replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteLastTitle(),
|
||||
"%player%", playerName));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
msg.add(user.voteCommandLastLine(voteSite));
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteLastName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandLastLine(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player p) {
|
||||
return site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandLastLine(site))
|
||||
.setAmountNone(1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteLastBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodLast().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
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.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
public class VoteNext extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteNext(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
msg.add(StringParser.getInstance().colorize(StringParser.getInstance()
|
||||
.replaceIgnoreCase(plugin.getConfigFile().getFormatCommandsVoteNextTitle(), "%player%", playerName)));
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
|
||||
String msgLine = plugin.getConfigFile().getFormatCommandsVoteNextLayout();
|
||||
|
||||
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%info%",
|
||||
user.voteCommandNextInfo(voteSite));
|
||||
|
||||
msgLine = StringParser.getInstance().replaceIgnoreCase(msgLine, "%SiteName%", voteSite.getDisplayName());
|
||||
msg.add(StringParser.getInstance().colorize(msgLine));
|
||||
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
// add colors/config options
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
Layout nextLayout = new Layout(new ArrayList<String>(Arrays.asList("[Json]")));
|
||||
nextLayout.replaceTextComponent("[Json]",
|
||||
BookUtil.TextBuilder.of(book.colorize(site.getDisplayName()))
|
||||
.onClick(BookUtil.ClickAction.openUrl(site.getVoteURLJsonStrip()))
|
||||
.onHover(BookUtil.HoverAction.showText(user.voteCommandNextInfo(site))).build());
|
||||
book.addLayout(nextLayout);
|
||||
}
|
||||
book.addLine();
|
||||
|
||||
book.open(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteNextName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new UpdatingBInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(user.voteCommandNextInfo(site)).setAmountNone(1), 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return site.getItem().setName(site.getDisplayName()).setLore(user.voteCommandNextInfo(site))
|
||||
.setAmountNone(1).addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteNextBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodNext().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,170 @@
|
||||
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.StringParser;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteShop extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteShop(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(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().getChestVoteShopEnabled()) {
|
||||
player.sendMessage(StringParser.getInstance().colorize(plugin.getGui().getChestVoteShopDisabled()));
|
||||
return;
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteShopName());
|
||||
inv.dontClose();
|
||||
|
||||
for (final String identifier : plugin.getGui().getChestShopIdentifiers()) {
|
||||
|
||||
String perm = plugin.getGui().getChestVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
int limit = plugin.getGui().getChestShopIdentifierLimit(identifier);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!plugin.getGui().getChestVoteShopNotBuyable(identifier)) {
|
||||
if (hasPerm && (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 = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (plugin.getConfigFile().isClearCacheOnVoteShopPurchase()
|
||||
|| plugin.getBungeeSettings().isUseBungeecoord()) {
|
||||
user.clearCache();
|
||||
}
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = plugin.getGui().getChestShopIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
} else {
|
||||
new VoteShopConfirm(plugin, player, user, identifier).open(GUIMethod.CHEST);
|
||||
;
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(plugin.getGui().getChestVoteShopLimitReached());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.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) {
|
||||
|
||||
}
|
||||
|
||||
}.dontClose().addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteShopBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
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.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.PlayerUtils;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
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(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.getInstance().setPlayerMeta(player, "ident", identifier);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestShopConfirmPurchaseTitle());
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestShopConfirmPurchaseYesItem())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
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)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, plugin.getGui().getData(),
|
||||
plugin.getGui().getChestShopIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getGui().getCHESTVoteShopPurchase(identifier), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
if (plugin.getGui().getChestVoteShopCloseGUI(identifier)) {
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
} else {
|
||||
new VoteShop(plugin, event.getPlayer(), user);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
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.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteStreak extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteStreak(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add(plugin.getConfigFile().getFormatCommandsVoteStreakTitle());
|
||||
msg.addAll(plugin.getConfigFile().getFormatCommandsVoteStreakLines());
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("DailyStreak", "" + user.getDayVoteStreak());
|
||||
placeholders.put("WeeklyStreak", "" + user.getWeekVoteStreak());
|
||||
placeholders.put("MonthlyStreak", "" + user.getMonthVoteStreak());
|
||||
|
||||
placeholders.put("BestDailyStreak", "" + user.getBestDayVoteStreak());
|
||||
placeholders.put("BestWeeklyStreak", "" + user.getBestWeekVoteStreak());
|
||||
placeholders.put("BestMonthlyStreak", "" + user.getBestMonthVoteStreak());
|
||||
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
|
||||
msg = ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteStreakName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakCurrentMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(plugin.getGui().getChestVoteStreakHighestMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteStreakBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodStreak().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
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.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.advancedcore.nms.NMSManager;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteToday extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteToday(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, int page) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
int pagesize = plugin.getConfigFile().getFormatPageSize();
|
||||
if (page < 1) {
|
||||
page = 1;
|
||||
}
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
String[] voteToday = voteToday();
|
||||
|
||||
int maxPage = voteToday.length / pagesize;
|
||||
if ((voteToday.length % pagesize) != 0) {
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
msg.add("&cToday's Votes " + page + "/" + maxPage);
|
||||
msg.add("&cPlayerName : VoteSite : Time");
|
||||
page--;
|
||||
|
||||
for (int i = pagesize * page; (i < voteToday.length) && (i < ((page + 1) * pagesize)); i++) {
|
||||
msg.add(voteToday[i]);
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTodayName());
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
for (VotingPluginUser 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>();
|
||||
placeholders.put("VoteSite", voteSite.getDisplayName());
|
||||
placeholders.put("Time", timeString);
|
||||
msg = StringParser.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
ItemBuilder item = null;
|
||||
if (plugin.getGui().isChestVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
|
||||
item = new ItemBuilder(user.getPlayerHead());
|
||||
} else {
|
||||
item = new ItemBuilder(plugin.getGui().getChestVoteTodayPlayerItem());
|
||||
}
|
||||
item.setName(StringParser.getInstance().replacePlaceHolder(plugin.getGui().getChestVoteTodayIconTitle(),
|
||||
"player", user.getPlayerName()));
|
||||
item.setLore(msg);
|
||||
final String uuid = user.getUUID();
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
new VoteGUI(plugin, player, user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTodayBackButton()) {
|
||||
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>();
|
||||
for (VotingPluginUser 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>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", voteSite.getKey());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
// msg.add("&6" + user.getPlayerName() + " : " + voteSite.getKey() + " : " +
|
||||
// timeString);
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public String[] voteTodayGUI() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
for (VotingPluginUser user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
LocalDateTime mostRecent = null;
|
||||
VoteSite mostRecentSite = null;
|
||||
for (Entry<VoteSite, LocalDateTime> entry : plugin.getVoteToday().get(user).entrySet()) {
|
||||
if (mostRecent == null || entry.getValue().isAfter(mostRecent)) {
|
||||
mostRecent = entry.getValue();
|
||||
mostRecentSite = entry.getKey();
|
||||
}
|
||||
}
|
||||
if (mostRecent != null) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(plugin.getConfigFile().getFormatTimeFormat());
|
||||
String timeString = mostRecent.format(formatter);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("player", user.getPlayerName());
|
||||
placeholders.put("votesite", mostRecentSite.getKey());
|
||||
placeholders.put("time", timeString);
|
||||
msg.add(StringParser.getInstance()
|
||||
.replacePlaceHolder(plugin.getConfigFile().getFormatCommandsVoteTodayLine(), placeholders));
|
||||
}
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.bencodez.advancedcore.api.gui.GUIHandler;
|
||||
import com.bencodez.advancedcore.api.gui.GUIMethod;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventory.ClickEvent;
|
||||
import com.bencodez.advancedcore.api.inventory.BInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTopVoter extends GUIHandler {
|
||||
|
||||
private int page;
|
||||
private VotingPluginMain plugin;
|
||||
private TopVoter top;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTopVoter(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, TopVoter top, int page) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.top = top;
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender sender) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterAllTime(page));
|
||||
case Daily:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterDaily(page));
|
||||
case Monthly:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterMonthly(page));
|
||||
case Weekly:
|
||||
return ArrayUtils.getInstance().convert(plugin.getTopVoterHandler().topVoterWeekly(page));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
try {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
Set<Entry<VotingPluginUser, Integer>> users = null;
|
||||
|
||||
String topVoter = top.getName();
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<VotingPluginUser, Integer> topVotes = (LinkedHashMap<VotingPluginUser, Integer>) plugin
|
||||
.getTopVoter(top).clone();
|
||||
users = topVotes.entrySet();
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", topVoter);
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = (VotingPluginUser) getData("User");
|
||||
new VoteGUI(plugin, player, user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
new VoteTopVoter(plugin, player, user, cur.next(), 0).open(GUIMethod.CHEST);
|
||||
} else {
|
||||
new VoteTopVoter(plugin, player, user, cur.prev(), 0).open(GUIMethod.CHEST);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTopVoter().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map.Entry;
|
||||
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.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTopVoterLastMonth extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTopVoterLastMonth(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
Set<Entry<VotingPluginUser, Integer>> users = null;
|
||||
|
||||
users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTopName());
|
||||
inv.addPlaceholder("topvoter", "Last Month");
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<VotingPluginUser, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (plugin.getGui().isChestVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(plugin.getGui().getChestVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(plugin.getGui().getChestVoteTopItemName())
|
||||
.addLoreLine(plugin.getGui().getChestVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VotingPluginUser user = (VotingPluginUser) getData("User");
|
||||
new VoteGUI(plugin, player, user)
|
||||
.open(GUIMethod.valueOf(plugin.getGui().getGuiMethodGUI().toUpperCase()));
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(plugin.getCommandLoader().getBackButton(user).setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(plugin.getGui().getChestVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
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.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteTotal extends GUIHandler {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
|
||||
public VoteTotal(VotingPluginMain plugin, CommandSender player, VotingPluginUser user) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
|
||||
int daily = user.getTotal(TopVoter.Daily);
|
||||
int weekly = user.getTotal(TopVoter.Weekly);
|
||||
int month = user.getTotal(TopVoter.Monthly);
|
||||
int all = user.getTotal(TopVoter.AllTime);
|
||||
|
||||
for (String s : plugin.getConfigFile().getFormatCommandsVoteTotal()) {
|
||||
String str = StringParser.getInstance().replaceIgnoreCase(s, "%DailyTotal%", "" + daily);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%WeeklyTotal%", "" + weekly);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%MonthlyTotal%", "" + month);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%AllTimeTotal%", "" + all);
|
||||
str = StringParser.getInstance().replaceIgnoreCase(str, "%player%", user.getPlayerName());
|
||||
msg.add(str);
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().colorize(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
// future release?
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
sendMessage(getChat(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteTotalName());
|
||||
inv.addPlaceholder("player", user.getPlayerName());
|
||||
|
||||
for (final TopVoter top : TopVoter.values()) {
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName()),
|
||||
1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player arg0) {
|
||||
return new ItemBuilder(plugin.getGui().getChestVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName())
|
||||
.addPlaceholder("player", user.getPlayerName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteTotalBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodTotal().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,220 @@
|
||||
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.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.MessageBuilder;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import xyz.upperlevel.spigot.book.BookUtil;
|
||||
|
||||
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(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.json = json;
|
||||
if (user == null && player instanceof Player) {
|
||||
this.user = UserManager.getInstance().getVotingPluginUser((Player) player);
|
||||
}
|
||||
if (player != null && user != null && player.getName().equals(user.getPlayerName())) {
|
||||
if (plugin.getConfigFile().isUsePrimaryAccountForPlaceholders() && user.hasPrimaryAccount()) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(user.getPrimaryAccount());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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().getFormatCommandsVoteAutoInputSites()) {
|
||||
int counter = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
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 = ArrayUtils.getInstance().replacePlaceHolder(sites, phs);
|
||||
}
|
||||
|
||||
return ArrayUtils.getInstance().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");
|
||||
}
|
||||
return builderAll;
|
||||
}
|
||||
|
||||
private ItemBuilder getItemVoteSite(VoteSite voteSite) {
|
||||
ItemBuilder builder = new ItemBuilder(plugin.getGui().getChestVoteURLAlreadyVotedItemSection());
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(plugin.getGui().getChestVoteURLCanVoteItemSection());
|
||||
} else {
|
||||
builder.addLoreLine(
|
||||
plugin.getGui().getChestVoteURLNextVote().replace("%Info%", user.voteCommandNextInfo(voteSite)));
|
||||
}
|
||||
|
||||
builder.setName(plugin.getGui().getChestVoteURLGUISiteName().replace("%Name%", voteSite.getDisplayName()));
|
||||
return builder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
BookWrapper book = new BookWrapper(plugin.getGui().getBookVoteURLBookGUITitle());
|
||||
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
Layout layout = new Layout(plugin.getGui().getBookVoteURLBookGUILayout()).addPlaceholder("sitename",
|
||||
site.getDisplayName());
|
||||
String text = plugin.getGui().getBookVoteURLBookGUIAlreadyVotedText();
|
||||
ChatColor color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUIAlreadyVotedColor());
|
||||
if (user.canVoteSite(site)) {
|
||||
color = ChatColor.valueOf(plugin.getGui().getBookVoteURLBookGUICanVoteColor());
|
||||
text = plugin.getGui().getBookVoteURLBookGUICanVoteText();
|
||||
}
|
||||
String url = StringParser.getInstance().replacePlaceHolder(site.getVoteURLJsonStrip(), "player",
|
||||
user.getPlayerName());
|
||||
layout.replaceTextComponent("[UrlText]", BookUtil.TextBuilder.of(text).color(color)
|
||||
.onClick(BookUtil.ClickAction.openUrl(url)).onHover(BookUtil.HoverAction.showText(url)).build());
|
||||
book.addLayout(layout);
|
||||
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
int count = 0;
|
||||
if (plugin.getGui().getChestVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = getItemAll();
|
||||
|
||||
inv.addButton(count, new UpdatingBInventoryButton(builderAll, 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
|
||||
json = true;
|
||||
user.sendMessage(getChat(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemAll();
|
||||
}
|
||||
});
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ItemBuilder builder = getItemVoteSite(voteSite);
|
||||
|
||||
inv.addButton(count, new UpdatingBInventoryButton(builder, 1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
StringParser.getInstance()
|
||||
.replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
plugin.getGui().getChestVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player player) {
|
||||
return getItemVoteSite(voteSite);
|
||||
}
|
||||
|
||||
});
|
||||
count++;
|
||||
}
|
||||
|
||||
if (plugin.getGui().getChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.valueOf(plugin.getGui().getGuiMethodURL().toUpperCase()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package com.bencodez.votingplugin.commands.gui.player;
|
||||
|
||||
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.inventory.UpdatingBInventoryButton;
|
||||
import com.bencodez.advancedcore.api.item.ItemBuilder;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
public class VoteURLVoteSite extends GUIHandler {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
private VotingPluginUser user;
|
||||
private String voteSite;
|
||||
|
||||
public VoteURLVoteSite(VotingPluginMain plugin, CommandSender player, VotingPluginUser user, String voteSite) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.user = user;
|
||||
this.voteSite = voteSite;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<String> getChat(CommandSender arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBook(Player player) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChat(CommandSender sender) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChest(Player player) {
|
||||
if (!plugin.isVoteSite(voteSite)) {
|
||||
player.sendMessage("Not a valid votesite");
|
||||
return;
|
||||
}
|
||||
VoteSite site = plugin.getVoteSite(voteSite);
|
||||
BInventory inv = new BInventory(plugin.getGui().getChestVoteURLSiteName());
|
||||
inv.addPlaceholder("site", site.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", site);
|
||||
if (!plugin.getConfigFile().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.BOW).setName("&4URL").addLoreLine("Click to see URL")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VoteSite site = (VoteSite) clickEvent.getMeta("VoteSite");
|
||||
clickEvent.getWhoClicked().sendMessage(site.getVoteURL());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new UpdatingBInventoryButton(
|
||||
new ItemBuilder(Material.COMPASS).setName("&4Next Vote").addLoreLine(user.voteCommandNextInfo(site)),
|
||||
1000, 1000) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemBuilder onUpdate(Player arg0) {
|
||||
return new ItemBuilder(Material.COMPASS).setName("&4Next Vote")
|
||||
.addLoreLine(user.voteCommandNextInfo(site));
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(Material.CLOCK).setName("&4Last Vote").addLoreLine(user.voteCommandLastLine(site))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
new VoteURL(plugin, clickEvent.getPlayer(), user, true).open();
|
||||
}
|
||||
});
|
||||
|
||||
if (plugin.getGui().getChestVoteURLBackButton()) {
|
||||
inv.addButton(plugin.getCommandLoader().getBackButton(user));
|
||||
}
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
open(GUIMethod.CHEST);
|
||||
}
|
||||
|
||||
}
|
||||
+53
-53
@@ -1,53 +1,53 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
/**
|
||||
* The Class AdminVoteTabCompleter.
|
||||
*/
|
||||
public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
List<String> tab = new ArrayList<String>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.adminVoteCommand, sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringUtils.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package com.bencodez.votingplugin.commands.tabcompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* The Class AdminVoteTabCompleter.
|
||||
*/
|
||||
public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
List<String> tab = new ArrayList<String>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+107
-107
@@ -1,107 +1,107 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
/**
|
||||
* The Class AliasesTabCompleter.
|
||||
*/
|
||||
public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/** The cmd handle. */
|
||||
public CommandHandler cmdHandle;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] argsIn) {
|
||||
ArrayList<String> msgArray = new ArrayList<String>();
|
||||
msgArray.add("");
|
||||
for (String arg : argsIn) {
|
||||
msgArray.add(arg);
|
||||
}
|
||||
|
||||
String[] args = ArrayUtils.getInstance().convert(msgArray);
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.adminVoteCommand);
|
||||
} else {
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
}
|
||||
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance()
|
||||
.getTabCompleteOptions();
|
||||
for (CommandHandler cmdHandle : cmdHandlers) {
|
||||
if (cmdHandle.getArgs().length >= argsIn.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
// plugin.debug("Found cmd... attempting to get tab
|
||||
// complete");
|
||||
args[0] = arg;
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argsIn.length; i++) {
|
||||
if (args.length >= i) {
|
||||
if (!cmdHandle.argsMatch(args[i], i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
|
||||
cmds.addAll(cmdHandle.getTabCompleteOptions(sender, args, argsIn.length, tabCompletes));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringUtils.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd, boolean adminCommand) {
|
||||
cmdHandle = cmd;
|
||||
this.adminCommand = adminCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
}
|
||||
package com.bencodez.votingplugin.commands.tabcompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.CommandHandler;
|
||||
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
/**
|
||||
* The Class AliasesTabCompleter.
|
||||
*/
|
||||
public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
private boolean adminCommand;
|
||||
|
||||
/** The cmd handle. */
|
||||
public CommandHandler cmdHandle;
|
||||
|
||||
/** The plugin. */
|
||||
VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] argsIn) {
|
||||
ArrayList<String> msgArray = new ArrayList<String>();
|
||||
msgArray.add("");
|
||||
for (String arg : argsIn) {
|
||||
msgArray.add(arg);
|
||||
}
|
||||
|
||||
String[] args = ArrayUtils.getInstance().convert(msgArray);
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
cmdHandlers.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance()
|
||||
.getTabCompleteOptions();
|
||||
for (CommandHandler cmdHandle : cmdHandlers) {
|
||||
if (cmdHandle.getArgs().length >= argsIn.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
// plugin.debug("Found cmd... attempting to get tab
|
||||
// complete");
|
||||
args[0] = arg;
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argsIn.length; i++) {
|
||||
if (args.length >= i) {
|
||||
if (!cmdHandle.argsMatch(args[i], i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
|
||||
cmds.addAll(cmdHandle.getTabCompleteOptions(sender, args, argsIn.length, tabCompletes));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd, boolean adminCommand) {
|
||||
cmdHandle = cmd;
|
||||
this.adminCommand = adminCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+54
-54
@@ -1,54 +1,54 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteTabCompleter.
|
||||
*/
|
||||
public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.voteCommand, sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringUtils.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
package com.bencodez.votingplugin.commands.tabcompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import com.bencodez.advancedcore.api.command.TabCompleteHandler;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteTabCompleter.
|
||||
*/
|
||||
public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeSettings extends YMLFile {
|
||||
|
||||
@ConfigDataBoolean(path = "BungeeBroadcast")
|
||||
@Getter
|
||||
private boolean bungeeBroadcast = false;
|
||||
|
||||
@ConfigDataBoolean(path = "BungeeBroadcastAlways")
|
||||
@Getter
|
||||
private boolean bungeeBroadcastAlways = false;
|
||||
|
||||
@ConfigDataBoolean(path = "BungeeDebug")
|
||||
@Getter
|
||||
private boolean bungeeDebug = false;
|
||||
|
||||
@ConfigDataString(path = "BungeeMethod")
|
||||
@Getter
|
||||
private String bungeeMethod = "PLUGINMESSAGING";
|
||||
|
||||
@ConfigDataString(path = "BungeeServer.Host")
|
||||
@Getter
|
||||
private String bungeeServerHost = "";
|
||||
|
||||
@ConfigDataInt(path = "BungeeServer.Port")
|
||||
@Getter
|
||||
private int bungeeServerPort = 1297;
|
||||
|
||||
@ConfigDataBoolean(path = "RemoveInvalidUsers")
|
||||
@Getter
|
||||
private boolean removeInvalidUsers = false;
|
||||
|
||||
@ConfigDataString(path = "Server")
|
||||
@Getter
|
||||
private String server = "PleaseSet";
|
||||
|
||||
@ConfigDataString(path = "SpigotServer.Host")
|
||||
@Getter
|
||||
private String spigotServerHost = "";
|
||||
|
||||
@ConfigDataInt(path = "SpigotServer.Port")
|
||||
@Getter
|
||||
private int spigotServerPort = 1298;
|
||||
|
||||
@ConfigDataBoolean(path = "UseBungeecord", secondPath = "UseBungeecoord")
|
||||
@Getter
|
||||
private boolean useBungeecoord = false;
|
||||
|
||||
public BungeeSettings(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "BungeeSettings.yml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
getPlugin().saveResource("BungeeSettings.yml", true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,791 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataInt;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Config.
|
||||
*/
|
||||
public class Config extends YMLFile {
|
||||
|
||||
@ConfigDataBoolean(path = "AddCustomCommands")
|
||||
@Getter
|
||||
private boolean addCustomCommands = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AddTotals")
|
||||
@Getter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnjoined")
|
||||
@Getter
|
||||
private boolean allowUnjoined = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseVoteGUIMainCommand")
|
||||
@Getter
|
||||
private boolean useVoteGUIMainCommand = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowUnJoinedCheckServer")
|
||||
@Getter
|
||||
private boolean allowUnJoinedCheckServer = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AllowVotePointTransfers")
|
||||
@Getter
|
||||
private boolean allowVotePointTransfers = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlterColumns")
|
||||
@Getter
|
||||
private boolean alterColumns = true;
|
||||
|
||||
@ConfigDataBoolean(path = "AlternateUUIDLookup")
|
||||
@Getter
|
||||
private boolean alternateUUIDLookup = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysCloseInventory")
|
||||
@Getter
|
||||
private boolean alwaysCloseInventory = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AlwaysUpdate")
|
||||
@Getter
|
||||
private boolean alwaysUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "AutoCreateVoteSites")
|
||||
@Getter
|
||||
private boolean autoCreateVoteSites = true;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.BroadcastVote")
|
||||
@Getter
|
||||
private boolean broadcastVotesEnabled = true;
|
||||
|
||||
@ConfigDataBoolean(path = "clearCacheOnUpdate")
|
||||
@Getter
|
||||
private boolean clearCacheOnUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ClearCacheOnVote")
|
||||
@Getter
|
||||
private boolean clearCacheOnVote = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ClearCacheOnVoteShopPurchase")
|
||||
@Getter
|
||||
private boolean clearCacheOnVoteShopPurchase = true;
|
||||
|
||||
@ConfigDataInt(path = "ConvertAmount")
|
||||
@Getter
|
||||
private int convertAmount = 250;
|
||||
|
||||
@ConfigDataInt(path = "ConvertDelay", defaultValue = 30000)
|
||||
@Getter
|
||||
private int convertDelay;
|
||||
|
||||
@ConfigDataBoolean(path = "CountFakeVotes")
|
||||
@Getter
|
||||
private boolean countFakeVotes = true;
|
||||
|
||||
@ConfigDataInt(path = "DelayBetweenUpdates")
|
||||
@Getter
|
||||
private int delayBetweenUpdates = 3;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableAdvancedTab")
|
||||
@Getter
|
||||
private boolean disableAdvancedTab = false;
|
||||
|
||||
@ConfigDataListString(path = "DisabledCommands")
|
||||
@Getter
|
||||
private ArrayList<String> disabledCommands = new ArrayList<String>();
|
||||
|
||||
@ConfigDataListString(path = "DisabledDefaultPermissions")
|
||||
@Getter
|
||||
private ArrayList<String> disabledDefaultPermissions = new ArrayList<String>();
|
||||
|
||||
@ConfigDataBoolean(path = "DisableNoServiceSiteMessage")
|
||||
@Getter
|
||||
private boolean disableNoServiceSiteMessage = false;
|
||||
|
||||
@ConfigDataBoolean(path = "DisableUpdateChecking")
|
||||
@Getter
|
||||
private boolean disableUpdateChecking = false;
|
||||
|
||||
@ConfigDataBoolean(path = "ExtraBackgroundUpdate")
|
||||
@Getter
|
||||
private boolean extraBackgroundUpdate = false;
|
||||
|
||||
@ConfigDataBoolean(path = "Format.Commands.Vote.ForceLinks")
|
||||
@Getter
|
||||
private boolean formatCommandsVoteForceLinks = true;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.LastVoted")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLastVoted = "%times% ago";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.Line", defaultValue = "&3%SiteName%: &6%timeSince% ago")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastLine;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.NeverVoted", defaultValue = "Never voted")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastNeverVoted;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Last.TimeFormat", defaultValue = "%amount% %TimeType%")
|
||||
@Getter
|
||||
private String formatCommandsVoteLastTimeFormat;
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.Today.Line")
|
||||
@Getter
|
||||
private String formatCommandsVoteTodayLine = "&6%player% : %VoteSite% : %Time%";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Disabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastDisabled = "&cYou will no longer see vote broadcasts";
|
||||
|
||||
@ConfigDataString(path = "Format.Commands.Vote.ToggleBroadcasts.Enabled")
|
||||
@Getter
|
||||
private String formatCommandsVoteToggleBroadcastEnabled = "&cYou will now see vote broadcasts";
|
||||
|
||||
@Getter
|
||||
private int formatPageSize = 10;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Day", defaultValue = "Day")
|
||||
@Getter
|
||||
private String formatTimeFormatsDay;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Days", defaultValue = "Days")
|
||||
@Getter
|
||||
private String formatTimeFormatsDays;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hour", defaultValue = "Hour")
|
||||
@Getter
|
||||
private String formatTimeFormatsHour;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Hours", defaultValue = "Hours")
|
||||
@Getter
|
||||
private String formatTimeFormatsHours;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minute", defaultValue = "Minute")
|
||||
@Getter
|
||||
private String formatTimeFormatsMinute;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Minutes", defaultValue = "Minutes")
|
||||
@Getter
|
||||
private String formatTimeFormatsMinutes;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Second", defaultValue = "Second")
|
||||
@Getter
|
||||
private String formatTimeFormatsSecond;
|
||||
|
||||
@ConfigDataString(path = "Format.TimeFormats.Seconds", defaultValue = "Seconds")
|
||||
@Getter
|
||||
private String formatTimeFormatsSeconds;
|
||||
|
||||
@ConfigDataBoolean(path = "LimitMonthlyVotes")
|
||||
@Getter
|
||||
private boolean limitMonthlyVotes = false;
|
||||
|
||||
@ConfigDataBoolean(path = "LoadCommandAliases")
|
||||
@Getter
|
||||
private boolean loadCommandAliases = true;
|
||||
|
||||
@ConfigDataBoolean(path = "LogVotesToFile")
|
||||
@Getter
|
||||
private boolean logVotesToFile = false;
|
||||
|
||||
@ConfigDataInt(path = "MaxiumNumberOfTopVotersToLoad")
|
||||
@Getter
|
||||
private int MaxiumNumberOfTopVotersToLoad = -1;
|
||||
|
||||
@ConfigDataBoolean(path = "OverrideVersionDisable")
|
||||
@Getter
|
||||
private boolean overrideVersionDisable = false;
|
||||
|
||||
@ConfigDataBoolean(path = "PreventRepeatMilestones")
|
||||
@Getter
|
||||
private boolean preventRepeatMilestones = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UpdateWithPlayersOnlineOnly")
|
||||
@Getter
|
||||
private boolean updateWithPlayersOnlineOnly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UseJavascriptPlaceholders")
|
||||
@Getter
|
||||
private boolean useJavascriptPlaceholders = false;
|
||||
|
||||
@ConfigDataBoolean(path = "UsePrimaryAccountForPlaceholders")
|
||||
@Getter
|
||||
private boolean usePrimaryAccountForPlaceholders = false;
|
||||
|
||||
@ConfigDataListString(path = "VotingBroadcastBlacklist")
|
||||
@Getter
|
||||
private ArrayList<String> votingBroadcastBlacklist = new ArrayList<String>();
|
||||
|
||||
public Config(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "Config.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the black list.
|
||||
*
|
||||
* @return the black list
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getBlackList() {
|
||||
return (ArrayList<String>) getData().getList("BlackList", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public Set<String> getCustomCommands() {
|
||||
Set<String> str = getData().getConfigurationSection("CustomCommands").getKeys(false);
|
||||
if (str == null) {
|
||||
str = new HashSet<String>();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public ConfigurationSection getCustomCommands(String ident) {
|
||||
return getData().getConfigurationSection("CustomCommands." + ident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broad cast msg.
|
||||
*
|
||||
* @return the broad cast msg
|
||||
*/
|
||||
public String getFormatBroadCastMsg() {
|
||||
return getData().getString("Format.BroadcastMsg",
|
||||
"&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the broadcast when online.
|
||||
*
|
||||
* @return the broadcast when online
|
||||
*/
|
||||
public boolean getFormatBroadcastWhenOnline() {
|
||||
return getData().getBoolean("Format.BroadcastWhenOnline");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote auto input sites.
|
||||
*
|
||||
* @return the commands vote auto input sites
|
||||
*/
|
||||
public boolean getFormatCommandsVoteAutoInputSites() {
|
||||
return getData().getBoolean("Format.Commands.Vote.AutoInputSites");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteBestLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Best.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteBestTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Best.Title", "&3&l%player% Best Votes");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help line.
|
||||
*
|
||||
* @return the commands vote help line
|
||||
*/
|
||||
public String getFormatCommandsVoteHelpLine() {
|
||||
return getData().getString("Format.Commands.Vote.Help.Line", "&6%Command% - &6%HelpMessage%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help require permission.
|
||||
*
|
||||
* @return the commands vote help require permission
|
||||
*/
|
||||
public boolean getFormatCommandsVoteHelpRequirePermission() {
|
||||
return getData().getBoolean("Format.Commands.Vote.Help.RequirePermission");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote help title.
|
||||
*
|
||||
* @return the commands vote help title
|
||||
*/
|
||||
public String getFormatCommandsVoteHelpTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Help.Title", "&6Voting Player Help");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote last title.
|
||||
*
|
||||
* @return the commands vote last title
|
||||
*/
|
||||
public String getFormatCommandsVoteLastTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Last.Title", "&3&l%player% Last Vote Times:");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next info can vote.
|
||||
*
|
||||
* @return the commands vote next info can vote
|
||||
*/
|
||||
public String getFormatCommandsVoteNextInfoCanVote() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.CanVote", "Go Vote!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next info error.
|
||||
*
|
||||
* @return the commands vote next info error
|
||||
*/
|
||||
public String getFormatCommandsVoteNextInfoError() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.Error", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next info time.
|
||||
*
|
||||
* @return the commands vote next info time
|
||||
*/
|
||||
public String getFormatCommandsVoteNextInfoTime() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.TimeUntilVote",
|
||||
"&cCould not caculate time until next vote!");
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteNextInfoVoteDelayDaily() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Info.VoteDelayDaily",
|
||||
"%hours% Hours and %minutes% Minutes");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next layout.
|
||||
*
|
||||
* @return the commands vote next layout
|
||||
*/
|
||||
public String getFormatCommandsVoteNextLayout() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Layout", "&3%SiteName%: &6%info%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote next title.
|
||||
*
|
||||
* @return the commands vote next title
|
||||
*/
|
||||
public String getFormatCommandsVoteNextTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Next.Title", "&3&l%player% Next Votes:");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote party.
|
||||
*
|
||||
* @return the commands vote party
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteParty() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Party", msg);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteStreakLines() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Streak.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public String getFormatCommandsVoteStreakTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Streak.Title", "&3&l%player% Vote Streak");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote text.
|
||||
*
|
||||
* @return the commands vote text
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteText() {
|
||||
ArrayList<String> str = new ArrayList<String>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Text", str);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotal() {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.Total",
|
||||
new ArrayList<String>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&l%player% Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatCommandsVoteTotalAll() {
|
||||
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList("Format.Commands.Vote.TotalAll",
|
||||
new ArrayList<String>());
|
||||
if (list.isEmpty()) {
|
||||
list.add("&3&lServer Total Votes:");
|
||||
list.add("&3&lDaily Total: &6&l%DailyTotal%");
|
||||
list.add("&3&lWeekly Total: &6&l%WeeklyTotal%");
|
||||
list.add("&3&lMonthly Total: &6&l%MonthlyTotal%");
|
||||
list.add("&3&lAllTime Total: &6&l%AllTimeTotal%");
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the commands vote URLS.
|
||||
*
|
||||
* @return the commands vote URLS
|
||||
*/
|
||||
public String getFormatCommandsVoteURLS() {
|
||||
return getData().getString("Format.Commands.Vote.Sites", "&4%num%: &c&l%SiteName% - &c%url%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command vote points.
|
||||
*
|
||||
* @return the command vote points
|
||||
*/
|
||||
public String getFormatCommandVotePoints() {
|
||||
return getData().getString("Format.Commands.Vote.Points", "&a%Player% currently has &a&l%Points%&a Points!");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command vote top line.
|
||||
*
|
||||
* @return the command vote top line
|
||||
*/
|
||||
public String getFormatCommandVoteTopLine() {
|
||||
return getData().getString("Format.Commands.Vote.Top.Line", "&c%num%: &6%player%, %votes%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the command vote top title.
|
||||
*
|
||||
* @return the command vote top title
|
||||
*/
|
||||
public String getFormatCommandVoteTopTitle() {
|
||||
return getData().getString("Format.Commands.Vote.Top.Title", "&3Top %Top% Voters %page%/%maxpages%");
|
||||
|
||||
}
|
||||
|
||||
public String getFormatNextPage() {
|
||||
return getData().getString("Format.NextPage", "&aNext Page");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the format no perms.
|
||||
*
|
||||
* @return the format no perms
|
||||
*/
|
||||
public String getFormatNoPerms() {
|
||||
return getData().getString("Format.NoPerms", "&cYou do not have enough permission!");
|
||||
}
|
||||
|
||||
public String getFormatNotNumber() {
|
||||
return getData().getString("Format.NotNumber", "&cError on &6%arg%&c, number expected!");
|
||||
}
|
||||
|
||||
public String getFormatPrevPage() {
|
||||
return getData().getString("Format.PrevPage", "&aPrevious Page");
|
||||
}
|
||||
|
||||
public String getFormatShopFailedMsg() {
|
||||
String msg = getData().getString("Format.ShopFailed", "&cYou do not have %Points% points to purhcase this!");
|
||||
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
public String getFormatShopPurchaseMsg() {
|
||||
return getData().getString("Format.ShopPurchase", "&aYou bought the %Identifier% for %Points% Points!");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 1.
|
||||
*
|
||||
* @return the sign top voter sign line 1
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine1() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line1", "TopVoter: %SiteName%");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 2.
|
||||
*
|
||||
* @return the sign top voter sign line 2
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine2() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line2", "#%position%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 3.
|
||||
*
|
||||
* @return the sign top voter sign line 3
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine3() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line3", "%player%");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign line 4.
|
||||
*
|
||||
* @return the sign top voter sign line 4
|
||||
*/
|
||||
public String getFormatSignTopVoterSignLine4() {
|
||||
return getData().getString("Format.Signs.TopVoterSign.Line4", "%votes% Votes");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign top voter sign right click message.
|
||||
*
|
||||
* @return the sign top voter sign right click message
|
||||
*/
|
||||
public String getFormatSignTopVoterSignRightClickMessage() {
|
||||
return getData().getString("Format.Signs.RightClickMessage",
|
||||
"&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cin &c&l%SiteName%");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the time format.
|
||||
*
|
||||
* @return the time format
|
||||
*/
|
||||
public String getFormatTimeFormat() {
|
||||
return getData().getString("Format.TimeFormat", "EEE, d MMM yyyy HH:mm");
|
||||
|
||||
}
|
||||
|
||||
public String getFormatTopVoterAllTime() {
|
||||
return getData().getString("Format.TopVoter.AllTime", "AllTime");
|
||||
}
|
||||
|
||||
public String getFormatTopVoterDaily() {
|
||||
return getData().getString("Format.TopVoter.Daily", "Daily");
|
||||
}
|
||||
|
||||
public String getFormatTopVoterMonthly() {
|
||||
return getData().getString("Format.TopVoter.Monthly", "Monthly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the top voter reward msg.
|
||||
*
|
||||
* @return the top voter reward msg
|
||||
*/
|
||||
public String getFormatTopVoterRewardMsg() {
|
||||
return getData().getString("Format.TopVoterAwardMsg",
|
||||
"&aYou came in %place% in top voters of the month! Here is an award!");
|
||||
|
||||
}
|
||||
|
||||
public String getFormatTopVoterWeekly() {
|
||||
return getData().getString("Format.TopVoter.Weekly", "Weekly");
|
||||
}
|
||||
|
||||
public String getFormatUserNotExist() {
|
||||
return getData().getString("Format.UserNotExist", "&cUser does not exist: %player%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote help.
|
||||
*
|
||||
* @return the vote help
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFormatVoteHelp() {
|
||||
return (ArrayList<String>) getData().getList("Format.Commands.Vote.Help.Lines", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getGiveDefaultPermission() {
|
||||
return getData().getBoolean("GiveDefaultPermission", true);
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoter(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getLoadTopVoterAllTime();
|
||||
case Daily:
|
||||
return getLoadTopVoterDaily();
|
||||
case Monthly:
|
||||
return getLoadTopVoterMonthly();
|
||||
case Weekly:
|
||||
return getLoadTopVoterWeekly();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoterAllTime() {
|
||||
return getData().getBoolean("LoadTopVoter.AllTime", true);
|
||||
}
|
||||
|
||||
@ConfigDataBoolean(path = "UseVoteStreaks")
|
||||
@Getter
|
||||
private boolean useVoteStreaks = true;
|
||||
|
||||
@ConfigDataBoolean(path = "UseHighestTotals")
|
||||
@Getter
|
||||
private boolean useHighestTotals = true;
|
||||
|
||||
public boolean getLoadTopVoterDaily() {
|
||||
return getData().getBoolean("LoadTopVoter.Daily", false);
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoterMonthly() {
|
||||
return getData().getBoolean("LoadTopVoter.Monthly", true);
|
||||
}
|
||||
|
||||
public boolean getLoadTopVoterWeekly() {
|
||||
return getData().getBoolean("LoadTopVoter.Weekly", false);
|
||||
}
|
||||
|
||||
public int getPointsOnVote() {
|
||||
return getData().getInt("PointsOnVote", 1);
|
||||
}
|
||||
|
||||
public int getPurgeMin() {
|
||||
return getData().getInt("PurgeMin", 90);
|
||||
}
|
||||
|
||||
public boolean getPurgeOldData() {
|
||||
return getData().getBoolean("PurgeOldData");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request API default method.
|
||||
*
|
||||
* @return the request API default method
|
||||
*/
|
||||
public String getRequestAPIDefaultMethod() {
|
||||
return getData().getString("RequestAPI.DefaultMethod", "Anvil");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request API disabled methods.
|
||||
*
|
||||
* @return the request API disabled methods
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getRequestAPIDisabledMethods() {
|
||||
return (ArrayList<String>) getData().getList("RequestAPI.DisabledMethods", new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the store top voters daily.
|
||||
*
|
||||
* @return the store top voters daily
|
||||
*/
|
||||
public boolean getStoreTopVotersDaily() {
|
||||
return getData().getBoolean("StoreTopVoters.Daily");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the store top voters monthly.
|
||||
*
|
||||
* @return the store top voters monthly
|
||||
*/
|
||||
public boolean getStoreTopVotersMonthly() {
|
||||
return getData().getBoolean("StoreTopVoters.Monthly");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the store top voters weekly.
|
||||
*
|
||||
* @return the store top voters weekly
|
||||
*/
|
||||
public boolean getStoreTopVotersWeekly() {
|
||||
return getData().getBoolean("StoreTopVoters.Weekly");
|
||||
}
|
||||
|
||||
public boolean getTopVoterAwardsTies() {
|
||||
return getData().getBoolean("TopVoterAwardsTies", true);
|
||||
}
|
||||
|
||||
public boolean getTopVoterIgnorePermission() {
|
||||
return getData().getBoolean("TopVoterIgnorePermission");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the enabled.
|
||||
*
|
||||
* @return the enabled
|
||||
*/
|
||||
public boolean getVoteRemindingEnabled() {
|
||||
return getData().getBoolean("VoteReminding.Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remind delay.
|
||||
*
|
||||
* @return the remind delay
|
||||
*/
|
||||
public int getVoteRemindingRemindDelay() {
|
||||
return getData().getInt("VoteReminding.RemindDelay", 30);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remind on login.
|
||||
*
|
||||
* @return the remind on login
|
||||
*/
|
||||
public boolean getVoteRemindingRemindOnLogin() {
|
||||
return getData().getBoolean("VoteReminding.RemindOnLogin");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the remind only once.
|
||||
*
|
||||
* @return the remind only once
|
||||
*/
|
||||
public boolean getVoteRemindingRemindOnlyOnce() {
|
||||
return getData().getBoolean("VoteReminding.RemindOnlyOnce");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
* @return the rewards
|
||||
*/
|
||||
public String getVoteRemindingRewardsPath() {
|
||||
return "VoteReminding.Rewards";
|
||||
}
|
||||
|
||||
public String getVoteTopDefault() {
|
||||
return getData().getString("VoteTopDefault", "Monthly");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
getPlugin().saveResource("Config.yml", true);
|
||||
}
|
||||
|
||||
}
|
||||
+79
-91
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -6,15 +6,18 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFile;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.bencodez.advancedcore.api.messages.StringParser;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -22,36 +25,20 @@ import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
*/
|
||||
public class ConfigVoteSites extends YMLFile {
|
||||
|
||||
/** The instance. */
|
||||
static ConfigVoteSites instance = new ConfigVoteSites();
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of ConfigVoteSites.
|
||||
*
|
||||
* @return single instance of ConfigVoteSites
|
||||
*/
|
||||
public static ConfigVoteSites getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new config vote sites.
|
||||
*/
|
||||
public ConfigVoteSites() {
|
||||
super(new File(Main.plugin.getDataFolder(), "VoteSites.yml"));
|
||||
public ConfigVoteSites(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "VoteSites.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate vote site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
*/
|
||||
public void generateVoteSite(String siteName) {
|
||||
if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
if (plugin.getConfigFile().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName
|
||||
@@ -60,19 +47,25 @@ public class ConfigVoteSites extends YMLFile {
|
||||
setServiceSite(siteName, org);
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
setVoteDelay(siteName, 24);
|
||||
set(siteName, "Item.Material", "GRASS");
|
||||
set(siteName, "Item.Amount", 1);
|
||||
set(siteName, "DisplayItem.Material", "GRASS");
|
||||
set(siteName, "DisplayItem.Amount", 1);
|
||||
set(siteName, "Rewards.Messages.Player", "&aThanks for voting on %ServiceSite%!");
|
||||
|
||||
plugin.loadVoteSites();
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission("VotingPlugin.Admin.GenerateServiceSite") || p.isOp()) {
|
||||
p.sendMessage(StringParser.getInstance().colorize("&cGenerating votesite for service site "
|
||||
+ siteName + ", please check console for details"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData(String siteName) {
|
||||
@@ -88,14 +81,16 @@ public class ConfigVoteSites extends YMLFile {
|
||||
}
|
||||
|
||||
public ConfigurationSection getItem(String site) {
|
||||
if (getData(site).isConfigurationSection("DisplayItem")) {
|
||||
return getData(site).getConfigurationSection("DisplayItem");
|
||||
}
|
||||
return getData(site).getConfigurationSection("Item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the priority
|
||||
*/
|
||||
public int getPriority(String siteName) {
|
||||
@@ -105,8 +100,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the rewards
|
||||
*/
|
||||
public String getRewardsPath(String siteName) {
|
||||
@@ -116,30 +110,35 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Gets the service site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the service site
|
||||
*/
|
||||
public String getServiceSite(String siteName) {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
public int getTimeOffSet(String siteName) {
|
||||
return getData(siteName).getInt("TimeOffSet", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the vote delay
|
||||
*/
|
||||
public int getVoteDelay(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelay");
|
||||
return getData(siteName).getInt("VoteDelay", 24);
|
||||
}
|
||||
|
||||
public int getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayMin", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site enabled.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the vote site enabled
|
||||
*/
|
||||
public boolean getVoteSiteEnabled(String siteName) {
|
||||
@@ -149,8 +148,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Gets the vote site file.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the vote site file
|
||||
*/
|
||||
public File getVoteSiteFile(String siteName) {
|
||||
@@ -190,7 +188,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
if (!siteCheck(site)) {
|
||||
plugin.getLogger().warning("Failed to load site " + site + ", see above");
|
||||
} else {
|
||||
voteSites.add(new VoteSite(site));
|
||||
voteSites.add(new VoteSite(plugin, site));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -244,19 +242,21 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL(String siteName) {
|
||||
return getData(siteName).getString("VoteURL");
|
||||
}
|
||||
|
||||
public boolean getWaitUntilVoteDelay(String siteName) {
|
||||
return getData(siteName).getBoolean("WaitUntilVoteDelay", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is service site good.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return true, if is service site good
|
||||
*/
|
||||
public boolean isServiceSiteGood(String siteName) {
|
||||
@@ -269,8 +269,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Checks if is vote URL good.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return true, if is vote URL good
|
||||
*/
|
||||
public boolean isVoteURLGood(String siteName) {
|
||||
@@ -289,10 +288,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Rename vote site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param newName
|
||||
* the new name
|
||||
* @param siteName the site name
|
||||
* @param newName the new name
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean renameVoteSite(String siteName, String newName) {
|
||||
@@ -303,12 +300,9 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Sets the.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param path
|
||||
* the path
|
||||
* @param value
|
||||
* the value
|
||||
* @param siteName the site name
|
||||
* @param path the path
|
||||
* @param value the value
|
||||
*/
|
||||
public void set(String siteName, String path, Object value) {
|
||||
// String playerName = user.getPlayerName();
|
||||
@@ -324,10 +318,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Sets the cumulative rewards.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param value
|
||||
* the value
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setCumulativeRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Cumulative.Rewards", value);
|
||||
@@ -344,22 +336,23 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param disabled
|
||||
* the disabled
|
||||
* @param siteName the site name
|
||||
* @param disabled the disabled
|
||||
*/
|
||||
public void setEnabled(String siteName, boolean disabled) {
|
||||
set(siteName, "Enabled", disabled);
|
||||
}
|
||||
|
||||
public void setForceOffline(String siteName, boolean value) {
|
||||
set(siteName, "ForceOffline", value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param value
|
||||
* the value
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setPriority(String siteName, int value) {
|
||||
set(siteName, "Priority", value);
|
||||
@@ -368,10 +361,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Sets the rewards.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param value
|
||||
* the value
|
||||
* @param siteName the site name
|
||||
* @param value the value
|
||||
*/
|
||||
public void setRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Rewards", value);
|
||||
@@ -380,10 +371,8 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Sets the service site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param serviceSite
|
||||
* the service site
|
||||
* @param siteName the site name
|
||||
* @param serviceSite the service site
|
||||
*/
|
||||
public void setServiceSite(String siteName, String serviceSite) {
|
||||
set(siteName, "ServiceSite", serviceSite);
|
||||
@@ -392,22 +381,22 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Sets the vote delay.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param voteDelay
|
||||
* the vote delay
|
||||
* @param siteName the site name
|
||||
* @param voteDelay the vote delay
|
||||
*/
|
||||
public void setVoteDelay(String siteName, int voteDelay) {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
public void setVoteDelayDaily(String siteName, boolean value) {
|
||||
set(siteName, "VoteDelayDaily", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param url
|
||||
* the url
|
||||
* @param siteName the site name
|
||||
* @param url the url
|
||||
*/
|
||||
public void setVoteURL(String siteName, String url) {
|
||||
set(siteName, "VoteURL", url);
|
||||
@@ -416,8 +405,7 @@ public class ConfigVoteSites extends YMLFile {
|
||||
/**
|
||||
* Site check.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param siteName the site name
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean siteCheck(String siteName) {
|
||||
@@ -0,0 +1,514 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataConfigurationSection;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataListString;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataString;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.topvoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class GUI extends YMLFile {
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.AlreadyVotedColor")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUIAlreadyVotedColor = "RED";
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.AlreadyVotedText")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUIAlreadyVotedText = "Click me";
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.CanVoteColor")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUICanVoteColor = "GREEN";
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.CanVoteText")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUICanVoteText = "Click me";
|
||||
|
||||
@ConfigDataListString(path = "BOOK.VoteURLBookGUI.Layout")
|
||||
@Getter
|
||||
private ArrayList<String> bookVoteURLBookGUILayout = ArrayUtils.getInstance()
|
||||
.convert(new String[] { "&c%Sitename%", "[UrlText]" });
|
||||
|
||||
@ConfigDataString(path = "BOOK.VoteURLBookGUI.Title")
|
||||
@Getter
|
||||
private String bookVoteURLBookGUITitle = "&cVoteURL";
|
||||
|
||||
@Getter
|
||||
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.NoItem")
|
||||
private ConfigurationSection chestShopConfirmPurchaseNoItem;
|
||||
|
||||
@Getter
|
||||
@ConfigDataString(path = "CHEST.ShopConfirmPurchase.Title")
|
||||
private String chestShopConfirmPurchaseTitle = "Confirm Purchase?";
|
||||
|
||||
@Getter
|
||||
@ConfigDataConfigurationSection(path = "CHEST.ShopConfirmPurchase.YesItem")
|
||||
private ConfigurationSection chestShopConfirmPurchaseYesItem;
|
||||
|
||||
@Getter
|
||||
@ConfigDataString(path = "CHEST.VoteShopDisabled")
|
||||
private String chestVoteShopDisabled = "&cVote shop disabled";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopHideLimitedReached")
|
||||
@Getter
|
||||
private boolean chestVoteShopHideLimitedReached = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteShopLimitReached")
|
||||
@Getter
|
||||
private String chestVoteShopLimitReached = "&aYou reached your limit";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteShopRequireConfirmation")
|
||||
@Getter
|
||||
private boolean chestVoteShopRequireConfirmation = false;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteToday.IconTitle")
|
||||
@Getter
|
||||
private String chestVoteTodayIconTitle = "%player%";
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteToday.Line")
|
||||
@Getter
|
||||
private String chestVoteTodayLine = "&6%VoteSite% : %Time%";
|
||||
|
||||
@ConfigDataConfigurationSection(path = "CHEST.VoteToday.PlayerItem")
|
||||
@Getter
|
||||
private ConfigurationSection chestVoteTodayPlayerItem;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteToday.UseSkull", defaultValue = true)
|
||||
@Getter
|
||||
private boolean chestVoteTodayUseSkull = true;
|
||||
|
||||
@ConfigDataString(path = "CHEST.VoteTop.PlayerItem.Material")
|
||||
@Getter
|
||||
private String chestVoteTopPlayerItemMaterial = "PAPER";
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteTop.UseSkull")
|
||||
@Getter
|
||||
private boolean chestVoteTopUseSkull = true;
|
||||
|
||||
@ConfigDataBoolean(path = "CHEST.VoteURL.AllUrlsButton.RequireAllSitesVoted")
|
||||
@Getter
|
||||
private boolean chestVoteURLAllUrlsButtonrequireAllSitesVoted = true;
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Best")
|
||||
@Getter
|
||||
private String guiMethodBest = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.GUI")
|
||||
@Getter
|
||||
private String guiMethodGUI = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Last")
|
||||
@Getter
|
||||
private String guiMethodLast = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Next")
|
||||
@Getter
|
||||
private String guiMethodNext = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Streak")
|
||||
@Getter
|
||||
private String guiMethodStreak = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Today")
|
||||
@Getter
|
||||
private String guiMethodToday = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.TopVoter")
|
||||
@Getter
|
||||
private String guiMethodTopVoter = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.Total")
|
||||
@Getter
|
||||
private String guiMethodTotal = "CHEST";
|
||||
|
||||
@ConfigDataString(path = "GUIMethod.URL")
|
||||
@Getter
|
||||
private String guiMethodURL = "CHEST";
|
||||
|
||||
@ConfigDataBoolean(path = "LastMonthGUI")
|
||||
@Getter
|
||||
private boolean lastMonthGUI = false;
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
public String getCHESTVoteShopPurchase(String identifier) {
|
||||
return getData().getString("CHEST.Shop." + identifier + ".PurchaseMessage",
|
||||
plugin.getConfigFile().getFormatShopPurchaseMsg());
|
||||
}
|
||||
|
||||
public GUI(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "GUI.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public ConfigurationSection getCHESTBackButton() {
|
||||
return getData().getConfigurationSection("CHEST.BackButton");
|
||||
}
|
||||
|
||||
public int getChestShopIdentifierCost(String identifier) {
|
||||
return getData().getInt("CHEST.Shop." + identifier + ".Cost");
|
||||
}
|
||||
|
||||
public String getChestShopIdentifierIdentifierName(String identifier) {
|
||||
return getData().getString("CHEST.Shop." + identifier + ".Identifier_Name", identifier);
|
||||
}
|
||||
|
||||
public int getChestShopIdentifierLimit(String identifier) {
|
||||
return getData().getInt("CHEST.Shop." + identifier + ".Limit", -1);
|
||||
}
|
||||
|
||||
public String getChestShopIdentifierRewardsPath(String identifier) {
|
||||
return "CHEST.Shop." + identifier + ".Rewards";
|
||||
|
||||
}
|
||||
|
||||
public Set<String> getChestShopIdentifiers() {
|
||||
ConfigurationSection shop = getData().getConfigurationSection("CHEST.Shop");
|
||||
if (shop != null) {
|
||||
return shop.getKeys(false);
|
||||
}
|
||||
return new HashSet<String>();
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestShopIdentifierSection(String identifier) {
|
||||
return getData().getConfigurationSection("CHEST.Shop." + identifier);
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteBestDayBestItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteBest.DayBest.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteBestMonthBestItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteBest.MonthBest.Item");
|
||||
}
|
||||
|
||||
public String getChestVoteBestName() {
|
||||
return getData().getString("CHEST.VoteBest.Name", "VoteBest: %player%");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteBestWeekBestItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteBest.WeekBest.Item");
|
||||
}
|
||||
|
||||
public String getChestVoteGUIName() {
|
||||
return getData().getString("CHEST.VoteGUIName", "&cVoteGUI: &c&l%player%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot command.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot command
|
||||
*/
|
||||
|
||||
public String getChestVoteGUISlotCommand(String slot) {
|
||||
return getData().getString("CHEST.VoteGUI." + slot + ".Command", "");
|
||||
}
|
||||
|
||||
public String getChestVoteGUISlotRewardsPath(String slot) {
|
||||
return "CHEST.VoteGUI." + slot + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot lore.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot lore
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getChestVoteGUISlotLore(String slot) {
|
||||
return (ArrayList<String>) getData().getList("CHEST.VoteGUI." + slot + ".Item.Lore", new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slots.
|
||||
*
|
||||
* @return the vote GUI slots
|
||||
*/
|
||||
public Set<String> getChestVoteGUISlots() {
|
||||
try {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteGUISlotSection(String slot) {
|
||||
return getData().getConfigurationSection("CHEST.VoteGUI." + slot + ".Item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote GUI slot slot.
|
||||
*
|
||||
* @param slot the slot
|
||||
* @return the vote GUI slot slot
|
||||
*/
|
||||
public int getChestVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("CHEST.VoteGUI." + slot + ".Slot", -1);
|
||||
}
|
||||
|
||||
public boolean getChestVoteLastBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteLast.BackButton");
|
||||
}
|
||||
|
||||
public String getChestVoteLastName() {
|
||||
return getData().getString("CHEST.VoteLast.Name", "VoteLast: %player%");
|
||||
}
|
||||
|
||||
public boolean getChestVoteNextBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteNext.BackButton");
|
||||
}
|
||||
|
||||
public String getChestVoteNextName() {
|
||||
return getData().getString("CHEST.VoteNext.Name", "VoteNext: %player%");
|
||||
}
|
||||
|
||||
public String getChestVoteRewardName() {
|
||||
return getData().getString("CHEST.VoteRewardName", "VoteReward");
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteShopBackButton", true);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopCloseGUI(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".CloseGUI", true);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopEnabled() {
|
||||
return getData().getBoolean("CHEST.VoteShopEnabled", true);
|
||||
}
|
||||
|
||||
public String getChestVoteShopName() {
|
||||
return getData().getString("CHEST.VoteShopName", "VoteShop");
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopNotBuyable(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".NotBuyable", false);
|
||||
}
|
||||
|
||||
public String getChestVoteShopPermission(String ident) {
|
||||
return getData().getString("CHEST.Shop." + ident + ".Permission", "");
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopResetDaily(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Daily", false);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopResetMonthly(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Monthly", false);
|
||||
}
|
||||
|
||||
public boolean getChestVoteShopResetWeekly(String shop) {
|
||||
return getData().getBoolean("CHEST.Shop." + shop + ".Reset.Weekly", false);
|
||||
}
|
||||
|
||||
public boolean getChestVoteStreakBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteStreak.BackButton");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteStreakCurrentDayStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentDayStreak.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteStreakCurrentMonthStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentMonthStreak.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteStreakCurrentWeekStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.CurrentWeekStreak.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteStreakHighestDayStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.HighestDayStreak.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteStreakHighestMonthStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.HighestMonthStreak.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteStreakHighestWeekStreakItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteStreak.HighestWeekStreak.Item");
|
||||
}
|
||||
|
||||
public String getChestVoteStreakName() {
|
||||
return getData().getString("CHEST.VoteStreak.Name", "VoteStreak");
|
||||
}
|
||||
|
||||
public boolean getChestVoteTodayBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteToday.BackButton");
|
||||
}
|
||||
|
||||
public String getChestVoteTodayName() {
|
||||
return getData().getString("CHEST.VoteToday.Name", "VoteToday");
|
||||
}
|
||||
|
||||
public boolean getChestVoteTopBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteToday.BackButton");
|
||||
}
|
||||
|
||||
public String getChestVoteTopItemLore() {
|
||||
return getData().getString("CHEST.VoteTop.Item.Lore", "&3&lVotes: &3%votes%");
|
||||
}
|
||||
|
||||
public String getChestVoteTopItemName() {
|
||||
return getData().getString("CHEST.VoteTop.Item.Name", "&3&l%position%: &3%player%");
|
||||
}
|
||||
|
||||
public String getChestVoteTopName() {
|
||||
return getData().getString("CHEST.VoteTop.Name", "VoteTop %topvoter%");
|
||||
}
|
||||
|
||||
public int getChestVoteTopSize() {
|
||||
return getData().getInt("CHEST.VoteTop.Size", 27);
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTopSwitchItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTop.SwitchItem");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalAllTimeTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.AllTimeTotal.Item");
|
||||
}
|
||||
|
||||
public boolean getChestVoteTotalBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteTotal.BackButton");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalDayTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.DayTotal.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalItem(TopVoter top) {
|
||||
switch (top) {
|
||||
case AllTime:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
case Daily:
|
||||
return getChestVoteTotalDayTotalItem();
|
||||
case Monthly:
|
||||
return getChestVoteTotalMonthTotalItem();
|
||||
case Weekly:
|
||||
return getChestVoteTotalWeekTotalItem();
|
||||
default:
|
||||
return getChestVoteTotalAllTimeTotalItem();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalMonthTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.MonthTotal.Item");
|
||||
}
|
||||
|
||||
public String getChestVoteTotalName() {
|
||||
return getData().getString("CHEST.VoteTotal.Name", "VoteTotal: %player%");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteTotalWeekTotalItem() {
|
||||
return getData().getConfigurationSection("CHEST.VoteTotal.WeekTotal.Item");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLAlreadyVotedAllUrlsButtonItemSection() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AllUrlsButton.AlreadyVotedItem");
|
||||
} else {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AlreadyVotedItem");
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLAlreadyVotedItemSection() {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AlreadyVotedItem");
|
||||
}
|
||||
|
||||
public boolean getChestVoteURLBackButton() {
|
||||
return getData().getBoolean("CHEST.VoteURL.BackButton");
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLCanVoteAllUrlsButtonItemSection() {
|
||||
if (getData().isConfigurationSection("CHEST.VoteURL.AllUrlsButton.CanVoteItem")) {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.AllUrlsButton.CanVoteItem");
|
||||
} else {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.CanVoteItem");
|
||||
}
|
||||
}
|
||||
|
||||
public ConfigurationSection getChestVoteURLCanVoteItemSection() {
|
||||
return getData().getConfigurationSection("CHEST.VoteURL.CanVoteItem");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL site name.
|
||||
*
|
||||
* @return the vote URL site name
|
||||
*/
|
||||
public String getChestVoteURLGUISiteName() {
|
||||
return getData().getString("CHEST.VoteURL.SiteName", "&c%Name%");
|
||||
}
|
||||
|
||||
public String getChestVoteURLName() {
|
||||
return getData().getString("CHEST.VoteURL.Name", "&cVoteURL");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL next vote.
|
||||
*
|
||||
* @return the vote URL next vote
|
||||
*/
|
||||
public String getChestVoteURLNextVote() {
|
||||
return getData().getString("CHEST.VoteURL.NextVote", "&cCan Vote In: %Info%");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL see URL.
|
||||
*
|
||||
* @return the vote URL see URL
|
||||
*/
|
||||
public String getChestVoteURLSeeURL() {
|
||||
return getData().getString("CHEST.VoteURL.SeeURL", "&cClick to see URL");
|
||||
}
|
||||
|
||||
public String getChestVoteURLSiteName() {
|
||||
return getData().getString("CHEST.VoteURLSite.Name", "VoteSite %site%");
|
||||
}
|
||||
|
||||
public String getChestVoteURLURLText() {
|
||||
return getData().getString("CHEST.VoteURL.URLText", "%VoteUrl%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL view all urls button enabled.
|
||||
*
|
||||
* @return the vote URL view all urls button enabled
|
||||
*/
|
||||
public boolean getChestVoteURLViewAllUrlsButtonEnabled() {
|
||||
return getData().getBoolean("CHEST.VoteURL.ViewAllUrlsButtonEnabled");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("GUI.yml", true);
|
||||
}
|
||||
|
||||
public boolean isChestVoteShopRequireConfirmation(String identifier) {
|
||||
return getData().getBoolean("CHEST.Shop." + identifier + ".RequireConfirmation",
|
||||
isChestVoteShopRequireConfirmation());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,307 @@
|
||||
package com.bencodez.votingplugin.config;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import com.bencodez.advancedcore.api.yml.YMLFile;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.AnnotationHandler;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataBoolean;
|
||||
import com.bencodez.advancedcore.api.yml.annotation.ConfigDataDouble;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class SpecialRewardsConfig extends YMLFile {
|
||||
|
||||
@Getter
|
||||
private String allSitesRewardPath = "AllSites";
|
||||
|
||||
@Getter
|
||||
private String anySiteRewardsPath = "AnySiteRewards";
|
||||
|
||||
@ConfigDataBoolean(path = "EnableDailyRewards")
|
||||
@Getter
|
||||
private boolean enableDailyRewards = false;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableMonthlyAwards")
|
||||
@Getter
|
||||
private boolean enableMonthlyAwards = true;
|
||||
|
||||
@ConfigDataBoolean(path = "EnableWeeklyAwards")
|
||||
@Getter
|
||||
private boolean enableWeeklyAwards = false;
|
||||
|
||||
@Getter
|
||||
private String firstVoteRewardsPath = "FirstVote";
|
||||
|
||||
/** The plugin. */
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetExtraVotesMonthly")
|
||||
@Getter
|
||||
private boolean votePartyResetExtraVotesMonthly = false;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteParty.ResetCount")
|
||||
@Getter
|
||||
private boolean votePartyResetCount = true;
|
||||
|
||||
@Getter
|
||||
private String votePartyRewardsPath = "VoteParty.Rewards";
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Day")
|
||||
@Getter
|
||||
private double voteStreakRequirementDay = 50;
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Month")
|
||||
@Getter
|
||||
private double voteStreakRequirementMonth = 50;
|
||||
|
||||
@ConfigDataBoolean(path = "VoteStreak.Requirement.UsePercentage")
|
||||
@Getter
|
||||
private boolean voteStreakRequirementUsePercentage = false;
|
||||
|
||||
@ConfigDataDouble(path = "VoteStreak.Requirement.Week")
|
||||
@Getter
|
||||
private double voteStreakRequirementWeek = 50;
|
||||
|
||||
public SpecialRewardsConfig(VotingPluginMain plugin) {
|
||||
super(plugin, new File(plugin.getDataFolder(), "SpecialRewards.yml"));
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean getCumulativeRewardEnabled(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".Enabled");
|
||||
}
|
||||
|
||||
public String getCumulativeRewardsPath(int cumulative) {
|
||||
return "Cumulative." + cumulative + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative votes.
|
||||
*
|
||||
* @return the cumulative votes
|
||||
*/
|
||||
public Set<String> getCumulativeVotes() {
|
||||
try {
|
||||
Set<String> set = getData().getConfigurationSection("Cumulative").getKeys(false);
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<String>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the cumulative votes in same day.
|
||||
*
|
||||
* @param cumulative the cumulative
|
||||
* @return the cumulative votes in same day
|
||||
*/
|
||||
public boolean getCumulativeVotesInSameDay(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameDay");
|
||||
}
|
||||
|
||||
public boolean getCumulativeVotesInSameMonth(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameMonth");
|
||||
}
|
||||
|
||||
public boolean getCumulativeVotesInSameWeek(int cumulative) {
|
||||
return getData().getBoolean("Cumulative." + cumulative + ".VotesInSameWeek");
|
||||
}
|
||||
|
||||
public String getDailyAwardRewardsPath(String path) {
|
||||
return "DailyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the daily possible reward places.
|
||||
*
|
||||
* @return the daily possible reward places
|
||||
*/
|
||||
public Set<String> getDailyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("DailyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone reward enabled.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone reward enabled
|
||||
*/
|
||||
public boolean getMilestoneRewardEnabled(int milestones) {
|
||||
return getData().getBoolean("MileStones." + milestones + ".Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone rewards.
|
||||
*
|
||||
* @param milestones the milestones
|
||||
* @return the milestone rewards
|
||||
*/
|
||||
public String getMilestoneRewardsPath(int milestones) {
|
||||
return "MileStones." + milestones + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the milestone votes.
|
||||
*
|
||||
* @return the milestone votes
|
||||
*/
|
||||
public Set<String> getMilestoneVotes() {
|
||||
try {
|
||||
Set<String> set = getData().getConfigurationSection("MileStones").getKeys(false);
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<String>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public String getMonthlyAwardRewardsPath(String path) {
|
||||
return "MonthlyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the monthly possible reward places.
|
||||
*
|
||||
* @return the monthly possible reward places
|
||||
*/
|
||||
public Set<String> getMonthlyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("MonthlyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getResetMilestonesMonthly() {
|
||||
return getData().getBoolean("ResetMilestonesMonthly");
|
||||
}
|
||||
|
||||
public String getVotePartyBroadcast() {
|
||||
return getData().getString("VoteParty.Broadcast", "");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotePartyCommands() {
|
||||
return (ArrayList<String>) getData().getList("VoteParty.Commands", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public boolean getVotePartyCountFakeVotes() {
|
||||
return getData().getBoolean("VoteParty.CountFakeVotes", true);
|
||||
}
|
||||
|
||||
public boolean getVotePartyCountOfflineVotes() {
|
||||
return getData().getBoolean("VoteParty.CountOfflineVotes", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party enabled.
|
||||
*
|
||||
* @return the vote party enabled
|
||||
*/
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party give all players.
|
||||
*
|
||||
* @return the vote party give all players
|
||||
*/
|
||||
public boolean getVotePartyGiveAllPlayers() {
|
||||
return getData().getBoolean("VoteParty.GiveAllPlayers");
|
||||
}
|
||||
|
||||
public int getVotePartyIncreaseVotesRquired() {
|
||||
return getData().getInt("VoteParty.IncreaseVotesRquired", 0);
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetEachDay() {
|
||||
return getData().getBoolean("VoteParty.ResetEachDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyOnlyOncePerDay() {
|
||||
return getData().getBoolean("VoteParty.OnlyOncePerDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetMontly() {
|
||||
return getData().getBoolean("VoteParty.ResetMonthly");
|
||||
}
|
||||
|
||||
public boolean getVotePartyResetWeekly() {
|
||||
return getData().getBoolean("VoteParty.ResetWeekly");
|
||||
}
|
||||
|
||||
public int getVotePartyUserVotesRequired() {
|
||||
return getData().getInt("VoteParty.UserVotesRequired");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote party votes required.
|
||||
*
|
||||
* @return the vote party votes required
|
||||
*/
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired");
|
||||
}
|
||||
|
||||
public boolean getVoteStreakRewardEnabled(String type, String s) {
|
||||
return getData().getBoolean("VoteStreak." + type + "." + s + ".Enabled");
|
||||
}
|
||||
|
||||
public String getVoteStreakRewardsPath(String type, String string) {
|
||||
return "VoteStreak." + type + "." + string + ".Rewards";
|
||||
}
|
||||
|
||||
public Set<String> getVoteStreakVotes(String type) {
|
||||
try {
|
||||
Set<String> set = getData().getConfigurationSection("VoteStreak." + type).getKeys(false);
|
||||
if (set != null) {
|
||||
return set;
|
||||
}
|
||||
return new HashSet<String>();
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public String getWeeklyAwardRewardsPath(String path) {
|
||||
return "WeeklyAwards." + path + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the weekly possible reward places.
|
||||
*
|
||||
* @return the weekly possible reward places
|
||||
*/
|
||||
public Set<String> getWeeklyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("WeeklyAwards").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadValues() {
|
||||
new AnnotationHandler().load(getData(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("SpecialRewards.yml", true);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.bencodez.votingplugin.cooldown;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.bencodez.advancedcore.api.rewards.RewardHandler;
|
||||
import com.bencodez.advancedcore.api.rewards.RewardOptions;
|
||||
import com.bencodez.advancedcore.api.time.events.DateChangedEvent;
|
||||
import com.bencodez.advancedcore.api.user.UUID;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.events.PlayerVoteCoolDownEndEvent;
|
||||
import com.bencodez.votingplugin.user.UserManager;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteReminding.
|
||||
*/
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
private VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public CoolDownCheck(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void checkAll() {
|
||||
plugin.getTimer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (VotingPluginMain.plugin != null) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
if (VotingPluginMain.plugin != null) {
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getUserData().hasData() && user.hasLoggedOnBefore()) {
|
||||
user.checkCoolDownEvents();
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 1000 * 60 * 3);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
RewardHandler.getInstance().giveReward(event.getPlayer(), plugin.getSpecialRewardsConfig().getData(),
|
||||
"VoteCoolDownEndedReward",
|
||||
new RewardOptions().addPlaceholder("Votesite", event.getVoteSite().getDisplayName()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChangeEnd(DateChangedEvent event) {
|
||||
checkAll();
|
||||
}
|
||||
}
|
||||
+81
-73
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Data;
|
||||
package com.bencodez.votingplugin.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@@ -8,9 +8,9 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.bencodez.advancedcore.api.misc.ArrayUtils;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -18,35 +18,10 @@ import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
*/
|
||||
public class ServerData {
|
||||
|
||||
/** The instance. */
|
||||
static ServerData instance = new ServerData();
|
||||
private VotingPluginMain plugin = VotingPluginMain.plugin;
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of ServerData.
|
||||
*
|
||||
* @return single instance of ServerData
|
||||
*/
|
||||
public static ServerData getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new server data.
|
||||
*/
|
||||
private ServerData() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new server data.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public ServerData(Main plugin) {
|
||||
ServerData.plugin = plugin;
|
||||
public ServerData(VotingPluginMain plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public synchronized void addServiceSite(String site) {
|
||||
@@ -60,12 +35,9 @@ public class ServerData {
|
||||
/**
|
||||
* Adds the sign.
|
||||
*
|
||||
* @param location
|
||||
* the location
|
||||
* @param data
|
||||
* the data
|
||||
* @param position
|
||||
* the position
|
||||
* @param location the location
|
||||
* @param data the data
|
||||
* @param position the position
|
||||
*/
|
||||
public void addSign(Location location, String data, int position) {
|
||||
|
||||
@@ -78,8 +50,8 @@ public class ServerData {
|
||||
getData().set("Signs." + count + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
saveData();
|
||||
plugin.signs.add(new SignHandler("" + count, getSignLocation("" + count), getSignData("" + count),
|
||||
getSignPosition("" + count)));
|
||||
plugin.getSigns().getSigns().add(new SignHandler(plugin, "" + count, getSignLocation("" + count),
|
||||
getSignSkullLocation("" + count), getSignData("" + count), getSignPosition("" + count)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -88,12 +60,10 @@ public class ServerData {
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData() {
|
||||
ConfigurationSection data = com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().getData()
|
||||
.getConfigurationSection("VotingPlugin");
|
||||
ConfigurationSection data = plugin.getServerDataFile().getData().getConfigurationSection("VotingPlugin");
|
||||
if (data == null) {
|
||||
com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().getData().createSection("VotingPlugin");
|
||||
data = com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().getData()
|
||||
.getConfigurationSection("VotingPlugin");
|
||||
plugin.getServerDataFile().getData().createSection("VotingPlugin");
|
||||
data = plugin.getServerDataFile().getData().getConfigurationSection("VotingPlugin");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
@@ -106,8 +76,7 @@ public class ServerData {
|
||||
/**
|
||||
* Gets the sign data.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @param sign the sign
|
||||
* @return the sign data
|
||||
*/
|
||||
public String getSignData(String sign) {
|
||||
@@ -117,8 +86,7 @@ public class ServerData {
|
||||
/**
|
||||
* Gets the sign location.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @param sign the sign
|
||||
* @return the sign location
|
||||
*/
|
||||
public Location getSignLocation(String sign) {
|
||||
@@ -130,8 +98,7 @@ public class ServerData {
|
||||
/**
|
||||
* Gets the sign position.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @param sign the sign
|
||||
* @return the sign position
|
||||
*/
|
||||
public int getSignPosition(String sign) {
|
||||
@@ -151,6 +118,25 @@ public class ServerData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign location.
|
||||
*
|
||||
* @param sign the sign
|
||||
* @return the sign location
|
||||
*/
|
||||
public Location getSignSkullLocation(String sign) {
|
||||
if (getData().getString("Signs." + sign + ".Skull.World", "").isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new Location(Bukkit.getWorld(getData().getString("Signs." + sign + ".Skull.World")),
|
||||
getData().getDouble("Signs." + sign + ".Skull.X"), getData().getDouble("Signs." + sign + ".Skull.Y"),
|
||||
getData().getDouble("Signs." + sign + ".Skull.Z"));
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
@@ -173,14 +159,13 @@ public class ServerData {
|
||||
* Reload data.
|
||||
*/
|
||||
public void reloadData() {
|
||||
com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().reloadData();
|
||||
plugin.getServerDataFile().reloadData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @param sign the sign
|
||||
*/
|
||||
public void removeSign(String sign) {
|
||||
getData().set("Signs." + sign + ".World", null);
|
||||
@@ -190,6 +175,10 @@ public class ServerData {
|
||||
getData().set("Signs." + sign + ".Data", null);
|
||||
getData().set("Signs." + sign + ".Position", null);
|
||||
getData().set("Signs." + sign, null);
|
||||
getData().set("Signs." + sign + ".Skull.World", null);
|
||||
getData().set("Signs." + sign + ".Skull.X", null);
|
||||
getData().set("Signs." + sign + ".Skull.Y", null);
|
||||
getData().set("Signs." + sign + ".Skull.Z", null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
@@ -197,7 +186,7 @@ public class ServerData {
|
||||
* Save data.
|
||||
*/
|
||||
public synchronized void saveData() {
|
||||
com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().saveData();
|
||||
plugin.getServerDataFile().saveData();
|
||||
}
|
||||
|
||||
public void setServiceSites(ArrayList<String> list) {
|
||||
@@ -205,31 +194,32 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sign.
|
||||
*
|
||||
* @param count
|
||||
* the count
|
||||
* @param location
|
||||
* the location
|
||||
* @param data
|
||||
* the data
|
||||
* @param position
|
||||
* the position
|
||||
*/
|
||||
public void setSign(String count, Location location, String data, int position) {
|
||||
public void setSign(String count, Location location, Location skullLocation, String data, int position) {
|
||||
|
||||
getData().set("Signs." + count + ".World", location.getWorld().getName());
|
||||
int x = (int) location.getX();
|
||||
int z = (int) location.getZ();
|
||||
getData().set("Signs." + count + ".X", x);
|
||||
getData().set("Signs." + count + ".Y", location.getY());
|
||||
getData().set("Signs." + count + ".Z", z);
|
||||
getData().set("Signs." + count + ".X", (int) location.getX());
|
||||
getData().set("Signs." + count + ".Y", (int) location.getY());
|
||||
getData().set("Signs." + count + ".Z", (int) location.getZ());
|
||||
getData().set("Signs." + count + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
if (skullLocation != null) {
|
||||
getData().set("Signs." + count + ".Skull.World", skullLocation.getWorld().getName());
|
||||
getData().set("Signs." + count + ".Skull.X", (int) skullLocation.getX());
|
||||
getData().set("Signs." + count + ".Skull.Y", (int) skullLocation.getY());
|
||||
getData().set("Signs." + count + ".Skull.Z", (int) skullLocation.getZ());
|
||||
}
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setSkullLocation(String count, Location skullLocation) {
|
||||
if (skullLocation != null) {
|
||||
getData().set("Signs." + count + ".Skull.World", skullLocation.getWorld().getName());
|
||||
getData().set("Signs." + count + ".Skull.X", (int) skullLocation.getX());
|
||||
getData().set("Signs." + count + ".Skull.Y", (int) skullLocation.getY());
|
||||
getData().set("Signs." + count + ".Skull.Z", (int) skullLocation.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version.
|
||||
*/
|
||||
@@ -238,10 +228,28 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
}
|
||||
|
||||
public boolean isLastVotePartySameDay() {
|
||||
int num = getData().getInt("LastVoteParty", 0);
|
||||
if (num != plugin.getTimeChecker().getTime().getDayOfYear()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateLastVoteParty() {
|
||||
getData().set("LastVoteParty", plugin.getTimeChecker().getTime().getDayOfYear());
|
||||
saveData();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerReceivePointsEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int points;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
public PlayerReceivePointsEvent(VotingPluginUser user, int points) {
|
||||
super(true);
|
||||
this.player = user;
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerSpecialRewardEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private SpecialRewardType type;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser user;
|
||||
|
||||
public PlayerSpecialRewardEvent(VotingPluginUser user, SpecialRewardType type) {
|
||||
super(true);
|
||||
this.type = type;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteCoolDownEndEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
public PlayerVoteCoolDownEndEvent(VotingPluginUser user, VoteSite site) {
|
||||
super(true);
|
||||
player = user;
|
||||
voteSite = site;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.bencodez.votingplugin.bungee.BungeeMessageData;
|
||||
import com.bencodez.votingplugin.objects.VoteSite;
|
||||
import com.bencodez.votingplugin.user.VotingPluginUser;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean bungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private BungeeMessageData bungeeTextTotals;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean forceBungee = false;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean realVote = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long time;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VotingPluginUser votingPluginUser;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
this.player = voteUsername;
|
||||
this.voteSite = voteSite;
|
||||
this.realVote = realVote;
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, FIRSTVOTE, MILESTONE, VOTESTREAK;
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
+7
-22
@@ -1,8 +1,11 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
package com.bencodez.votingplugin.events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
@@ -21,11 +24,12 @@ public class VotePartyEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/** The cancelled. */
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public VotePartyEvent() {
|
||||
super();
|
||||
super(true);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -38,23 +42,4 @@ public class VotePartyEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
+8
-10
@@ -1,4 +1,4 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
package com.bencodez.votingplugin.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@@ -8,8 +8,8 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.bencodez.votingplugin.VotingPluginMain;
|
||||
import com.bencodez.votingplugin.signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
@@ -18,23 +18,21 @@ import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
public class BlockBreak implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
private static VotingPluginMain plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new block break.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
* @param plugin the plugin
|
||||
*/
|
||||
public BlockBreak(Main plugin) {
|
||||
public BlockBreak(VotingPluginMain plugin) {
|
||||
BlockBreak.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On block break.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
* @param event the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
@@ -45,7 +43,7 @@ public class BlockBreak implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns().getSigns()) {
|
||||
if (sign.getLocation().equals(loc)) {
|
||||
sign.removeSign();
|
||||
sign.setValid(false);
|
||||
Loaded 100 of 121 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user