Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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 | ||
|
|
d06041cfd8 | ||
|
|
1a257a3858 | ||
|
|
90c0104de3 | ||
|
|
b3473174de | ||
|
|
5b853b9ad4 | ||
|
|
3b3578fa87 | ||
|
|
6bf079068b | ||
|
|
2a889ff2ce | ||
|
|
de9c9185f3 | ||
|
|
07c4534d10 | ||
|
|
b3462bebe6 | ||
|
|
5525a378ae | ||
|
|
bb8588e144 | ||
|
|
8abd596172 | ||
|
|
df93655db3 | ||
|
|
f1f97a8908 | ||
|
|
65fe355d6d | ||
|
|
7cd5954cd2 | ||
|
|
5618d4b479 | ||
|
|
898b2985e5 | ||
|
|
cd7fa2cd39 | ||
|
|
62afcfc820 | ||
|
|
12233d1061 | ||
|
|
c2b3178f2e | ||
|
|
2e01c1eafd | ||
|
|
384ace3013 | ||
|
|
2693874d99 | ||
|
|
f5b780453c | ||
|
|
7a7bb93091 | ||
|
|
8933dac0db | ||
|
|
822e0a5766 | ||
|
|
e1fdc5cd6b | ||
|
|
3b0451b348 | ||
|
|
4de380318f | ||
|
|
1c7afc8bb3 | ||
|
|
7b15289c43 | ||
|
|
241746fdf0 | ||
|
|
37932f570e | ||
|
|
1c834a480f | ||
|
|
6a0d74f400 | ||
|
|
feed85d9bb | ||
|
|
f9b4adf342 | ||
|
|
a04b9b996d | ||
|
|
4992c547ed | ||
|
|
d5c1f3bf11 | ||
|
|
b82736e933 | ||
|
|
d0d1e262c2 | ||
|
|
0b0dea8f51 | ||
|
|
48e1298b73 | ||
|
|
8d850dde7e | ||
|
|
963ff8b5f2 | ||
|
|
5a871656c5 | ||
|
|
011e18ff9d | ||
|
|
53f9b2c9f8 | ||
|
|
fe488158df | ||
|
|
699bb1bdf6 | ||
|
|
f9c8b8a719 | ||
|
|
242eceda2c | ||
|
|
98cd79684e | ||
|
|
5b4f73dadf | ||
|
|
a8113aa941 | ||
|
|
f741dbf6a7 | ||
|
|
f589817301 | ||
|
|
27874ecb70 | ||
|
|
73726123ae | ||
|
|
0a7637f04b | ||
|
|
c4d3068895 | ||
|
|
c497d338f9 | ||
|
|
9140466e02 | ||
|
|
2d6b1ebd33 | ||
|
|
d0ff76e9c4 | ||
|
|
6ff6b14c2d | ||
|
|
198dffe5df | ||
|
|
868a755d86 | ||
|
|
9f4c6bf250 | ||
|
|
655cec2bac | ||
|
|
9fc0b2c9a3 | ||
|
|
5aa396cc67 | ||
|
|
d11b90fabd | ||
|
|
bc85b88c27 | ||
|
|
a9e110f21f | ||
|
|
aa4622437f | ||
|
|
46eb548962 | ||
|
|
25b3494dc5 | ||
|
|
33602b3ed2 | ||
|
|
36662ab18d | ||
|
|
40473b14a2 | ||
|
|
6ca6529f2c | ||
|
|
a6b2945b14 | ||
|
|
b5fc7da7c9 | ||
|
|
41104be50f | ||
|
|
e2dabbb8c1 | ||
|
|
5f37262a48 | ||
|
|
efd48a1005 | ||
|
|
a813172c43 | ||
|
|
0f8f190a21 | ||
|
|
0f87222709 | ||
|
|
518ecfc42b | ||
|
|
d02c4a4b70 | ||
|
|
9359b4fb05 | ||
|
|
4f3ba5b1c4 | ||
|
|
600287e9c5 | ||
|
|
a05114e277 | ||
|
|
5449038cfd | ||
|
|
853cdd0a13 | ||
|
|
3cd36d3fd7 | ||
|
|
bd3abaae76 | ||
|
|
a9a70a20ee | ||
|
|
2fc2067bc5 | ||
|
|
2e6e3617a3 | ||
|
|
c590ca5a93 | ||
|
|
2772db23b8 | ||
|
|
ee3217b942 | ||
|
|
b1dfe6a14b | ||
|
|
222a3824af | ||
|
|
5f5d3dd2c5 | ||
|
|
84ba523233 | ||
|
|
1da224ff6b | ||
|
|
e2efe2b289 | ||
|
|
9cf044aa64 | ||
|
|
eac8078a65 | ||
|
|
2cf97ba408 | ||
|
|
23ffc18289 | ||
|
|
2152a6688f | ||
|
|
c3220392eb | ||
|
|
fec401485b | ||
|
|
2b2a6385b4 | ||
|
|
9937f3d9c0 | ||
|
|
b276d516a6 | ||
|
|
d6a336e9b9 | ||
|
|
b356cb1794 | ||
|
|
4b0a2ee384 | ||
|
|
8dab62124e | ||
|
|
a7df1a0150 | ||
|
|
f2d7e24400 | ||
|
|
fa74bdcb3c | ||
|
|
80a4cb8f78 | ||
|
|
f16aef16d4 | ||
|
|
e7a1a1241b | ||
|
|
0ee002e3fb | ||
|
|
69ab9df8b3 | ||
|
|
54ff1dd66b | ||
|
|
75732910e2 | ||
|
|
9c6614836a | ||
|
|
72148816e5 | ||
|
|
f969c91170 | ||
|
|
904d660919 | ||
|
|
fb5449effe | ||
|
|
46db998e17 | ||
|
|
2bcf096584 | ||
|
|
c2b7e2388e | ||
|
|
180ae04b24 | ||
|
|
73efcfb87f | ||
|
|
6ba2ff582a | ||
|
|
d622b5b684 | ||
|
|
2247134daa | ||
|
|
7de7150e41 | ||
|
|
be23989a20 | ||
|
|
8c4bdc8e20 | ||
|
|
f4d507d821 | ||
|
|
43fd338efd | ||
|
|
c51873e7b2 | ||
|
|
5e1d5b534b | ||
|
|
c762ef5be1 | ||
|
|
1d0f8d5c06 | ||
|
|
6129480077 | ||
|
|
f8d7c837f9 | ||
|
|
d7aba7b390 | ||
|
|
5833a1c5cc | ||
|
|
6833247a8c | ||
|
|
46087ccad5 | ||
|
|
4634d6bdc2 | ||
|
|
3f451c888a | ||
|
|
ea448e3920 | ||
|
|
169aaf026e | ||
|
|
0af3f7f2bc | ||
|
|
b3baa33c39 | ||
|
|
e7f8aac88d | ||
|
|
6ce4040bae | ||
|
|
f5e38b2b1b | ||
|
|
9fdb9b4efb | ||
|
|
29f020bdc0 | ||
|
|
cce5bb0672 | ||
|
|
8a0cd0426c | ||
|
|
397c4392a0 | ||
|
|
4784b372c9 | ||
|
|
1521d0787c | ||
|
|
9cbcb74822 | ||
|
|
ae75f63c94 | ||
|
|
e91e2e109c | ||
|
|
0fb0a6351d | ||
|
|
10d06c170d | ||
|
|
a4c0a9b45b | ||
|
|
63fc8d436e | ||
|
|
6160110ba2 | ||
|
|
e337c267a8 | ||
|
|
b0abbcc99f | ||
|
|
f75dffe5df | ||
|
|
146d981c23 | ||
|
|
2e7ed9c1c1 | ||
|
|
198fe10447 | ||
|
|
ab8dd96a79 | ||
|
|
cac0b0e99c | ||
|
|
80ae9dbe2d | ||
|
|
f91a02ba3f | ||
|
|
25d718a37c | ||
|
|
6114373237 | ||
|
|
3c60c99c83 | ||
|
|
e237b382cd | ||
|
|
a07b69cc08 | ||
|
|
7f1ceaf500 | ||
|
|
6b8924c08b | ||
|
|
1f80578e7a | ||
|
|
2f78c4b462 | ||
|
|
89b0d71267 | ||
|
|
77363ce3c7 | ||
|
|
9477c063de | ||
|
|
dc00652e69 | ||
|
|
374ba2ee95 | ||
|
|
8fd8b1ad35 | ||
|
|
2c05ce4870 | ||
|
|
dca689ec37 | ||
|
|
ee4d52377f | ||
|
|
ac41c9413c | ||
|
|
596968f869 | ||
|
|
0d2221d195 | ||
|
|
23fa59f98f | ||
|
|
cb81b61096 | ||
|
|
186917992c | ||
|
|
6b70e4fee4 | ||
|
|
79c98c8b86 | ||
|
|
b8e0830b0b | ||
|
|
1cd1a0ab75 | ||
|
|
481510a1e8 | ||
|
|
3a95ef9b23 | ||
|
|
f7af9210cb | ||
|
|
9f5fe338f4 | ||
|
|
967be0aa19 | ||
|
|
6e0b62a1dd | ||
|
|
a8ec557c9e | ||
|
|
252263da74 | ||
|
|
e7696bed25 | ||
|
|
064451d2b5 | ||
|
|
daa25805fa | ||
|
|
cc010d9738 | ||
|
|
cbe58a1f18 | ||
|
|
c29247d2a0 | ||
|
|
a28cdfc6bf | ||
|
|
7db5cd59da | ||
|
|
0ebb0c9a70 | ||
|
|
9ba20ddd02 | ||
|
|
7fddc0af12 | ||
|
|
475e6059eb | ||
|
|
b552928b8c | ||
|
|
779c1728b4 | ||
|
|
d91e9cd150 | ||
|
|
5f8bf52c08 | ||
|
|
bbf401ac94 | ||
|
|
fda1f134bf | ||
|
|
2b6425242a | ||
|
|
79f1f5ced4 | ||
|
|
8f37dc6f34 | ||
|
|
16590a023c | ||
|
|
0e961f0b92 | ||
|
|
24af26ff50 | ||
|
|
45c6b0d65a | ||
|
|
3f4c787fc6 | ||
|
|
3d9610f1cc | ||
|
|
47e7201cc2 | ||
|
|
6a665d9645 | ||
|
|
a880c11941 | ||
|
|
1b4e8ed4d7 | ||
|
|
5fcfba567a | ||
|
|
da88aa17b1 | ||
|
|
61243589b1 | ||
|
|
d0ea06921b | ||
|
|
9f2cfb7825 | ||
|
|
33d104cdfc | ||
|
|
3a483ed746 | ||
|
|
b4c5e68833 | ||
|
|
3ef524aefe | ||
|
|
fedd6cf9ef | ||
|
|
f1112d5694 | ||
|
|
6ed58d8223 | ||
|
|
5122e0391a | ||
|
|
cb088a84f9 | ||
|
|
90a57fbe84 | ||
|
|
edf636de35 | ||
|
|
6601f13127 | ||
|
|
96f38bf13f | ||
|
|
014ba226f9 | ||
|
|
a46cd4ae2c | ||
|
|
63c826007e | ||
|
|
165b80dca3 | ||
|
|
f84517741d | ||
|
|
ea4216244a | ||
|
|
6982d8421c | ||
|
|
afdbb57d66 | ||
|
|
b10396176b | ||
|
|
bd865dd588 | ||
|
|
fec62bdb32 | ||
|
|
63fa9b77d3 | ||
|
|
6ecb703235 | ||
|
|
4193f0bd32 | ||
|
|
7eb6e0c4f2 | ||
|
|
530ca13de4 | ||
|
|
76d4666e58 | ||
|
|
d3b980bb5e | ||
|
|
371961bcce | ||
|
|
1df7869f3b | ||
|
|
6af60370bf | ||
|
|
49d9ce7b36 | ||
|
|
1d3ef77d78 | ||
|
|
2a80658981 | ||
|
|
9bafe060a3 | ||
|
|
8c67abbf6a | ||
|
|
1f1dd3fd07 | ||
|
|
fcf0977042 | ||
|
|
f4cb50e1cd | ||
|
|
13367c2f8e | ||
|
|
acc5736e82 | ||
|
|
e8fbbb7db4 | ||
|
|
2f4f8a0da7 | ||
|
|
f3fc1373c1 | ||
|
|
71c3d6ac7c | ||
|
|
71bda92e46 | ||
|
|
33bff9e0c8 | ||
|
|
da1723bd41 | ||
|
|
4b478a4667 | ||
|
|
8acfadbe25 | ||
|
|
f2523b63c3 | ||
|
|
ec59112740 | ||
|
|
1d39ea2c3d | ||
|
|
49e69cba08 | ||
|
|
04081939b3 | ||
|
|
7c86774c01 | ||
|
|
7410299a35 | ||
|
|
a4ec9e650a | ||
|
|
683f8d77f7 | ||
|
|
68fdb5ca78 | ||
|
|
5a8d14806e | ||
|
|
eafb38f351 | ||
|
|
685bb69f2a | ||
|
|
1b2f63a8ab | ||
|
|
bb7b2bd303 | ||
|
|
aa699cdb50 | ||
|
|
1c19377d58 | ||
|
|
085a9614a3 | ||
|
|
4a84d657a8 | ||
|
|
eb79c6c37d | ||
|
|
e21c6d0ccb | ||
|
|
2f273a0a2a | ||
|
|
f095fa1223 | ||
|
|
aa7ce443cc | ||
|
|
145e9bada5 | ||
|
|
8597e86b79 | ||
|
|
834dfcc8bb | ||
|
|
79ca900e5d | ||
|
|
5bbbaf056f | ||
|
|
a922e5f082 | ||
|
|
e1356e2375 | ||
|
|
1d3c25b7fc | ||
|
|
0dc8206f7d | ||
|
|
801175f4fd | ||
|
|
38ac0b5317 | ||
|
|
534deb8fa7 | ||
|
|
545ff24ec9 | ||
|
|
41802f4d64 | ||
|
|
3efb5f9ad3 | ||
|
|
842e341c7d | ||
|
|
7d771bc1b2 | ||
|
|
e25d5329a2 | ||
|
|
7303cfcbfb | ||
|
|
dc115ed789 | ||
|
|
5937507818 | ||
|
|
163f9404c2 | ||
|
|
143468e48a | ||
|
|
2c29ed40f8 | ||
|
|
ede5d6b3a6 | ||
|
|
8dd7f49b24 | ||
|
|
44393f60d9 | ||
|
|
5880de53eb | ||
|
|
95da201ea5 | ||
|
|
1179451738 | ||
|
|
d1abad711d | ||
|
|
8bd7fe330d | ||
|
|
a281b37a56 | ||
|
|
01ee350eea | ||
|
|
d342d2b43e | ||
|
|
14fe133482 | ||
|
|
2fa9f3ced1 | ||
|
|
75b435dac7 | ||
|
|
9471925696 | ||
|
|
eb5aa134e3 | ||
|
|
1771d15e83 | ||
|
|
1064e48a22 | ||
|
|
42faa9fa81 | ||
|
|
76de7d6e2f | ||
|
|
e12e81aa0b | ||
|
|
a4ef6acdec | ||
|
|
ddf3ac5513 | ||
|
|
6b77d9a46b | ||
|
|
198ebc7f6f | ||
|
|
c5168d3f5d | ||
|
|
665c009d8b | ||
|
|
07d9b23eef | ||
|
|
6c67b405c2 | ||
|
|
e9646ee5d6 | ||
|
|
a7e8561639 | ||
|
|
f80f7dc546 | ||
|
|
87becb7750 | ||
|
|
1affff072d | ||
|
|
ecdd02313b | ||
|
|
5483e414d5 | ||
|
|
93457617a4 | ||
|
|
a6ce18a520 | ||
|
|
882f7a6703 | ||
|
|
228b3cb41b | ||
|
|
34b1b43d07 | ||
|
|
f82a0cb88a | ||
|
|
5329dd5312 | ||
|
|
580f35c8b0 | ||
|
|
10c5f7b173 | ||
|
|
7acf00b0ac | ||
|
|
f58d429173 | ||
|
|
5ba393d040 | ||
|
|
537f2b34bc | ||
|
|
1e07f826e7 | ||
|
|
414a2f2139 | ||
|
|
494faa1fb8 | ||
|
|
b003a55979 | ||
|
|
5aec36795a | ||
|
|
32581641b7 | ||
|
|
054248594f | ||
|
|
e0e6b68fe8 | ||
|
|
0f9398ab7e | ||
|
|
3ede586ba0 | ||
|
|
e37c7d3122 | ||
|
|
b51b7f7205 | ||
|
|
ab327d4cf2 | ||
|
|
bc2476c096 | ||
|
|
7440a0ddec | ||
|
|
d1929fea9d | ||
|
|
f484aa63c6 | ||
|
|
05a03ca51b | ||
|
|
c39872ee19 | ||
|
|
848c9c5d49 | ||
|
|
5c656ec5ff | ||
|
|
bf79b275f6 | ||
|
|
782a2a88dc | ||
|
|
1cbbc15301 | ||
|
|
0297711e17 | ||
|
|
bc71b96733 | ||
|
|
be60f07de2 | ||
|
|
8ae15ccffe | ||
|
|
088081c3ec | ||
|
|
e8637da77b | ||
|
|
471453aadf | ||
|
|
2d38b3dbca | ||
|
|
441726f233 | ||
|
|
37edb38723 | ||
|
|
eb4b33aa60 | ||
|
|
c291ff00a6 | ||
|
|
37399dd856 | ||
|
|
3ecd784e61 | ||
|
|
412f6bab97 | ||
|
|
d1d9054562 | ||
|
|
98229d9d6a | ||
|
|
26d39ac7e2 | ||
|
|
066b7813a0 | ||
|
|
e36befcbfb | ||
|
|
34c84175f6 | ||
|
|
406a47e272 | ||
|
|
bb6ae46dd8 | ||
|
|
47cbd05290 | ||
|
|
87c91e67d7 | ||
|
|
b44b97284e | ||
|
|
a0f3264297 | ||
|
|
45cb09ef0e | ||
|
|
9cef05beb7 | ||
|
|
c008744559 | ||
|
|
0bb990e535 | ||
|
|
3b977a3da0 | ||
|
|
4d9a855b4f | ||
|
|
023206bd14 | ||
|
|
9d30790373 | ||
|
|
c92746b6c6 | ||
|
|
f4fa697f0f | ||
|
|
761c2f0c77 | ||
|
|
67908b82fa | ||
|
|
1fedd7063d | ||
|
|
dbdc74e751 | ||
|
|
0c9bc0fb01 | ||
|
|
7fcdd3b545 | ||
|
|
be6ef6f75e | ||
|
|
42d81ba361 | ||
|
|
a17a889ffa | ||
|
|
d04293b1b4 | ||
|
|
8e5a37b969 | ||
|
|
4439268472 | ||
|
|
b33d256656 | ||
|
|
7c10ef066f | ||
|
|
5f02f76b9f | ||
|
|
4e6e88159e | ||
|
|
96b5e8fc3e | ||
|
|
dd3bee2b77 | ||
|
|
d2a4c6385d | ||
|
|
6707296b5a | ||
|
|
42c358fd70 | ||
|
|
b14c0b79c1 | ||
|
|
81582fef1b | ||
|
|
f4f05322a3 | ||
|
|
25b81a8c8e | ||
|
|
433cc9a914 | ||
|
|
27096eb67d | ||
|
|
2c4074694c | ||
|
|
4666406f41 | ||
|
|
d5c710c060 | ||
|
|
740d8dd21f | ||
|
|
f03264236b | ||
|
|
e2681edee9 | ||
|
|
5d49479da2 | ||
|
|
66410db7e5 | ||
|
|
f29cfd5434 | ||
|
|
a30fdba2b9 | ||
|
|
122bd089d4 | ||
|
|
d73ee79102 | ||
|
|
2ece54f321 | ||
|
|
3b1c94d040 | ||
|
|
ae4d2b7339 | ||
|
|
c1e512d574 | ||
|
|
b3a6e3e658 | ||
|
|
1d11bbb2b5 | ||
|
|
8a92bfa89c | ||
|
|
91f2a32e32 | ||
|
|
b4df38b83b | ||
|
|
dc6c20bf02 | ||
|
|
5d3c14cd88 | ||
|
|
0ac214d1b7 | ||
|
|
97e136de75 | ||
|
|
48373e001a | ||
|
|
9aa327053d | ||
|
|
7a7185c392 | ||
|
|
1350ef9522 | ||
|
|
c00c18bbe0 | ||
|
|
bce502999d | ||
|
|
f832ee9882 | ||
|
|
1861a23efc | ||
|
|
1901383c20 | ||
|
|
6f59f7fdb5 | ||
|
|
c7de86c096 | ||
|
|
18c8d75003 | ||
|
|
4de41f07eb | ||
|
|
0ac771418f | ||
|
|
476c807e34 | ||
|
|
44f9763f30 | ||
|
|
e9ea9517d7 | ||
|
|
bc77bdd610 | ||
|
|
f0c0e01f27 | ||
|
|
001d804d76 | ||
|
|
d572b410c6 | ||
|
|
00613c9a4f | ||
|
|
add03e9a0f | ||
|
|
21bb3cd957 | ||
|
|
6dfb6959e9 | ||
|
|
0b22d413cf | ||
|
|
83afa346d2 | ||
|
|
f4f46be906 | ||
|
|
6013862653 | ||
|
|
1c152e5dfb | ||
|
|
e8d92c5317 | ||
|
|
0b2a7eda5f | ||
|
|
e19577015f | ||
|
|
afdbe8b32c | ||
|
|
2d3a57cc59 | ||
|
|
5f41bb2bc8 | ||
|
|
06a9c2df95 | ||
|
|
3ac3e8df2f | ||
|
|
ae13977b7d | ||
|
|
99cabd9bcd | ||
|
|
9674d80737 | ||
|
|
2e2bf1233c | ||
|
|
7ffd919884 | ||
|
|
7a31d69e3a |
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,6 +2,30 @@
|
||||
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
|
||||

|
||||
|
||||

|
||||
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/Resources/LICENSE.txt
|
||||
|
||||
### Maven:
|
||||
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.BenCodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
Versions:
|
||||
LATEST - latest stable release
|
||||
BRANCH-SNAPHSOT - unstable builds
|
||||
|
||||
|
||||
+22
-8
@@ -1,11 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="lib" path="D:/programming/Liabaries/Votifier.jar"/>
|
||||
<classpathentry kind="lib" path="D:/programming/Liabaries/Vault.jar"/>
|
||||
<classpathentry kind="lib" path="D:/Horizon/Test Server/plugins/PlaceholderAPI.jar"/>
|
||||
<classpathentry kind="lib" path="D:/Horizon/buildtools/spigot-1.10.2.jar"/>
|
||||
<classpathentry kind="lib" path="D:/Horizon/Test Server/plugins/SpigotLib.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="Resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -1 +1,3 @@
|
||||
/bin/
|
||||
/target/
|
||||
/doc/
|
||||
@@ -10,8 +10,24 @@
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -0,0 +1,7 @@
|
||||
add_todo=false
|
||||
eclipse.preferences.version=1
|
||||
include_subpackages=true
|
||||
mode=mode_replace
|
||||
project_specific_settings=true
|
||||
replacements=<?xml version\="1.0" standalone\="yes"?>\n\n<replacements>\n<replacement key\="get" scope\="1" mode\="0">Gets the</replacement>\n<replacement key\="set" scope\="1" mode\="0">Sets the</replacement>\n<replacement key\="add" scope\="1" mode\="0">Adds the</replacement>\n<replacement key\="edit" scope\="1" mode\="0">Edits the</replacement>\n<replacement key\="remove" scope\="1" mode\="0">Removes the</replacement>\n<replacement key\="init" scope\="1" mode\="0">Inits the</replacement>\n<replacement key\="parse" scope\="1" mode\="0">Parses the</replacement>\n<replacement key\="create" scope\="1" mode\="0">Creates the</replacement>\n<replacement key\="build" scope\="1" mode\="0">Builds the</replacement>\n<replacement key\="is" scope\="1" mode\="0">Checks if is</replacement>\n<replacement key\="print" scope\="1" mode\="0">Prints the</replacement>\n<replacement key\="has" scope\="1" mode\="0">Checks for</replacement>\n</replacements>\n\n
|
||||
use_internal_formatter=true
|
||||
@@ -0,0 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=Cp1252
|
||||
encoding/Resources=Cp1252
|
||||
encoding/src=Cp1252
|
||||
@@ -7,6 +7,24 @@ org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
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.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
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.missingJavadocComments=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocTagDescription=all_standard_tags
|
||||
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.reportPreviewFeatures=ignore
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false
|
||||
@@ -0,0 +1,4 @@
|
||||
activeProfiles=dev
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,3 @@
|
||||
eclipse.preferences.version=1
|
||||
project.repository.kind=github
|
||||
project.repository.url=http\://github.com/Ben12345rocks/VotingPlugin
|
||||
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
org.jboss.ide.eclipse.as.core.singledeployable.deployableList=\n
|
||||
@@ -1,19 +0,0 @@
|
||||
# BungeeVoting.yml
|
||||
# On vote, plugin will forward the votifier vote to the following servers
|
||||
# Put in the votifier information for each server below
|
||||
# ServiceSite is not needed. Leave blank.
|
||||
|
||||
# Send bungee votes
|
||||
Enabled: false
|
||||
|
||||
Servers:
|
||||
# Server, don't have 2 names the same
|
||||
Server1:
|
||||
# Votifier IP
|
||||
IP: ''
|
||||
# Votifier port
|
||||
Port: 8129
|
||||
# Votifier key of this server
|
||||
Key: 'PUBLICKEY'
|
||||
# Add custom service site, leave blank to use the service site from the vote
|
||||
ServiceSite: ''
|
||||
@@ -1,71 +0,0 @@
|
||||
# VotingPlugin by Ben12345rocks
|
||||
# Main Config
|
||||
# See wiki for help:
|
||||
# https://github.com/Ben12345rocks/VotingPlugin/wiki
|
||||
|
||||
# Wether debug info will be displayed
|
||||
Debug: false
|
||||
|
||||
# Broadcast votes
|
||||
BroadcastVote: true
|
||||
|
||||
# Let players who never joined before vote
|
||||
AllowUnjoined: false
|
||||
|
||||
# If true /vote will open VoteURL GUI
|
||||
VoteURLDefault: false
|
||||
|
||||
# If true, plugin will send scoreboards on commands
|
||||
SendScoreboards: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being
|
||||
# created randomly
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Number of seconds between background updates
|
||||
# Default: 600 (10 minutes)
|
||||
BackgroundTaskDelay: 600
|
||||
|
||||
|
||||
# --------- Voting Effects --------
|
||||
# The following will be sent to voter when the voter is online
|
||||
# You can also send the following in each reward file if you wish
|
||||
# This will only run once if player has voted offline, regardless of number of votes
|
||||
# Setting them here works better for offline votes
|
||||
|
||||
# Title to send to voter on vote
|
||||
# Requires SpigotLib (and all of its requirements)
|
||||
# Download here:
|
||||
# https://www.spigotmc.org/resources/spigotlib.5925/
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cThanks for voting!'
|
||||
SubTitle: '&aYou voted!'
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
|
||||
# Sound to voter
|
||||
Sound:
|
||||
# Enable or Disable Sound
|
||||
Enabled: false
|
||||
# Sound to play
|
||||
# 1.10 Sounds: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
|
||||
Sound: 'BLOCK_ANVIL_USE'
|
||||
# Volume
|
||||
# Range: 0.0 to 1.0
|
||||
Volume: 1.0
|
||||
# Pitch
|
||||
# Range: 0.0 to 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# Play particle effect to voter
|
||||
# 1.10 Effects can be found here:
|
||||
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Effect.html
|
||||
Effect:
|
||||
Enabled: false
|
||||
Effect: 'EXPLOSION'
|
||||
Data: 0
|
||||
Particles: 10
|
||||
Radius: 5
|
||||
@@ -1,144 +0,0 @@
|
||||
# Format.yml
|
||||
# Set your format here
|
||||
#
|
||||
# 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
|
||||
|
||||
Format:
|
||||
|
||||
# Broadcast vote message
|
||||
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
|
||||
|
||||
# Broadcast only when player is online
|
||||
BroadcastWhenOnline: false
|
||||
|
||||
Commands:
|
||||
# Format for /vote
|
||||
# %num% = the number of the site, for a numbered list
|
||||
# %url% = site URL
|
||||
Vote:
|
||||
Title:
|
||||
- '&4&lVote for our server!'
|
||||
|
||||
# For each VoteSite
|
||||
# make sure to set VoteURL in your VoteSites
|
||||
Sites: '&4%num%: &c&l%SiteName% - &c%url%'
|
||||
|
||||
# Format for /vote next
|
||||
Next:
|
||||
# First line
|
||||
Title: '&3&l%player% Next Votes:'
|
||||
|
||||
# How each line is setup for each vote site
|
||||
# %info% = Info - See Below
|
||||
# %SiteName% = site name from vote
|
||||
Layout: '&3%SiteName%: &6%info%'
|
||||
|
||||
Info:
|
||||
# Message when player can vote
|
||||
CanVote: 'Go Vote!'
|
||||
# Time until vote msg
|
||||
# %hours% = hours until next vote
|
||||
# %minutes% = minutes until next vote
|
||||
TimeUntilVote: '%hours% Hours and %minutes% Minutes'
|
||||
# If there is an error finding out time until next vote
|
||||
Error: '&cCould not caculate time until next vote!'
|
||||
|
||||
# Format for /vote last
|
||||
Last:
|
||||
# First line
|
||||
Title: '&3&l%player% Last Vote Times:'
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
Line: '&3%SiteName%: &6%time%'
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
# First line
|
||||
Title: '&3&l%player% Total Votes:'
|
||||
# %Total% = total for that site
|
||||
# %SiteName% = site name
|
||||
Line: '&3%SiteName%: &6%Total%'
|
||||
# %Totals% = totals of all sites added up
|
||||
Total: '&3&lTotal: &6&l%Totals%'
|
||||
|
||||
# Format for /vote total all
|
||||
TotalAll:
|
||||
# First line
|
||||
Title: '&3&lAll Votes Total:'
|
||||
# %Total% = total for that site
|
||||
Line: '&3%SiteName% &6%Total%'
|
||||
# %Totals% = totals of all sites added up
|
||||
Total: '&3&lTotal: &6&l%Totals%'
|
||||
|
||||
# Format for /vote top
|
||||
Top:
|
||||
# First line
|
||||
# %page% = current page
|
||||
# %maxpages% = max number of pages
|
||||
# %Top% = Monthly/Weekly/Daily (depending on command)
|
||||
Title: '&3Top Voters %Top% %page%/%maxpages%'
|
||||
# Line for each player in that page
|
||||
Line: '&c%num%: &6%player%, %votes%'
|
||||
|
||||
# Format for /vote help
|
||||
Help:
|
||||
# Title of /vote help
|
||||
Title: '&3&lVoting Player Help'
|
||||
# Format for help message in /v help
|
||||
Line: '&3&l%Command% - &3%HelpMessage%'
|
||||
# Require permission to see command in /v help or /av help
|
||||
RequirePermission: true
|
||||
|
||||
# PlaceHolders:
|
||||
# %VotesRequired% = VotesRequired
|
||||
# %NeededVotes% = Number of votes needed to reach VotesRequired
|
||||
# %Votes% = Number of votes
|
||||
Party:
|
||||
- '&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%'
|
||||
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
# Login message if player can vote on all sites
|
||||
# Must be enabled in config.yml
|
||||
LoginMsg: '&cRemember to vote!'
|
||||
|
||||
# Msg on reward given
|
||||
# PlaceHolders:
|
||||
# %money% = amount of money given for votesite
|
||||
# %items% = string list of items
|
||||
DefaultRewardMsg: '&aYou were given rewards!'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
TopVoterAwardMsg: '&aYou came in %place% in top voters of the month! Here is an award!'
|
||||
|
||||
# Time Format
|
||||
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
TimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
# Format for signs
|
||||
# SiteName may be all, depending on sign
|
||||
# %position% = position of player, set by sign
|
||||
# %votes% = Number of votes
|
||||
Signs:
|
||||
TopVoterSign:
|
||||
Line1: 'TopVoter: %SiteName%'
|
||||
Line2: '#%position%'
|
||||
Line3: '%player%'
|
||||
Line4: '%votes% Votes'
|
||||
# Message when right clicking sign, uses same placeholders as above
|
||||
RightClickMessage: '&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cvotes in &c&l%SiteName%'
|
||||
|
||||
# Message when player tries to run command without required permissions
|
||||
NoPerms: '&cYou do not have enough permission!'
|
||||
|
||||
# Message when player types a command but does not input a number where needed
|
||||
NotNumber: '&cError on &6%arg%&c, number expected!'
|
||||
|
||||
# TimeZone
|
||||
TimeZone: 'UTC'
|
||||
@@ -1,134 +0,0 @@
|
||||
# Configure GUI's here
|
||||
# Note: Slots start at 0 instead of 1, max slots 44 (don't go over) (E.g: so 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%'
|
||||
Command: 'vote'
|
||||
Slot: 0
|
||||
Next:
|
||||
Item:
|
||||
Material: 'COMPASS'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Next'
|
||||
Command: 'vote next'
|
||||
Slot: 1
|
||||
Last:
|
||||
Item:
|
||||
Material: 'WATCH'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
Command: 'vote last'
|
||||
Slot: 2
|
||||
Total:
|
||||
Item:
|
||||
Material: 'CHEST'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Total'
|
||||
Command: 'vote total'
|
||||
Slot: 3
|
||||
Top:
|
||||
Item:
|
||||
Material: 'SIGN'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Top'
|
||||
Command: 'vote top'
|
||||
Slot: 4
|
||||
Today:
|
||||
Item:
|
||||
Material: 'BOOK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Today'
|
||||
Command: 'vote today'
|
||||
Slot: 5
|
||||
Help:
|
||||
Item:
|
||||
Material: 'WRITTEN_BOOK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Help'
|
||||
Command: 'vote help'
|
||||
Slot: 6
|
||||
Rewards:
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Voting Rewards'
|
||||
Command: 'vote reward'
|
||||
Slot: 7
|
||||
# GUI for /vote url
|
||||
# And /vote if enabled in Config.yml
|
||||
VoteURL:
|
||||
SiteName: '&c%Name%'
|
||||
SeeURL: '&cClick to see URL'
|
||||
NextVote: '&cCan Vote In: %Info%'
|
||||
ViewAllUrlsButtonEnabled: true
|
||||
AlreadyVotedItem:
|
||||
Material: 'REDSTONE_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
CanVoteItem:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
# Customize /vote reward
|
||||
# Show players what you get when you vote on each site
|
||||
VoteReward:
|
||||
# Name of votesite
|
||||
# If your site name contains a dot, replace it with a - and surround the name with ' '
|
||||
SiteName:
|
||||
# Item to display as vote site in /vote reward
|
||||
Item:
|
||||
# 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'
|
||||
# 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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,51 @@
|
||||
# --------------------------
|
||||
# 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
|
||||
|
||||
# If true & AllowUnJoined is false (Config.yml) it will remove any invalid players
|
||||
# Not fully tested, could cause some trouble in some cases
|
||||
RemoveInvalidUsers: 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
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add this to bungee server
|
||||
SpigotServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
@@ -0,0 +1,582 @@
|
||||
# VotingPlugin by Ben12345rocks
|
||||
# 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
|
||||
# - FLAT
|
||||
# - MYSQL
|
||||
DataStorage: SQLITE
|
||||
|
||||
# Information for mysql
|
||||
# See the end of the config for cache options
|
||||
MySQL:
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# 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
|
||||
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data)
|
||||
AllowUnjoined: false
|
||||
|
||||
# Use server lookup for when allowunjoined is set to false
|
||||
# Recommend leaving enabled unless you face issues
|
||||
AllowUnJoinedCheckServer: true
|
||||
|
||||
# ------------------------------------------------
|
||||
# VoteReminding
|
||||
# ------------------------------------------------
|
||||
|
||||
# Configuration for VoteReminding
|
||||
# By default this should be all setup to work
|
||||
# as long as vote delays are done properly
|
||||
VoteReminding:
|
||||
# Enable vote reminding
|
||||
# This will remind player when he can vote on all sites
|
||||
# Requires VoteDelays to be setup properly
|
||||
# Use /vote next to see when you can be reminded
|
||||
# Players require the perm "VotingPlugin.Login.RemindVotes" or "VotingPlugin.Player"
|
||||
Enabled: true
|
||||
|
||||
# Whether or not to remind only once when the player can vote
|
||||
# Does not apply to login reminds.
|
||||
RemindOnlyOnce: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
# Ignores value above
|
||||
RemindOnLogin: true
|
||||
|
||||
# Delay to remind votes in minutes
|
||||
# Only works if above is false
|
||||
RemindDelay: 30
|
||||
|
||||
# Run reward files on remind
|
||||
# By default, the reward file will be created for you
|
||||
# and have the default message
|
||||
# Edit the message at AdvancedCore/Rewards/Remind.yml (or any other reward listed)
|
||||
# Can add titles and more in the reward file
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aRemember to vote!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
SubTitle: '&aType /vote'
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
ActionBar:
|
||||
Message: '&cRemember to vote'
|
||||
Delay: 30
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
# ------------------------------------------------
|
||||
|
||||
# Common PlacesHolders:
|
||||
# Special PlaceHolders will be commented where available
|
||||
# %player% = player name
|
||||
# %SiteName% = vote site name
|
||||
#
|
||||
# Set Message to '' (2 ') to disable message
|
||||
|
||||
Format:
|
||||
# CommandHandler help message
|
||||
# Mainly used in admin help page, see below for /vote help
|
||||
HelpLine: '&6%Command% - &6%HelpMessage%'
|
||||
|
||||
# Broadcast vote message
|
||||
# Set to an empty message to disable
|
||||
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
|
||||
|
||||
# Broadcast only when player is online
|
||||
BroadcastWhenOnline: false
|
||||
|
||||
Commands:
|
||||
# Format for /vote
|
||||
# %num% = the number of the site, for a numbered list
|
||||
# %url% = site URL
|
||||
Vote:
|
||||
Text:
|
||||
- '&3&lVote for our server!'
|
||||
|
||||
# If you want to want to use the feature below where the plugin will
|
||||
# automaticly list the sites then set the message in the text above
|
||||
AutoInputSites: true
|
||||
# For each VoteSite
|
||||
# make sure to set VoteURL in your VoteSites
|
||||
# Requires above to be true
|
||||
# Text will be sent before this
|
||||
Sites: '&3%num%: &6&l%SiteName% &6- %url%'
|
||||
|
||||
# If true, links will always be forced as urls
|
||||
ForceLinks: true
|
||||
|
||||
# Format for /vote next
|
||||
Next:
|
||||
# First line
|
||||
Title: '&3&l%player% Next Votes:'
|
||||
|
||||
# How each line is setup for each vote site
|
||||
# %info% = Info - See Below
|
||||
# %SiteName% = site name from vote
|
||||
Layout: '&3%SiteName%: &6%info%'
|
||||
|
||||
Info:
|
||||
# Message when player can vote
|
||||
CanVote: 'Go Vote!'
|
||||
# Time until vote msg
|
||||
# %hours% = hours until next vote
|
||||
# %minutes% = minutes until next vote
|
||||
TimeUntilVote: '%hours% Hours and %minutes% Minutes'
|
||||
# If there is an error finding out time until next vote
|
||||
Error: '&cCould not caculate time until next vote!'
|
||||
# For sites that have this, requires votedelaydaily to be set to true in the site
|
||||
VoteDelayDaily: '%hours% Hours and %minutes% Minutes'
|
||||
|
||||
# Format for /vote last
|
||||
Last:
|
||||
# First line
|
||||
Title: '&3&l%player% Last Vote Times:'
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
# %timesince% = time since vote
|
||||
Line: '&3%SiteName%: &6%timeSince%'
|
||||
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
LastVoted: '%times% ago'
|
||||
NeverVoted: 'Never voted'
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
- '&3&l%player% Total Votes:'
|
||||
- '&3&lDaily Total: &6&l%DailyTotal%'
|
||||
- '&3&lWeekly Total: &6&l%WeeklyTotal%'
|
||||
- '&3&lMonthly Total: &6&l%MonthlyTotal%'
|
||||
- '&3&lAllTime Total: &6&l%AllTimeTotal%'
|
||||
|
||||
# Format for /vote total all
|
||||
TotalAll:
|
||||
- '&3&lServer Total Votes:'
|
||||
- '&3&lDaily Total: &6&l%DailyTotal%'
|
||||
- '&3&lWeekly Total: &6&l%WeeklyTotal%'
|
||||
- '&3&lMonthly Total: &6&l%MonthlyTotal%'
|
||||
- '&3&lAllTime Total: &6&l%AllTimeTotal%'
|
||||
|
||||
# Format for /vote top
|
||||
Top:
|
||||
# First line
|
||||
# %page% = current page
|
||||
# %maxpages% = max number of pages
|
||||
# %Top% = Monthly/Weekly/Daily (depending on command)
|
||||
Title: '&3Top %Top% Voters %page%/%maxpages%'
|
||||
# Line for each player in that page
|
||||
Line: '&c%num%: &6%player%, %votes%'
|
||||
|
||||
# Format for /vote help
|
||||
Help:
|
||||
# Title of /vote help
|
||||
Title: '&6&lVoting Player Help'
|
||||
# Format for help message in /v help
|
||||
Line: '&6%Command% - &6%HelpMessage%'
|
||||
# Require permission to see command in /v help or /av help
|
||||
RequirePermission: true
|
||||
|
||||
Best:
|
||||
Title: '&3&l%player% Best Votes'
|
||||
Lines:
|
||||
- '&3Highest Daily Total: &3&l%HighestDailyTotal%'
|
||||
- '&3Highest Week Total: &3&l%HighestWeeklyTotal%'
|
||||
- '&3Highest Month Total: &3&l%HighestMonthlyTotal%'
|
||||
|
||||
Streak:
|
||||
Title: '&3&l%player% Vote Streak'
|
||||
Lines:
|
||||
- '&3Current Daily Streak: &3&l%DailyStreak%'
|
||||
- '&3Current Week Streak: &3&l%WeeklyStreak%'
|
||||
- '&3Current Month Streak: &3&l%MonthlyStreak%'
|
||||
- '&3&lHighest Streaks:'
|
||||
- '&3Highest Daily Streak: &3&l%BestDailyStreak%'
|
||||
- '&3Highest Week Streak: &3&l%BestWeeklyStreak%'
|
||||
- '&3Highest Month Streak: &3&l%BestMonthlyStreak%'
|
||||
|
||||
Today:
|
||||
Line: '&6%player% : %VoteSite% : %Time%'
|
||||
|
||||
# PlaceHolders:
|
||||
# %VotesRequired% = VotesRequired
|
||||
# %NeededVotes% = Number of votes needed to reach VotesRequired
|
||||
# %Votes% = Number of votes
|
||||
Party:
|
||||
- '&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%'
|
||||
|
||||
# %Points% = player points
|
||||
Points: '&a%Player% currently has &a&l%Points%&a Points!'
|
||||
|
||||
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
|
||||
TopVoterAwardMsg: '&aYou came in %place% in top voters of the month! Here is an award!'
|
||||
|
||||
# Time Format
|
||||
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
TimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
TimeFormats:
|
||||
Day: 'Day'
|
||||
Days: 'Days'
|
||||
Hour: 'Hour'
|
||||
Hours: 'Hours'
|
||||
Minute: 'Minute'
|
||||
Minutes: 'Minutes'
|
||||
Second: 'Second'
|
||||
Seconds: 'Seconds'
|
||||
|
||||
# Format for signs
|
||||
# SiteName may be all, depending on sign
|
||||
# %position% = position of player, set by sign
|
||||
# %votes% = Number of votes
|
||||
Signs:
|
||||
TopVoterSign:
|
||||
Line1: 'TopVoter: %SiteName%'
|
||||
Line2: '#%position%'
|
||||
Line3: '%player%'
|
||||
Line4: '%votes% Votes'
|
||||
# Message when right clicking sign, uses same placeholders as above
|
||||
RightClickMessage: '&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cvotes in &c&l%SiteName%'
|
||||
|
||||
# Message when player tries to run command without required permissions
|
||||
NoPerms: '&cYou do not have enough permission!'
|
||||
|
||||
# Message when player types a command but does not input a number where needed
|
||||
NotNumber: '&cError on &6%arg%&c, number expected!'
|
||||
|
||||
# Shop messages when using the /vote shop
|
||||
ShopPurchase: '&aYou bought the %Identifier% for %Points% Points!'
|
||||
ShopFailed: '&cYou do not have %Points% points to purchase this!'
|
||||
|
||||
# User not exist message, from commands such as /vote next (player)
|
||||
UserNotExist: '&cUser does not exist: %player%'
|
||||
|
||||
# Prev/Next page tems in GUIs
|
||||
PrevItem:
|
||||
Material: 'BLACK_STAINED_GLASS_PANE'
|
||||
Amount: 1
|
||||
Name: '&aPrevious Page'
|
||||
|
||||
NextItem:
|
||||
Material: 'BLACK_STAINED_GLASS_PANE'
|
||||
Amount: 1
|
||||
Name: '&aNext Page'
|
||||
|
||||
InvFull: '&cInventory full'
|
||||
|
||||
# Display text
|
||||
# Used in /vote top (GUI)
|
||||
TopVoter:
|
||||
Daily: 'Daily'
|
||||
Weekly: 'Weekly'
|
||||
Monthly: 'Monthly'
|
||||
AllTime: 'AllTime'
|
||||
|
||||
# ------------------------------------------------
|
||||
# Top Voter
|
||||
# Top voter rewards available in specialrewards.yml
|
||||
# ------------------------------------------------
|
||||
|
||||
# Top voter blacklist
|
||||
# Hide these names from top voter lists
|
||||
BlackList:
|
||||
- 'Notch'
|
||||
|
||||
# If true players with the permission 'VotingPlugin.TopVoter.Ignore' will act
|
||||
# as if there name was added on the the blacklist above
|
||||
# This also applies for players with op
|
||||
TopVoterIgnorePermission: false
|
||||
|
||||
# /vote top default data displayed
|
||||
# Valid Options: AllTime, Monthly, Weekly, Daily
|
||||
VoteTopDefault: Monthly
|
||||
|
||||
# Whether or not to have ties on top voter rewards
|
||||
TopVoterAwardsTies: true
|
||||
|
||||
# These are required to be enabled in order for top voter awards to work
|
||||
LoadTopVoter:
|
||||
AllTime: true
|
||||
Monthly: true
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# Maxium number of players to show on top voter
|
||||
# Set to -1 for no limit
|
||||
MaxiumNumberOfTopVotersToLoad: -1
|
||||
|
||||
# When top voter awards are given (even if there are none listed) it will store top voters
|
||||
# Files will created in TopVoters folder.
|
||||
StoreTopVoters:
|
||||
Monthly: true
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# ------------------------------------------------
|
||||
# Advanced
|
||||
# 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
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# If true, items given for rewards are dropped on the ground
|
||||
# If false, items will be given when there is space
|
||||
DropOnFullInv: true
|
||||
|
||||
# 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
|
||||
|
||||
AddCustomCommands: false
|
||||
|
||||
# Injects custom command to /vote
|
||||
# Requires AddCustomCommand: true to be set
|
||||
CustomCommands:
|
||||
# identifier, not specific name
|
||||
command1:
|
||||
Args:
|
||||
- token
|
||||
# Message to send on command
|
||||
Message: 'token message'
|
||||
# Permission for this command
|
||||
Permission: 'votingplugin.commands.vote.token'
|
||||
# help message
|
||||
HelpMessage: 'See tokens'
|
||||
# Forces player to run this command
|
||||
Commands:
|
||||
- tokencommand
|
||||
|
||||
######################
|
||||
# Debug
|
||||
######################
|
||||
|
||||
# Debug levels:
|
||||
# NONE
|
||||
# INFO
|
||||
# EXTRA
|
||||
DebugLevel: NONE
|
||||
|
||||
# Debug info ingame
|
||||
# Players with permission "VotingPlugin.Debug"
|
||||
# will see debug info if debug is true
|
||||
DebugInGame: false
|
||||
|
||||
# Will log debug messages to VotingPlugin/Log/log.txt
|
||||
# Only needed for extreme cases
|
||||
#LogDebugToFile: false
|
||||
|
||||
# Whether or not to log every vote to a file
|
||||
# Use this if you wanna track player votes
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
# 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
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
# Will also disable a few other warnings about vote sites
|
||||
DisableNoServiceSiteMessage: false
|
||||
|
||||
# Count fake votes
|
||||
# If true fake votes will give points and totals
|
||||
CountFakeVotes: true
|
||||
|
||||
# Give VotingPlugin.Player by default
|
||||
# Requires restart to take affect
|
||||
GiveDefaultPermission: true
|
||||
|
||||
# Permissions given by VotingPlugin.Player by default
|
||||
# Permissions listed here will no be accessible with the default permission
|
||||
DisabledDefaultPermissions: []
|
||||
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get kept)
|
||||
CreateBackups: true
|
||||
|
||||
# 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,321 @@
|
||||
# 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 orders as it is below
|
||||
URL:
|
||||
# Standard item format, lore is automaticly applied
|
||||
Item:
|
||||
Material: 'BOW'
|
||||
Data: 0
|
||||
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'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Next'
|
||||
Last:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
Total:
|
||||
Item:
|
||||
Material: 'CHEST'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Total'
|
||||
Top:
|
||||
Item:
|
||||
Material: 'OAK_SIGN'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Top'
|
||||
Today:
|
||||
Item:
|
||||
Material: 'BOOK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Today'
|
||||
Shop:
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
|
||||
# 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
|
||||
Slot: 7
|
||||
# Number of topvoters to display on page +9
|
||||
# 9 Slots on the botton are used for page buttons
|
||||
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
|
||||
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]'
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,193 @@
|
||||
# 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
|
||||
# Reset at the end of the month
|
||||
ResetMonthly: 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%!'
|
||||
@@ -0,0 +1,117 @@
|
||||
VoteSites:
|
||||
# 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
|
||||
# Default: false
|
||||
Enabled: false
|
||||
|
||||
# Display name of voting site
|
||||
Name: 'ExampleVoteSite'
|
||||
|
||||
# Priority of this site
|
||||
# Used for sorted list
|
||||
# High prority, higher on the list
|
||||
Priority: 5
|
||||
|
||||
# The serviceName from the vote, has to be correct to work correctly
|
||||
# Gotten from voting on the site (will be in console/log)
|
||||
# Usually is the main part of the url(e.g. PlanetMinecraft.com), but not always
|
||||
# See console when you vote (it will notify you if the plugin didn't find a votingsite matching the service site
|
||||
ServiceSite: 'PlanetMinecraft.com'
|
||||
|
||||
# vote url for /vote
|
||||
# Format for this can be set in 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 while the player is offline
|
||||
# This basiclly disables offline voting if set to true, don't misinterpret this option
|
||||
ForceOffline: false
|
||||
|
||||
# VoteSite Material for some GUI's
|
||||
# Removing this may result in an error, required on each site
|
||||
DisplayItem:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# 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'
|
||||
|
||||
# Reward for any site
|
||||
# Similar to AnySiteReward
|
||||
# This requires the site to be configured in order to get the reward.
|
||||
EverySiteReward: []
|
||||
@@ -0,0 +1,4 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.bungee.VotingPluginBungee
|
||||
author: BenCodez
|
||||
@@ -0,0 +1,64 @@
|
||||
# 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
|
||||
Broadcast: true
|
||||
|
||||
# Bungee communication, Add this to each spigot server
|
||||
BungeeServer:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1297
|
||||
|
||||
# Bungee communication, add each spigot server here
|
||||
SpigotServers:
|
||||
lobby:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1298
|
||||
factions:
|
||||
Host: '127.0.0.1'
|
||||
Port: 1999
|
||||
@@ -0,0 +1,248 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.bencodez.votingplugin.VotingPluginMain
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: BenCodez
|
||||
softdepend: [MVdWPlaceholders, Votifier, VotifierPlus, NuVotifier, CMI, Vault, PlaceholderAPI, ProtocolLib, MVdWPlaceholderAPI, AuthMe]
|
||||
api-version: 1.13
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
adminvote:
|
||||
description: Admin commands for VotingPlugin
|
||||
av:
|
||||
description: Admin commands for VotingPlugin
|
||||
votehelp:
|
||||
description: See access to a list of commands, Formated in Format.yml
|
||||
aliases: vhelp
|
||||
votetotal:
|
||||
description: See totals of votes
|
||||
aliases: vtotal
|
||||
votelast:
|
||||
description: See the last time you voted
|
||||
aliases: vlast
|
||||
votenext:
|
||||
description: See when you can vote next
|
||||
aliases: vnext
|
||||
votetop:
|
||||
description: See top voters
|
||||
aliases: vtop
|
||||
votetoday:
|
||||
description: See who voted today
|
||||
aliases: vtoday
|
||||
votegui:
|
||||
description: Open VoteGUI
|
||||
aliases: vgui
|
||||
voteurl:
|
||||
description: Open VoteURL
|
||||
aliases: vurl
|
||||
votereward:
|
||||
description: Open VoteReward GUI
|
||||
aliases: vreward
|
||||
vote?:
|
||||
description: View Help
|
||||
aliases: v?
|
||||
voteparty:
|
||||
description: A command
|
||||
aliases: vparty
|
||||
voteshop:
|
||||
description: A command
|
||||
aliases: vshop
|
||||
votebest:
|
||||
description: A command
|
||||
aliases: vbest
|
||||
votestreak:
|
||||
description: A command
|
||||
aliases: vstreak
|
||||
votetogglebroadcast:
|
||||
description: A command
|
||||
aliases: vtogglebroadcast
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votelist:
|
||||
description: A command
|
||||
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?
|
||||
adminvotereport:
|
||||
description: Command Alias
|
||||
aliases: avreport
|
||||
adminvoteperms:
|
||||
description: Command Alias
|
||||
aliases: avperms
|
||||
adminvoteDownload:
|
||||
description: Command Alias
|
||||
aliases: avdownload
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
adminvotetestreward:
|
||||
description: Command Alias
|
||||
aliases: avtestreward
|
||||
adminvoteversion:
|
||||
description: Command Alias
|
||||
aliases: avversion
|
||||
adminvotesites:
|
||||
description: Command Alias
|
||||
aliases: avsites
|
||||
adminvoterewards:
|
||||
description: Command Alias
|
||||
aliases: avrewards
|
||||
adminvoteuuid:
|
||||
description: Command Alias
|
||||
aliases: avuuid
|
||||
adminvotevotesite:
|
||||
description: Command Alias
|
||||
aliases: avvotesite
|
||||
adminvoteconfig:
|
||||
description: Command Alias
|
||||
aliases: avconfig
|
||||
adminvoteupdatecheck:
|
||||
description: Command Alias
|
||||
aliases: avupdatecheck
|
||||
adminvotevote:
|
||||
description: Command Alias
|
||||
aliases: [avvote, fakevote]
|
||||
adminvotegui:
|
||||
description: Command Alias
|
||||
aliases: avgui
|
||||
adminvotegivereward:
|
||||
description: Command Alias
|
||||
aliases: avgivereward
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
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
|
||||
adminvoteGiveAll:
|
||||
description: Command Alias
|
||||
aliases: avGiveAll
|
||||
adminvoteGiveAllOnline:
|
||||
description: Command Alias
|
||||
aliases: avGiveAllOnline
|
||||
adminvoteForceTimeChanged:
|
||||
description: Command Alias
|
||||
aliases: avForceTimeChanged
|
||||
adminvoteplayername:
|
||||
description: Command Alias
|
||||
aliases: avplayername
|
||||
adminvoteResyncMilestones:
|
||||
description: Command Alias
|
||||
aliases: avResyncMilestones
|
||||
adminvoteClearOfflineRewards:
|
||||
description: Command Alias
|
||||
aliases: avClearOfflineRewards
|
||||
adminvoteUserRemove:
|
||||
description: Command Alias
|
||||
aliases: avUserRemove
|
||||
adminvotePurge:
|
||||
description: Command Alias
|
||||
aliases: avPurge
|
||||
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 commands
|
||||
VotingPlugin.Admin:
|
||||
description: Allows admincommands
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Allows players to get remined on login if they can vote
|
||||
default: true
|
||||
VotingPlugin.Admin.Debug:
|
||||
description: Permission to view debug info ingame
|
||||
VotingPlugin.Signs.Create:
|
||||
description: Allows access to create signs
|
||||
VotingPlugin.TopVoter.Ignore:
|
||||
description: Allows you to be exempt from top voter
|
||||
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}
|
||||
@@ -1,33 +0,0 @@
|
||||
# Other rewards other than vote sites rewards are set here
|
||||
# To disable reward set value to []
|
||||
# Eg:
|
||||
# FirstVote: [] (All in one line)
|
||||
|
||||
# First vote rewrrards
|
||||
FirstVote:
|
||||
- 'FirstVote'
|
||||
|
||||
# All vote rewards
|
||||
# Reward for voting on all sites in one day
|
||||
AllSites:
|
||||
- 'AllSites'
|
||||
|
||||
# Give rewards after certain number of votes
|
||||
VotesRequired: 0
|
||||
# Wether or not votes must be made in same day
|
||||
# Useful if you want to require a certain number of voting sites to be voted on
|
||||
# for a daily reward instead of all of them
|
||||
VotesInSameDay: false
|
||||
CumulativeRewards:
|
||||
- 'NumberOfVotes'
|
||||
|
||||
VoteParty:
|
||||
# Wether or not vote party is enabled
|
||||
Enabled: true
|
||||
# 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
|
||||
Rewards:
|
||||
- 'ExampleReward'
|
||||
@@ -1,180 +0,0 @@
|
||||
# This is a reward file
|
||||
# Define rewards in here
|
||||
# File name is the reward name, without file extention
|
||||
# This reward is named "ExampleReward"
|
||||
# DO NOT HAVE DUPLICATE NAMES!!
|
||||
|
||||
# Reward are run top to bottom (For the most part)
|
||||
|
||||
# NOTE: Do not use this reward file in more than one place if
|
||||
# delayed or timed is enabled!
|
||||
|
||||
# This will delay the reward file from running
|
||||
Delayed:
|
||||
Enabled: false
|
||||
Hours: 1
|
||||
Minutes: 0
|
||||
|
||||
# Specific time of day to give this reward file
|
||||
# in 24 hour time, relative to local time zone
|
||||
Timed:
|
||||
Enabled: false
|
||||
Hour: 12
|
||||
Minute: 0
|
||||
|
||||
# Chance out of 100
|
||||
# Must be an integer
|
||||
# Set to 0 or 100 for always, or delete this line to disable chance
|
||||
# Will not give any rewards below unless chance is lucky or disabled
|
||||
Chance: 40
|
||||
|
||||
# This is to give random rewards, with fallback
|
||||
# Rewards defined in this reward file below are still given
|
||||
Random:
|
||||
# Chance to give a randomly selected reward below (from list), will only give random reward
|
||||
# if lucky (according to chance)
|
||||
# Works same as chance above
|
||||
Chance: 40
|
||||
# When this reward file is being given, a random reward in the list below
|
||||
# will be given, if chance is lucky
|
||||
# Don't set this reward as a possible reward, may cause infinite loop
|
||||
Rewards: []
|
||||
# A list of fall back rewards if chance is unlucky
|
||||
# Don't set this reward as a reward, may cause infinite loop
|
||||
FallBack: []
|
||||
|
||||
# Require permission to give this reward file
|
||||
# Permission is VotingPlugin.Reward.(REWARDNAME)
|
||||
# E.g: VotingPlugin.Reward.ExampleReward
|
||||
RequirePermission: false
|
||||
|
||||
# Worlds to give this reward in
|
||||
# Player will be given this world once he is in this world
|
||||
# This may not work with money
|
||||
Worlds:
|
||||
- 'world1'
|
||||
- 'world2'
|
||||
|
||||
# If true, the player will be rewarded in each world
|
||||
# If false, the player will be reward one of the worlds once
|
||||
GiveInEachWorld: false
|
||||
|
||||
|
||||
# Items to give to user
|
||||
Items:
|
||||
# Item
|
||||
# This is not item display name
|
||||
# No 2 names the same
|
||||
Diamond:
|
||||
# Item Material
|
||||
# List of material for 1.10:
|
||||
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||
Material: 'DIAMOND'
|
||||
# Item data value (Eg 1:4, data is 4)
|
||||
Data: 0
|
||||
# Will only give Amount if min and max amounts are 0
|
||||
Amount: 1
|
||||
# Set item durability
|
||||
# Set to 0 or remove line for no durability
|
||||
#Durability: 100
|
||||
|
||||
# Random amount of items between Min and Max will be given
|
||||
# if min and max are not both 0
|
||||
# Min amount of items
|
||||
MinAmount: 1
|
||||
# Max amount of items
|
||||
MaxAmount: 4
|
||||
|
||||
# Item name
|
||||
# Remove this value to have no name
|
||||
Name: '&aSpecial Diamond'
|
||||
|
||||
# Lore
|
||||
# Remove this value to have no lore
|
||||
Lore:
|
||||
- 'Line 1'
|
||||
|
||||
# Enchants
|
||||
# List of 1.10 Encahants can be found at
|
||||
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/enchantments/Enchantment.html
|
||||
Enchants:
|
||||
DURABILITY: 1
|
||||
|
||||
# Amount of money to give, requires vault
|
||||
# Use 0 to give none
|
||||
# Use negative to take money
|
||||
Money: 1000
|
||||
|
||||
# Pick random number between min and max amount
|
||||
MinMoney: 100
|
||||
MaxMoney: 3000
|
||||
|
||||
# Give player experience
|
||||
EXP: 100
|
||||
|
||||
# Commands to run
|
||||
# Use %player% for player name
|
||||
# Set to Console: [] for no commands
|
||||
Commands:
|
||||
# Commands here will be run by console
|
||||
Console:
|
||||
- 'say %player% was lucky'
|
||||
# Commands here are run by player
|
||||
Player:
|
||||
- 'vote total'
|
||||
|
||||
# Potions to give on reward
|
||||
Potions:
|
||||
# Potion effect name
|
||||
# 1.10 potions can be found here:
|
||||
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
|
||||
ABSORPTION:
|
||||
# Duration in seconds
|
||||
Duration: 100
|
||||
# Amplifier
|
||||
Amplifier: 1
|
||||
|
||||
# Title to send to voter
|
||||
# Requires SpigotLib
|
||||
# Download here:
|
||||
# https://www.spigotmc.org/resources/spigotlib.5925/
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cThanks for voting!'
|
||||
SubTitle: '&aYou voted on a website!'
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
|
||||
# Sound on reward
|
||||
Sound:
|
||||
# Enable or Disable Sound
|
||||
Enabled: false
|
||||
# Sound to play
|
||||
# 1.9 Sounds: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
|
||||
# 1.8: https://jd.bukkit.org/org/bukkit/Sound.html
|
||||
Sound: 'BLOCK_ANVIL_USE'
|
||||
# Volume
|
||||
# Range: 0.0 to 1.0
|
||||
Volume: 1.0
|
||||
# Pitch
|
||||
# Range: 0.0 to 1.0
|
||||
Pitch: 1.0
|
||||
|
||||
# Play particle effect on reward
|
||||
# 1.10 Effects can be found here:
|
||||
# https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Effect.html
|
||||
Effect:
|
||||
Enabled: false
|
||||
Effect: 'EXPLOSION'
|
||||
Data: 0
|
||||
Particles: 10
|
||||
Radius: 5
|
||||
|
||||
|
||||
# The messages are sent when rewards above are given to user
|
||||
# set to '' to give no message
|
||||
# If no value is set, default in Format.yml is used
|
||||
Messages:
|
||||
Reward: '&aMessage on reward'
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# Top voter blacklist
|
||||
BlackList:
|
||||
- 'Notch'
|
||||
|
||||
EnableMonthlyAwards: true
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
1:
|
||||
# Reward files to give
|
||||
Rewards:
|
||||
- 'TopVoter1'
|
||||
2:
|
||||
Rewards:
|
||||
- 'TopVoter2'
|
||||
|
||||
EnableWeeklyAwards: false
|
||||
# Rewards to give on weekly top voter
|
||||
WeeklyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
1:
|
||||
# Reward files to give
|
||||
Rewards:
|
||||
- 'WeeklyTopVoter1'
|
||||
2:
|
||||
Rewards:
|
||||
- 'WeeklyTopVoter2'
|
||||
|
||||
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:
|
||||
- 'DailyTopVoter1'
|
||||
2:
|
||||
Rewards:
|
||||
- 'DailyTopVoter2'
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
# Options for vote reminding
|
||||
|
||||
# Enable vote reminding
|
||||
# This will remind player when he can vote on all sites
|
||||
# Requires VoteDelay's 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 not to remind only once
|
||||
RemindOnlyOnce: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
# Ignores value above
|
||||
RemindOnLogin: true
|
||||
|
||||
# Delay to remind votes
|
||||
# Only works if above is false
|
||||
# In minutes
|
||||
RemindDelay: 30
|
||||
|
||||
# Run reward files on remind
|
||||
# Set values in the reward file
|
||||
Rewards:
|
||||
- 'VoteReminding'
|
||||
@@ -1,44 +0,0 @@
|
||||
# ExampleVoteSite.yml
|
||||
# This is an Example VoteSite
|
||||
# Located in VoteSites folder in plugin directory
|
||||
# The file name is the VoteSite name (not including the file extenstion)
|
||||
# On vote (of this site), plugin will attempt to give any reward files listed below
|
||||
# Also will attempt cumulative rewards
|
||||
|
||||
# Enable voteSite
|
||||
# If false, votesite will not be loaded by plugin
|
||||
# Default: false
|
||||
Enabled: false
|
||||
|
||||
# Priority of this site
|
||||
# Used for sorted list
|
||||
# High prority, higher on the list
|
||||
Priority: 5
|
||||
|
||||
# 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)
|
||||
ServiceSite: 'PlanetMinecraft.com'
|
||||
|
||||
# vote url for /vote
|
||||
# Format for this can be set in Format.yml
|
||||
# Do not include colors here
|
||||
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
|
||||
|
||||
# List of reward files to give to voter
|
||||
Rewards:
|
||||
- 'ExampleReward'
|
||||
|
||||
# Rewards to give once certain number of votes reached for this vote site
|
||||
# Rewards work similar to above
|
||||
Cumulative:
|
||||
# Number of votes required to give this reward
|
||||
Votes: 20
|
||||
# List of reward files to give on cumulativereward
|
||||
Rewards:
|
||||
- 'ExampleReward'
|
||||
|
||||
@@ -1,134 +0,0 @@
|
||||
name: VotingPlugin
|
||||
version: 4.1.4
|
||||
main: com.Ben12345rocks.VotingPlugin.Main
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: Ben12345rocks
|
||||
commands:
|
||||
vote:
|
||||
description: Vote command
|
||||
v:
|
||||
description: Vote command
|
||||
adminvote:
|
||||
description: Admin commands for VotingPlugin
|
||||
av:
|
||||
description: Admin commands for VotingPlugin
|
||||
votehelp:
|
||||
description: See access to a list of commands, Formated in Format.yml
|
||||
aliases: vhelp
|
||||
votetotal:
|
||||
description: See totals of votes
|
||||
aliases: vtotal
|
||||
votelast:
|
||||
description: See the last time you voted
|
||||
aliases: vlast
|
||||
votenext:
|
||||
description: See when you can vote next
|
||||
aliases: vnext
|
||||
votetop:
|
||||
description: See top voters
|
||||
aliases: vtop
|
||||
voteinfo:
|
||||
description: See player info
|
||||
aliases: vinfo
|
||||
votetoday:
|
||||
description: See who voted today
|
||||
aliases: vtoday
|
||||
votegui:
|
||||
description: Open VoteGUI
|
||||
aliases: vgui
|
||||
voteurl:
|
||||
description: Open VoteURL
|
||||
aliases: vurl
|
||||
votereward:
|
||||
description: Open VoteReward GUI
|
||||
aliases: vreward
|
||||
vote?:
|
||||
description: View Help
|
||||
aliases: v?
|
||||
voteparty:
|
||||
description: A command
|
||||
aliases: vparty
|
||||
voteshop:
|
||||
description: A command
|
||||
aliases: vshop
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
adminvotehelp:
|
||||
description: Open adminvote help
|
||||
aliases: avhelp
|
||||
adminvote?:
|
||||
description: Open adminvote help
|
||||
aliases: av?
|
||||
adminvotereport:
|
||||
description: Command Alias
|
||||
aliases: avreport
|
||||
adminvoteperms:
|
||||
description: Command Alias
|
||||
aliases: avperms
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
adminvoteversion:
|
||||
description: Command Alias
|
||||
aliases: avversion
|
||||
adminvotesites:
|
||||
description: Command Alias
|
||||
aliases: avsites
|
||||
adminvoterewards:
|
||||
description: Command Alias
|
||||
aliases: avrewards
|
||||
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
|
||||
adminvoteTriggerPlayerVoteEvent:
|
||||
description: Command Alias
|
||||
aliases: avTriggerPlayerVoteEvent
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
default: true
|
||||
children:
|
||||
VotingPlugin.Login.RemindVotes: true
|
||||
VotingPlugin.Commands.Vote.Next: true
|
||||
VotingPlugin.Commands.Vote.GUI: true
|
||||
VotingPlugin.Commands.Vote.URL: true
|
||||
VotingPlugin.Commands.Vote.Reward: true
|
||||
VotingPlugin.Commands.Vote.Total: true
|
||||
VotingPlugin.Commands.Vote.Last: true
|
||||
VotingPlugin.Commands.Vote.Info: true
|
||||
VotingPlugin.Commands.Vote.Help: true
|
||||
VotingPlugin.Commands.Vote.Top: true
|
||||
VotingPlugin.Commands.Vote.Top.Monthly: true
|
||||
VotingPlugin.Commands.Vote.Top.Weekly: true
|
||||
VotingPlugin.Commands.Vote.Top.Daily: true
|
||||
VotingPlugin.Login.RemindVotes:
|
||||
description: Allows players to get remined on login if they can vote
|
||||
default: true
|
||||
VotingPlugin.Signs.Create:
|
||||
description: Allows access to create signs
|
||||
VotingPlugin.TopVoter.Ignore:
|
||||
description: Allows you to be exempt from top voter
|
||||
|
||||
@@ -0,0 +1,352 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.bencodez</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>6.1</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>
|
||||
<id>internal.repo</id>
|
||||
<name>Temporary Staging Repository</name>
|
||||
<url>file://${project.build.directory}/mvn-repo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>Resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>plugin.yml</include>
|
||||
<include>bungee.yml</include>
|
||||
<include>votingpluginversion.yml</include>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>Resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<versionRange>[1,)</versionRange>
|
||||
<goals>
|
||||
<goal>delombok</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore />
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<finalName>${project.name}</finalName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-maven-plugin</artifactId>
|
||||
<version>1.18.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>
|
||||
<version>2.4.3</version>
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<relocations>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<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}.votingplugin</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.mrten.mysqlapi</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.mysqlapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.HikariCP</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.HikariCP</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>xyz.upperlevel.spigot.book</pattern>
|
||||
<shadedPattern>${project.groupId}.votingplugin.upperlevel.book</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactSet>
|
||||
<!-- Lets exclude google code, because the server already has this
|
||||
code in it (guava, etc) -->
|
||||
<excludes>
|
||||
<exclude>com.google.*:*</exclude>
|
||||
</excludes>
|
||||
</artifactSet>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<sourcepath>${project.basedir}/target/delombok</sourcepath>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.github.github</groupId>
|
||||
<artifactId>site-maven-plugin</artifactId>
|
||||
<version>0.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>javadoc</id>
|
||||
<goals>
|
||||
<goal>site</goal>
|
||||
</goals>
|
||||
<phase>deploy</phase>
|
||||
<configuration>
|
||||
<message>Maven javadoc for ${project.version}</message>
|
||||
<noJekyll>true</noJekyll>
|
||||
<outputDirectory>${project.build.directory}/apidocs
|
||||
</outputDirectory>
|
||||
<branch>refs/heads/gh-pages</branch>
|
||||
<includes>
|
||||
<include>**/*</include>
|
||||
</includes>
|
||||
<repositoryName>VotingPlugin</repositoryName>
|
||||
<repositoryOwner>BenCodez</repositoryOwner>
|
||||
<server>github</server>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<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>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<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>3.0-SNAPSHOT</version> </dependency> -->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vexsoftware</groupId>
|
||||
<artifactId>votifier</artifactId>
|
||||
<version>1.9</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/Votifier.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<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/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>
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Bungee;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketAddress;
|
||||
import java.security.KeyFactory;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.PublicKey;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigBungeeVoting;
|
||||
import com.vexsoftware.votifier.crypto.RSA;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
|
||||
public class BungeeVote {
|
||||
|
||||
static BungeeVote instance = new BungeeVote();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
static ServerSocket sock;
|
||||
|
||||
public static BungeeVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private BungeeVote() {
|
||||
}
|
||||
|
||||
public BungeeVote(Main plugin) {
|
||||
BungeeVote.plugin = plugin;
|
||||
}
|
||||
|
||||
public void sendVote(Vote vote) throws NoSuchAlgorithmException,
|
||||
InvalidKeySpecException {
|
||||
if (ConfigBungeeVoting.getInstance().getEnabled()) {
|
||||
for (String server : ConfigBungeeVoting.getInstance().getServers()) {
|
||||
byte[] encodedPublicKey = DatatypeConverter
|
||||
.parseBase64Binary(ConfigBungeeVoting.getInstance()
|
||||
.getServerKey(server));
|
||||
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
|
||||
X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(
|
||||
encodedPublicKey);
|
||||
PublicKey publicKey = keyFactory.generatePublic(publicKeySpec);
|
||||
String serverIP = ConfigBungeeVoting.getInstance().getServerIP(
|
||||
server);
|
||||
int serverPort = ConfigBungeeVoting.getInstance()
|
||||
.getServerPort(server);
|
||||
String serviceSite = ConfigBungeeVoting.getInstance()
|
||||
.getServerServiceSite(serverIP);
|
||||
if (serverIP.length() != 0) {
|
||||
try {
|
||||
if (serviceSite != null) {
|
||||
if (serviceSite.length() > 0) {
|
||||
vote.setServiceName(serviceSite);
|
||||
}
|
||||
}
|
||||
String VoteString = "VOTE\n" + vote.getServiceName()
|
||||
+ "\n" + vote.getUsername() + "\n"
|
||||
+ vote.getAddress() + "\n"
|
||||
+ vote.getTimeStamp() + "\n";
|
||||
|
||||
SocketAddress sockAddr = new InetSocketAddress(
|
||||
serverIP, serverPort);
|
||||
Socket socket = new Socket();
|
||||
socket.connect(sockAddr, 1000);
|
||||
OutputStream socketOutputStream = socket
|
||||
.getOutputStream();
|
||||
socketOutputStream.write(RSA.encrypt(
|
||||
VoteString.getBytes(), publicKey));
|
||||
socketOutputStream.close();
|
||||
socket.close();
|
||||
|
||||
plugin.debug("Sending vote to " + server + "("
|
||||
+ sockAddr.toString() + "): " + vote.toString());
|
||||
|
||||
} catch (Exception e) {
|
||||
plugin.getLogger().info(
|
||||
"Failed to send vote to " + server + "("
|
||||
+ serverIP + ":" + serverPort + "): "
|
||||
+ vote.toString()
|
||||
+ ", ignore this if server is offline");
|
||||
if (Config.getInstance().getDebugEnabled()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,756 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Executers.CommandAdminVote;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Executers.CommandAliases;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Executers.CommandVote;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.TabCompleter.AliasesTabCompleter;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Report.Report;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
|
||||
public class CommandLoader {
|
||||
|
||||
static ConfigOtherRewards otherReward = ConfigOtherRewards.getInstance();
|
||||
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static CommandLoader instance = new CommandLoader();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static CommandLoader getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private HashMap<String, CommandHandler> commands;
|
||||
|
||||
private CommandLoader() {
|
||||
}
|
||||
|
||||
public CommandLoader(Main plugin) {
|
||||
CommandLoader.plugin = plugin;
|
||||
}
|
||||
|
||||
public HashMap<String, CommandHandler> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
|
||||
private void loadAdminVoteCommand() {
|
||||
plugin.adminVoteCommand = new ArrayList<CommandHandler>();
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"TriggerPlayerVoteEvent", "(player)", "(sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.TriggerPlayerVoteEvent",
|
||||
"Trigger vote event, used for testing") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin
|
||||
.getVoteSite(args[2]), new User(args[1]));
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
}
|
||||
});
|
||||
plugin.adminVoteCommand.add(new CommandHandler(
|
||||
new String[] { "Help&?" },
|
||||
"VotingPlugin.Commands.AdminVote.Help", "See this page") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().help(sender, 1);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "Help&?",
|
||||
"(number)" }, "VotingPlugin.Commands.AdminVote.Help",
|
||||
"See this page") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().help(sender,
|
||||
Integer.parseInt(args[1]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(
|
||||
new String[] { "Report" },
|
||||
"VotingPlugin.Commands.AdminVote.Report",
|
||||
"Create a zip file to send for debuging") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Report.getInstance().create();
|
||||
sender.sendMessage("Created Zip File!");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(
|
||||
new String[] { "Perms" },
|
||||
"VotingPlugin.Commands.AdminVote.Perms", "List perms") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().permList(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(
|
||||
new String[] { "Reload" },
|
||||
"VotingPlugin.Commands.AdminVote.Reload", "Reload plugin") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().reload(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand
|
||||
.add(new CommandHandler(new String[] { "Version" },
|
||||
"VotingPlugin.Commands.AdminVote.Version",
|
||||
"List version info") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().version(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(
|
||||
new String[] { "Sites" },
|
||||
"VotingPlugin.Commands.AdminVote.Sites", "List VoteSites") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().sites(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "Sites",
|
||||
"(sitename)" }, "VotingPlugin.Commands.AdminVote.Sites.Site",
|
||||
"View Site Info") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().site(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(
|
||||
new String[] { "Rewards" },
|
||||
"VotingPlugin.Commands.AdminVote.Rewards", "List VoteSites") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().rewards(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"Rewards", "(reward)" },
|
||||
"VotingPlugin.Commands.AdminVote.Rewards.Reward",
|
||||
"View Site Info") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().reward(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "UUID",
|
||||
"(player)" }, "VotingPlugin.Commands.AdminVote.UUID",
|
||||
"View UUID of player") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().uuid(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "Reset",
|
||||
"Totals" }, "VotingPlugin.Commands.AdminVote.Reset.Total",
|
||||
"Reset totals for all players") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().resetTotals(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "Reset",
|
||||
"Totals", "(player)" },
|
||||
"VotingPlugin.Commands.AdminVote.Reset.Total.Player",
|
||||
"Reset total for player") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().resetPlayerTotals(sender,
|
||||
args[2]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "Vote",
|
||||
"(player)", "(sitename)" },
|
||||
"VotingPlugin.Commands.AdminVote.Vote", "Trigger manual vote") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().Vote(sender, args[1], args[2]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"VoteSite", "(sitename)", "Create" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit",
|
||||
"Create VoteSite") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().createVoteSite(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] { "Config",
|
||||
"SetDebug", "(boolean)" },
|
||||
"VotingPlugin.Commands.AdminVote.Config.Edit",
|
||||
"Set Debug on or off") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().setConfigDebug(sender,
|
||||
Boolean.parseBoolean(args[2]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"ServerData", "SetPrevMonth", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.ServerDta.Edit",
|
||||
"Edit PrevMonth, ADVANCED USERS ONLY") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandAdminVote.getInstance().setServerDataPrevMonth(sender,
|
||||
Integer.parseInt(args[2]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"SetTotal", "(player)", "(sitename)", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.Set.Total",
|
||||
"Set Total votes of player") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandAdminVote.getInstance().setTotal(sender, args[1],
|
||||
args[2], Integer.parseInt(args[3]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"VoteSite", "(sitename)", "SetServiceSite", "(string)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit",
|
||||
"Set VoteSite SerivceSite") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().setVoteSiteServiceSite(sender,
|
||||
args[1], args[3]);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"VoteSite", "(sitename)", "SetVoteURL", "(string)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit",
|
||||
"Set VoteSite VoteURL") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandAdminVote.getInstance().setVoteSiteVoteURL(sender,
|
||||
args[1], args[3]);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"VoteSite", "(sitename)", "SetPriority", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit",
|
||||
"Set VoteSite Priority") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandAdminVote.getInstance().setVoteSitePriority(sender,
|
||||
args[1], Integer.parseInt(args[3]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"VoteSite", "(sitename)", "SetVoteDelay", "(number)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit",
|
||||
"Set VoteSite VoteDelay") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandAdminVote.getInstance().setVoteSiteVoteDelay(sender,
|
||||
args[1], Integer.parseInt(args[3]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(
|
||||
new String[] { "UpdateCheck" },
|
||||
"VotingPlugin.Commands.AdminVote.UpdateCheck",
|
||||
"Check for update") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,
|
||||
new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(Utils.getInstance()
|
||||
.colorize("&cChecking for update..."));
|
||||
CommandAdminVote.getInstance().checkUpdate(
|
||||
sender);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"VoteSite", "(sitename)", "SetEnabled", "(boolean)" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Edit",
|
||||
"Set VoteSite Enabled") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandAdminVote.getInstance().setVoteSiteEnabled(sender,
|
||||
args[1], Boolean.parseBoolean(args[3]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.adminVoteCommand.add(new CommandHandler(new String[] {
|
||||
"VoteSite", "(sitename)", "Check" },
|
||||
"VotingPlugin.Commands.AdminVote.VoteSite.Check",
|
||||
"Check to see if VoteSite is valid") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandAdminVote.getInstance().checkVoteSite(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void loadAliases() {
|
||||
commands = new HashMap<String, CommandHandler>();
|
||||
for (CommandHandler cmdHandle : plugin.voteCommand) {
|
||||
if (cmdHandle.getArgs().length > 0) {
|
||||
String[] args = cmdHandle.getArgs()[0].split("&");
|
||||
for (String arg : args) {
|
||||
try {
|
||||
plugin.getCommand("vote" + arg).setExecutor(
|
||||
new CommandAliases(cmdHandle));
|
||||
|
||||
plugin.getCommand("vote" + arg).setTabCompleter(
|
||||
new AliasesTabCompleter()
|
||||
.setCMDHandle(cmdHandle));
|
||||
} catch (Exception ex) {
|
||||
plugin.debug("Failed to load command and tab completer for /vote"
|
||||
+ arg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : plugin.adminVoteCommand) {
|
||||
if (cmdHandle.getArgs().length > 0) {
|
||||
String[] args = cmdHandle.getArgs()[0].split("&");
|
||||
for (String arg : args) {
|
||||
try {
|
||||
plugin.getCommand("adminvote" + arg).setExecutor(
|
||||
new CommandAliases(cmdHandle));
|
||||
|
||||
plugin.getCommand("adminvote" + arg).setTabCompleter(
|
||||
new AliasesTabCompleter()
|
||||
.setCMDHandle(cmdHandle));
|
||||
} catch (Exception ex) {
|
||||
plugin.debug("Failed to load command and tab completer for /adminvote"
|
||||
+ arg);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadCommands() {
|
||||
loadAdminVoteCommand();
|
||||
loadVoteCommand();
|
||||
}
|
||||
|
||||
private void loadVoteCommand() {
|
||||
plugin.voteCommand = new ArrayList<CommandHandler>();
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Help&?" },
|
||||
"VotingPlugin.Commands.Vote.Help", "View this page") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().help(sender);
|
||||
|
||||
}
|
||||
});
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "URL" },
|
||||
"VotingPlugin.Commands.Vote.URL", "Open VoteURL GUI") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().voteURL(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Reward" },
|
||||
"VotingPlugin.Commands.Vote.Reward", "Open VoteReward GUI") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().voteReward(sender, "");
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Reward",
|
||||
"(SiteName)" }, "VotingPlugin.Commands.Vote.Reward",
|
||||
"Open VoteURL GUI for VoteSIte") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().voteReward(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Info" },
|
||||
"VotingPlugin.Commands.Vote.Info", "See player info") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().infoSelf(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Info",
|
||||
"(player)" }, "VotingPlugin.Commands.Vote.Info.Other",
|
||||
"See other players info") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().infoOther(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Last",
|
||||
"(player)" }, "VotingPlugin.Commands.Vote.Last.Other",
|
||||
"See other players last votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().lastOther(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Last" },
|
||||
"VotingPlugin.Commands.Vote.Last", "See your last votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().lastSelf(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Next",
|
||||
"(player)" }, "VotingPlugin.Commands.Vote.Next.Other",
|
||||
"See other players next votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().nextOther(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Points",
|
||||
"(player)" }, "VotingPlugin.Commands.Vote.Points.Other",
|
||||
"View pints of other player") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance()
|
||||
.pointsOther(sender, new User(args[1]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Points", },
|
||||
"VotingPlugin.Commands.Vote.Points", "View your points") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
CommandVote.getInstance().pointsSelf(
|
||||
new User((Player) sender));
|
||||
} else {
|
||||
sender.sendMessage("Must be a player to use this!");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Next" },
|
||||
"VotingPlugin.Commands.Vote.Next", "See your next votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().nextSelf(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "GUI" },
|
||||
"VotingPlugin.Commands.Vote.GUI", "Open VoteGUI") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
CommandVote.getInstance().voteGUI(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Top" },
|
||||
"VotingPlugin.Commands.Vote.Top", "Open list of Top Voters") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().topVoterMonthly(sender, 1);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Top",
|
||||
"(number)" }, "VotingPlugin.Commands.Vote.Top",
|
||||
"Open page of Top Voters") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (Utils.getInstance().isInt(args[1])) {
|
||||
CommandVote.getInstance().topVoterMonthly(sender,
|
||||
Integer.parseInt(args[1]));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cError on " + args[1] + ", number expected"));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Top",
|
||||
"(number)", "Monthly" },
|
||||
"VotingPlugin.Commands.Vote.Top.Monthly",
|
||||
"Open page of Top Voters") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (Utils.getInstance().isInt(args[1])) {
|
||||
CommandVote.getInstance().topVoterMonthly(sender,
|
||||
Integer.parseInt(args[1]));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cError on " + args[1] + ", number expected"));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Top",
|
||||
"(number)", "Weekly" },
|
||||
"VotingPlugin.Commands.Vote.Top.Weekly",
|
||||
"Open page of Top Voters") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (Utils.getInstance().isInt(args[1])) {
|
||||
CommandVote.getInstance().topVoterWeekly(sender,
|
||||
Integer.parseInt(args[1]));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cError on " + args[1] + ", number expected"));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Top",
|
||||
"(number)", "Daily" }, "VotingPlugin.Commands.Vote.Top.Daily",
|
||||
"Open page of Top Voters") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (Utils.getInstance().isInt(args[1])) {
|
||||
CommandVote.getInstance().topVoterDaily(sender,
|
||||
Integer.parseInt(args[1]));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cError on " + args[1] + ", number expected"));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Party" },
|
||||
"VotingPlugin.Commands.Vote.Party",
|
||||
"View current amount of votes and how many more needed") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
VoteParty.getInstance().commandVoteParty(sender);
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Today",
|
||||
"(number)" }, "VotingPlugin.Commands.Vote.Today",
|
||||
"Open page of who Voted Today") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().today(sender,
|
||||
Integer.parseInt(args[1]));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Today" },
|
||||
"VotingPlugin.Commands.Vote.Today",
|
||||
"View who list of who voted today") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().today(sender, 1);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(
|
||||
new String[] { "Total", "All" },
|
||||
"VotingPlugin.Commands.Vote.Total.All",
|
||||
"View server total votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().totalAll(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Total",
|
||||
"(player)" }, "VotingPlugin.Commands.Vote.Total.Other",
|
||||
"View other players total votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().totalOther(sender, args[1]);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] { "Total" },
|
||||
"VotingPlugin.Commands.Vote.Total", "View your total votes") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
CommandVote.getInstance().totalSelf(sender);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
plugin.voteCommand.add(new CommandHandler(new String[] {}, "",
|
||||
"See voting URLs") {
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if (!Config.getInstance().getVoteURLDefault()) {
|
||||
CommandVote.getInstance().voteURLs(sender);
|
||||
} else {
|
||||
CommandVote.getInstance().voteURL(sender);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void setCommands(HashMap<String, CommandHandler> commands) {
|
||||
this.commands = commands;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
-359
@@ -1,359 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.Executers;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Bungee.BungeeVote;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.Updater.Updater;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
|
||||
public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
private static CommandAdminVote instance = new CommandAdminVote();
|
||||
|
||||
public static CommandAdminVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
ConfigOtherRewards bonusReward = ConfigOtherRewards.getInstance();
|
||||
|
||||
Config config = Config.getInstance();
|
||||
|
||||
ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
ConfigVoteSites voteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
private CommandAdminVote() {
|
||||
}
|
||||
|
||||
public CommandAdminVote(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void checkUpdate(CommandSender sender) {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case FAIL_SPIGOT: {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cFailed to check for update for &c&l" + plugin.getName()
|
||||
+ "&c!"));
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&c&l" + plugin.getName()
|
||||
+ " &cis up to date! Version: &c&l"
|
||||
+ plugin.updater.getVersion()));
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&c&l" + plugin.getName()
|
||||
+ " &chas an update available! Your Version: &c&l"
|
||||
+ plugin.getDescription().getVersion()
|
||||
+ " &cNew Version: &c&l"
|
||||
+ plugin.updater.getVersion()));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkVoteSite(CommandSender sender, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().isServiceSiteGood(siteName)) {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cServiceSite is invalid, votes may not work properly"));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&aServiceSite is properly setup"));
|
||||
}
|
||||
if (!ConfigVoteSites.getInstance().isVoteURLGood(siteName)) {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cVoteURL is invalid"));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&aVoteURL is properly setup"));
|
||||
}
|
||||
}
|
||||
|
||||
public void createVoteSite(CommandSender sender, String voteSite) {
|
||||
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cCreating VoteSite..."));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSite);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cCreated VoteSite: &c&l" + voteSite));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void help(CommandSender sender, int page) {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendJson(Commands.getInstance().adminHelp(sender, page - 1));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance()
|
||||
.convertArray(
|
||||
Utils.getInstance().comptoString(
|
||||
Commands.getInstance().adminHelp(sender,
|
||||
page - 1))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public void permList(CommandSender sender) {
|
||||
|
||||
sender.sendMessage(Commands.getInstance().listPerms());
|
||||
|
||||
}
|
||||
|
||||
public void reload(CommandSender sender) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(ChatColor.RED + "Reloading "
|
||||
+ plugin.getName() + "...");
|
||||
plugin.reload();
|
||||
sender.sendMessage(ChatColor.RED + plugin.getName() + " v"
|
||||
+ plugin.getDescription().getVersion() + " reloaded!");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void resetPlayerTotals(CommandSender sender, String playerName) {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cResseting totals for player &c&l" + playerName));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
TopVoter.getInstance().resetTotalsPlayer(new User(playerName));
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cDone resseting totals for &c&l" + playerName));
|
||||
plugin.update();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void resetTotals(CommandSender sender) {
|
||||
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cResseting totals for all players..."));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
TopVoter.getInstance().resetTotalsMonthly();
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cDone resseting totals"));
|
||||
plugin.update();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void reward(CommandSender sender, String reward) {
|
||||
|
||||
sender.sendMessage(Commands.getInstance().voteCommandRewardInfo(reward));
|
||||
|
||||
}
|
||||
|
||||
public void rewards(CommandSender sender) {
|
||||
|
||||
sender.sendMessage(Commands.getInstance().voteCommandRewards());
|
||||
|
||||
}
|
||||
|
||||
public void setConfigAllowUnjoined(CommandSender sender, boolean value) {
|
||||
|
||||
Config.getInstance().setAllowUnJoined(value);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet AllowUnjoined to &c&l" + value));
|
||||
|
||||
}
|
||||
|
||||
public void setConfigBroadcastVote(CommandSender sender, boolean value) {
|
||||
|
||||
Config.getInstance().setDebugEnabled(value);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet BroadcastVote to &c&l" + value));
|
||||
|
||||
}
|
||||
|
||||
public void setConfigDebug(CommandSender sender, boolean value) {
|
||||
|
||||
Config.getInstance().setDebugEnabled(value);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet Debug to &c&l" + value));
|
||||
|
||||
}
|
||||
|
||||
public void setConfigEnableTopVoterAwards(CommandSender sender,
|
||||
boolean value) {
|
||||
|
||||
Config.getInstance().setTopVoterAwardsEnabled(value);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet DisableTopVoterAwards to &c&l" + value));
|
||||
|
||||
}
|
||||
|
||||
public void setServerDataPrevMonth(CommandSender sender, int month) {
|
||||
|
||||
ServerData.getInstance().setPrevMonth(month);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet PreMonth to &c&l" + month));
|
||||
|
||||
}
|
||||
|
||||
public void setTotal(CommandSender sender, String playerName,
|
||||
String voteSite, int amount) {
|
||||
|
||||
Data.getInstance().setTotal(new User(playerName), voteSite, amount);
|
||||
sender.sendMessage(ChatColor.GREEN + playerName + " total votes for "
|
||||
+ voteSite + " has been set to " + amount);
|
||||
plugin.update();
|
||||
|
||||
}
|
||||
|
||||
public void setVoteSiteEnabled(CommandSender sender, String voteSite,
|
||||
boolean value) {
|
||||
ConfigVoteSites.getInstance().setEnabled(voteSite, value);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet votesite " + voteSite + " enabled to " + value));
|
||||
}
|
||||
|
||||
public void setVoteSitePriority(CommandSender sender, String voteSite,
|
||||
int value) {
|
||||
|
||||
ConfigVoteSites.getInstance().setPriority(voteSite, value);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet priortiy to &c&l" + value + "&c on &c&l" + voteSite));
|
||||
|
||||
}
|
||||
|
||||
public void setVoteSiteServiceSite(CommandSender sender, String voteSite,
|
||||
String serviceSite) {
|
||||
|
||||
ConfigVoteSites.getInstance().setServiceSite(voteSite, serviceSite);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet ServiceSite to &c&l" + serviceSite + "&c on &c&l"
|
||||
+ voteSite));
|
||||
|
||||
}
|
||||
|
||||
public void setVoteSiteVoteDelay(CommandSender sender, String voteSite,
|
||||
int delay) {
|
||||
|
||||
ConfigVoteSites.getInstance().setVoteDelay(voteSite, delay);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet VoteDelay to &c&l" + delay + "&c on &c&l" + voteSite));
|
||||
|
||||
}
|
||||
|
||||
public void setVoteSiteVoteURL(CommandSender sender, String voteSite,
|
||||
String url) {
|
||||
|
||||
ConfigVoteSites.getInstance().setVoteURL(voteSite, url);
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
"&cSet VoteURL to &c&l" + url + "&c on &c&l" + voteSite));
|
||||
|
||||
}
|
||||
|
||||
public void site(CommandSender sender, String site) {
|
||||
|
||||
sender.sendMessage(Commands.getInstance().voteCommandSiteInfo(site));
|
||||
|
||||
}
|
||||
|
||||
public void sites(CommandSender sender) {
|
||||
|
||||
sender.sendMessage(Commands.getInstance().voteCommandSites());
|
||||
|
||||
}
|
||||
|
||||
public void uuid(CommandSender sender, String playerName) {
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "UUID of player "
|
||||
+ ChatColor.DARK_GREEN + playerName + ChatColor.GREEN + " is: "
|
||||
+ Utils.getInstance().getUUID(playerName));
|
||||
|
||||
}
|
||||
|
||||
public void version(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
|
||||
Player player = (Player) sender;
|
||||
player.performCommand("bukkit:version " + plugin.getName());
|
||||
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(),
|
||||
"bukkit:version " + plugin.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void Vote(CommandSender sender, String playerName, String voteSite) {
|
||||
|
||||
VotiferEvent.playerVote(playerName, voteSite);
|
||||
|
||||
Vote vote = new com.vexsoftware.votifier.model.Vote();
|
||||
vote.setServiceName(new VoteSite(voteSite).getServiceSite());
|
||||
vote.setUsername(playerName);
|
||||
try {
|
||||
BungeeVote.getInstance().sendVote(vote);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
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.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
|
||||
public class CommandAliases implements CommandExecutor {
|
||||
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
private CommandHandler cmdHandle;
|
||||
|
||||
public CommandAliases(CommandHandler cmdHandle) {
|
||||
this.cmdHandle = cmdHandle;
|
||||
}
|
||||
|
||||
@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: "
|
||||
+ Utils.getInstance().makeStringList(argsNew));
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
cmdHandlers.addAll(plugin.adminVoteCommand);
|
||||
for (CommandHandler cmdHandle : cmdHandlers) {
|
||||
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, Utils
|
||||
.getInstance().convertArray(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
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "No valid arguments, see /vote help!");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,358 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.Executers;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
public class CommandVote implements CommandExecutor {
|
||||
|
||||
private static CommandVote instance = new CommandVote();
|
||||
|
||||
private static Main plugin;
|
||||
|
||||
public static CommandVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private CommandVote() {
|
||||
}
|
||||
|
||||
public CommandVote(Main plugin) {
|
||||
CommandVote.plugin = plugin;
|
||||
}
|
||||
|
||||
public void help(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendJson(Commands.getInstance().voteHelpText(sender));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().convertArray(
|
||||
Utils.getInstance().comptoString(
|
||||
Commands.getInstance().voteHelpText(sender))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void infoOther(CommandSender sender, String playerName) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Utils.getInstance().colorize(
|
||||
"&cGetting player info..."));
|
||||
user.sendMessage(Commands.getInstance().playerInfo(
|
||||
new User(playerName)));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
Commands.getInstance().playerInfo(
|
||||
new User(playerName))));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void infoSelf(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Utils.getInstance().colorize(
|
||||
"&cGetting info..."));
|
||||
user.sendMessage(Commands.getInstance().playerInfo(
|
||||
new User(sender.getName())));
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
sender.sendMessage("You must be a player to do this!");
|
||||
}
|
||||
}
|
||||
|
||||
public void lastOther(CommandSender sender, String playerName) {
|
||||
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Commands.getInstance().voteCommandLast(
|
||||
new User(playerName)));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
Commands.getInstance()
|
||||
.voteCommandLast(new User(playerName))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void lastSelf(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Commands.getInstance().voteCommandLast(user));
|
||||
} else {
|
||||
sender.sendMessage("You must be a player to do this!");
|
||||
}
|
||||
}
|
||||
|
||||
public void nextOther(CommandSender sender, String playerName) {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Commands.getInstance().voteCommandNext(
|
||||
new User(playerName)));
|
||||
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
Commands.getInstance()
|
||||
.voteCommandNext(new User(playerName))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void nextSelf(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
String playerName = sender.getName();
|
||||
User user = new User(playerName);
|
||||
user.sendMessage(Commands.getInstance().voteCommandNext(user));
|
||||
} else {
|
||||
sender.sendMessage("You must be a player to do this!");
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
public void today(CommandSender sender, int page) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Commands.getInstance().commandVoteToday(
|
||||
page));
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Commands.getInstance().sendVoteTodayScoreBoard(
|
||||
(Player) sender, page);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sender.sendMessage(Commands.getInstance().commandVoteToday(
|
||||
page));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void pointsSelf(User user) {
|
||||
String msg = ConfigFormat.getInstance().getCommandVotePoints()
|
||||
.replace("%Player%", user.getPlayerName())
|
||||
.replace("%Points%", "" + user.getPoints());
|
||||
user.sendMessage(msg);
|
||||
}
|
||||
|
||||
public void pointsOther(CommandSender sender, User user) {
|
||||
String msg = ConfigFormat.getInstance().getCommandVotePoints()
|
||||
.replace("%Player%", user.getPlayerName())
|
||||
.replace("%Points%", "" + user.getPoints());
|
||||
if (sender instanceof Player) {
|
||||
new User(sender.getName()).sendMessage(msg);
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(msg));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void topVoterDaily(CommandSender sender, int page) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(TopVoter.getInstance().topVoterDaily(page));
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Commands.getInstance().sendTopVoterDailyScoreBoard(
|
||||
(Player) sender, page);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sender.sendMessage(TopVoter.getInstance().topVoterDaily(
|
||||
page));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void topVoterMonthly(CommandSender sender, int page) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(TopVoter.getInstance().topVoterMonthly(
|
||||
page));
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Commands.getInstance()
|
||||
.sendTopVoterMonthlyScoreBoard(
|
||||
(Player) sender, page);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sender.sendMessage(TopVoter.getInstance().topVoterMonthly(
|
||||
page));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void topVoterWeekly(CommandSender sender, int page) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(TopVoter.getInstance()
|
||||
.topVoterWeekly(page));
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Commands.getInstance()
|
||||
.sendTopVoterWeeklyScoreBoard(
|
||||
(Player) sender, page);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sender.sendMessage(TopVoter.getInstance().topVoterWeekly(
|
||||
page));
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void totalAll(CommandSender sender) {
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Commands.getInstance()
|
||||
.voteCommandTotalAll());
|
||||
|
||||
} else {
|
||||
sender.sendMessage(Commands.getInstance()
|
||||
.voteCommandTotalAll());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void totalOther(CommandSender sender, String playerName) {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Commands.getInstance().voteCommandTotal(
|
||||
new User(playerName)));
|
||||
} else {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
Commands.getInstance().voteCommandTotal(
|
||||
new User(playerName))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void totalSelf(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
String playerName = sender.getName();
|
||||
User user = new User(playerName);
|
||||
user.sendMessage(Commands.getInstance().voteCommandTotal(user));
|
||||
} else {
|
||||
sender.sendMessage("You must be a player to do this!");
|
||||
}
|
||||
}
|
||||
|
||||
public void voteGUI(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Commands.getInstance().openVoteGUI((Player) sender);
|
||||
} else {
|
||||
sender.sendMessage("Must be a player to do this!");
|
||||
}
|
||||
}
|
||||
|
||||
public void voteReward(CommandSender sender, String siteName) {
|
||||
if (sender instanceof Player) {
|
||||
Commands.getInstance().voteReward((Player) sender, siteName);
|
||||
} else {
|
||||
sender.sendMessage("Must be a player to do this!");
|
||||
}
|
||||
}
|
||||
|
||||
public void voteURL(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
Commands.getInstance().voteURL((Player) sender);
|
||||
} else {
|
||||
sender.sendMessage("Must be a player to do this!");
|
||||
}
|
||||
}
|
||||
|
||||
public void voteURLs(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
User user = new User((Player) sender);
|
||||
user.sendMessage(Commands.getInstance().voteURLs());
|
||||
} else {
|
||||
sender.sendMessage(Commands.getInstance().voteURLs());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
|
||||
public class AdminVoteTabCompleter implements TabCompleter {
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
public ArrayList<String> getAdminTabCompleteOptions(CommandSender sender,
|
||||
String[] args, int argNum) {
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
for (CommandHandler commandHandler : plugin.adminVoteCommand) {
|
||||
if (sender.hasPermission(commandHandler.getPerm())) {
|
||||
String[] cmdArgs = commandHandler.getArgs();
|
||||
if (cmdArgs.length > argNum) {
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argNum; i++) {
|
||||
if (args.length >= i) {
|
||||
if (!commandHandler.argsMatch(args[i], i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
String[] cmdArgsList = cmdArgs[argNum].split("&");
|
||||
for (String arg : cmdArgsList) {
|
||||
if (arg.equalsIgnoreCase("(player)")) {
|
||||
for (Object playerOb : Bukkit
|
||||
.getOnlinePlayers().toArray()) {
|
||||
Player player = (Player) playerOb;
|
||||
if (!cmds.contains(player.getName())) {
|
||||
cmds.add(player.getName());
|
||||
}
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(sitename)")) {
|
||||
for (String siteName : ConfigVoteSites
|
||||
.getInstance().getVoteSitesNames()) {
|
||||
if (!cmds.contains(siteName)) {
|
||||
cmds.add(siteName);
|
||||
}
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(reward0")) {
|
||||
for (String reward : ConfigRewards
|
||||
.getInstance().getRewardNames()) {
|
||||
if (!cmds.contains(reward)) {
|
||||
cmds.add(reward);
|
||||
}
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(boolean)")) {
|
||||
if (!cmds.contains("True")) {
|
||||
cmds.add("True");
|
||||
}
|
||||
if (!cmds.contains("False")) {
|
||||
cmds.add("False");
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(number)")) {
|
||||
|
||||
} else if (!cmds.contains(arg)) {
|
||||
cmds.add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(cmds, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return cmds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd,
|
||||
String alias, String[] args) {
|
||||
|
||||
if (cmd.getName().equalsIgnoreCase("adminvote")
|
||||
|| cmd.getName().equalsIgnoreCase("av")) {
|
||||
|
||||
List<String> tab = new ArrayList<String>();
|
||||
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
|
||||
cmds.addAll(getAdminTabCompleteOptions(sender, args,
|
||||
args.length - 1));
|
||||
|
||||
for (int i = 0; i < cmds.size(); i++) {
|
||||
if (Utils.getInstance().startsWithIgnoreCase(cmds.get(i),
|
||||
args[args.length - 1])) {
|
||||
tab.add(cmds.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
-145
@@ -1,145 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
|
||||
public class AliasesTabCompleter implements TabCompleter {
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
public CommandHandler cmdHandle;
|
||||
|
||||
public ArrayList<String> getTabCompleteOptions(CommandSender sender,
|
||||
String[] args, int argNum, CommandHandler cmdHandle) {
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
if (sender.hasPermission(cmdHandle.getPerm())) {
|
||||
String[] cmdArgs = cmdHandle.getArgs();
|
||||
if (cmdArgs.length > argNum) {
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argNum; i++) {
|
||||
if (args.length >= i) {
|
||||
if (!cmdHandle.argsMatch(args[i], i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
if (cmdArgs[argNum].equalsIgnoreCase("(player)")) {
|
||||
for (Object playerOb : Bukkit.getOnlinePlayers()
|
||||
.toArray()) {
|
||||
Player player = (Player) playerOb;
|
||||
if (!cmds.contains(player.getName())) {
|
||||
cmds.add(player.getName());
|
||||
}
|
||||
}
|
||||
} else if (cmdArgs[argNum].equalsIgnoreCase("(reward)")) {
|
||||
for (String reward : ConfigRewards.getInstance()
|
||||
.getRewardNames()) {
|
||||
if (!cmds.contains(reward)) {
|
||||
cmds.add(reward);
|
||||
}
|
||||
}
|
||||
} else if (cmdArgs[argNum].equalsIgnoreCase("(sitename)")) {
|
||||
for (String siteName : ConfigVoteSites.getInstance()
|
||||
.getVoteSitesNames()) {
|
||||
if (!cmds.contains(siteName)) {
|
||||
cmds.add(siteName);
|
||||
}
|
||||
}
|
||||
} else if (cmdArgs[argNum].equalsIgnoreCase("(boolean)")) {
|
||||
if (!cmds.contains("True")) {
|
||||
cmds.add("True");
|
||||
}
|
||||
if (!cmds.contains("False")) {
|
||||
cmds.add("False");
|
||||
}
|
||||
} else if (cmdArgs[argNum].equalsIgnoreCase("(number)")) {
|
||||
|
||||
} else if (!cmds.contains(cmdArgs[argNum])) {
|
||||
cmds.add(cmdArgs[argNum]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(cmds, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return cmds;
|
||||
}
|
||||
|
||||
@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 = Utils.getInstance().convertArray(msgArray);
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
cmdHandlers.addAll(plugin.adminVoteCommand);
|
||||
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(getTabCompleteOptions(sender, args,
|
||||
argsIn.length, cmdHandle));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < cmds.size(); i++) {
|
||||
if (Utils.getInstance().startsWithIgnoreCase(cmds.get(i),
|
||||
args[argsIn.length])) {
|
||||
tab.add(cmds.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd) {
|
||||
cmdHandle = cmd;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
|
||||
public class VoteTabCompleter implements TabCompleter {
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
public ArrayList<String> getTabCompleteOptions(CommandSender sender,
|
||||
String[] args, int argNum) {
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
for (CommandHandler commandHandler : plugin.voteCommand) {
|
||||
|
||||
if (sender.hasPermission(commandHandler.getPerm())) {
|
||||
String[] cmdArgs = commandHandler.getArgs();
|
||||
if (cmdArgs.length > argNum) {
|
||||
boolean argsMatch = true;
|
||||
for (int i = 0; i < argNum; i++) {
|
||||
if (args.length >= i) {
|
||||
if (!commandHandler.argsMatch(args[i], i)) {
|
||||
argsMatch = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
String[] cmdArgsList = cmdArgs[argNum].split("&");
|
||||
for (String arg : cmdArgsList) {
|
||||
if (arg.equalsIgnoreCase("(player)")) {
|
||||
for (Object playerOb : Bukkit
|
||||
.getOnlinePlayers().toArray()) {
|
||||
Player player = (Player) playerOb;
|
||||
if (!cmds.contains(player.getName())) {
|
||||
cmds.add(player.getName());
|
||||
}
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(sitename)")) {
|
||||
for (String siteName : ConfigVoteSites
|
||||
.getInstance().getVoteSitesNames()) {
|
||||
if (!cmds.contains(siteName)) {
|
||||
cmds.add(siteName);
|
||||
}
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(reward)")) {
|
||||
for (String reward : ConfigRewards
|
||||
.getInstance().getRewardNames()) {
|
||||
if (!cmds.contains(reward)) {
|
||||
cmds.add(reward);
|
||||
}
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(boolean)")) {
|
||||
if (!cmds.contains("True")) {
|
||||
cmds.add("True");
|
||||
}
|
||||
if (!cmds.contains("False")) {
|
||||
cmds.add("False");
|
||||
}
|
||||
} else if (arg.equalsIgnoreCase("(number)")) {
|
||||
|
||||
} else if (!cmds.contains(arg)) {
|
||||
cmds.add(arg);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(cmds, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return cmds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd,
|
||||
String alias, String[] args) {
|
||||
|
||||
if (cmd.getName().equalsIgnoreCase("vote")
|
||||
|| cmd.getName().equalsIgnoreCase("v")) {
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
|
||||
cmds.addAll(getTabCompleteOptions(sender, args, args.length - 1));
|
||||
|
||||
for (int i = 0; i < cmds.size(); i++) {
|
||||
if (Utils.getInstance().startsWithIgnoreCase(cmds.get(i),
|
||||
args[args.length - 1])) {
|
||||
tab.add(cmds.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return tab;
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,180 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class Config {
|
||||
|
||||
static Config instance = new Config();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static Config getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private Config() {
|
||||
}
|
||||
|
||||
public Config(Main plugin) {
|
||||
Config.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean allowUnJoined() {
|
||||
return getData().getBoolean("AllowUnjoined");
|
||||
}
|
||||
|
||||
public boolean getAutoCreateVoteSites() {
|
||||
return getData().getBoolean("AutoCreateVoteSites");
|
||||
}
|
||||
|
||||
public int getBackgroundTaskDelay() {
|
||||
int num = getData().getInt("BackgroundTaskDelay");
|
||||
if (num == 0) {
|
||||
num = 600;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public boolean getBroadCastVotesEnabled() {
|
||||
return getData().getBoolean("BroadcastVote");
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean getDebugEnabled() {
|
||||
return getData().getBoolean("Debug");
|
||||
}
|
||||
|
||||
public int getEffectData() {
|
||||
return getData().getInt("Effect.Data");
|
||||
}
|
||||
|
||||
public String getEffectEffect() {
|
||||
return getData().getString("Effect.Effect");
|
||||
}
|
||||
|
||||
public boolean getEffectEnabled() {
|
||||
return getData().getBoolean("Effect.Enabled");
|
||||
}
|
||||
|
||||
public int getEffectParticles() {
|
||||
return getData().getInt("Effect.Particles");
|
||||
}
|
||||
|
||||
public int getEffectRadius() {
|
||||
return getData().getInt("Effect.Radius");
|
||||
}
|
||||
|
||||
public boolean getSendScoreboards() {
|
||||
return getData().getBoolean("SendScoreboards");
|
||||
}
|
||||
|
||||
public boolean getSoundEnabled() {
|
||||
return getData().getBoolean("Sound.Enabled");
|
||||
}
|
||||
|
||||
public float getSoundPitch() {
|
||||
return (float) getData().getDouble("Sound.Pitch");
|
||||
}
|
||||
|
||||
public String getSoundSound() {
|
||||
return getData().getString("Sound.Sound");
|
||||
}
|
||||
|
||||
public float getSoundVolume() {
|
||||
return (float) getData().getDouble("Sound.Volume");
|
||||
}
|
||||
|
||||
public boolean getTitleEnabled() {
|
||||
return getData().getBoolean("Title.Enabled");
|
||||
}
|
||||
|
||||
public int getTitleFadeIn() {
|
||||
return getData().getInt("Title.FadeIn");
|
||||
}
|
||||
|
||||
public int getTitleFadeOut() {
|
||||
return getData().getInt("Title.FadeOut");
|
||||
}
|
||||
|
||||
public int getTitleShowTime() {
|
||||
return getData().getInt("Title.ShowTime");
|
||||
}
|
||||
|
||||
public String getTitleSubTitle() {
|
||||
return getData().getString("Title.SubTitle");
|
||||
}
|
||||
|
||||
public String getTitleTitle() {
|
||||
return getData().getString("Title.Title");
|
||||
}
|
||||
|
||||
public boolean getVoteURLDefault() {
|
||||
return getData().getBoolean("VoteURLDefault");
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setAllowUnJoined(boolean value) {
|
||||
getData().set("AllowUnjoined", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setBroadcastVoteEnabled(boolean value) {
|
||||
getData().set("BroadcastVote", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setDebugEnabled(boolean value) {
|
||||
getData().set("Debug", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setTopVoterAwardsEnabled(boolean value) {
|
||||
getData().set("TopVoterAwards", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "Config.yml");
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
plugin.saveResource("Config.yml", true);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer().getLogger()
|
||||
.severe(ChatColor.RED + "Could not create Config.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class ConfigBungeeVoting {
|
||||
|
||||
static ConfigBungeeVoting instance = new ConfigBungeeVoting();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigBungeeVoting getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private ConfigBungeeVoting() {
|
||||
}
|
||||
|
||||
public ConfigBungeeVoting(Main plugin) {
|
||||
ConfigBungeeVoting.plugin = plugin;
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return getData().getBoolean("Enabled");
|
||||
}
|
||||
|
||||
public String getServerIP(String server) {
|
||||
return getData().getString("Servers." + server + ".IP");
|
||||
}
|
||||
|
||||
public String getServerKey(String server) {
|
||||
return getData().getString("Servers." + server + ".Key");
|
||||
}
|
||||
|
||||
public int getServerPort(String server) {
|
||||
return getData().getInt("Servers." + server + ".Port");
|
||||
}
|
||||
|
||||
public Set<String> getServers() {
|
||||
return getData().getConfigurationSection("Servers").getKeys(false);
|
||||
}
|
||||
|
||||
public String getServerServiceSite(String server) {
|
||||
return getData().getString("Servers." + server + ".ServiceSite");
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "BungeeVoting.yml");
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
plugin.saveResource("BungeeVoting.yml", true);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED
|
||||
+ "Could not create BungeeVoting.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,419 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class ConfigFormat {
|
||||
|
||||
static ConfigFormat instance = new ConfigFormat();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigFormat getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private ConfigFormat() {
|
||||
}
|
||||
|
||||
public ConfigFormat(Main plugin) {
|
||||
ConfigFormat.plugin = plugin;
|
||||
}
|
||||
|
||||
public String getBroadCastMsg() {
|
||||
String str = getData().getString("Format.BroadcastMsg");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandVotePoints() {
|
||||
String str = getData().getString("Format.Commands.Vote.Points");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&a%Player% currently has &a&l%Points%&a Points!";
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getBroadcastWhenOnline() {
|
||||
return getData().getBoolean("Format.BroadcastWhenOnline");
|
||||
}
|
||||
|
||||
public String getCommandsVoteHelpLine() {
|
||||
|
||||
String str = getData().getString("Format.Commands.Vote.Help.Line");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3&l%Command% - &3%HelpMessage%";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean getCommandsVoteHelpRequirePermission() {
|
||||
return getData().getBoolean(
|
||||
"Format.Commands.Vote.Help.RequirePermission");
|
||||
}
|
||||
|
||||
public String getCommandsVoteHelpTitle() {
|
||||
String str = getData().getString("Format.Commands.Vote.Help.Title");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "Voting Player Help";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getCommandsVoteLastLine() {
|
||||
String str = getData().getString("Format.Commands.Vote.Last.Line");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3%SiteName%: &6%time%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteLastTitle() {
|
||||
String str = getData().getString("Format.Commands.Vote.Last.Title");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3&l%player% Last Vote Times:";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteNextInfoCanVote() {
|
||||
String str = getData().getString(
|
||||
"Format.Commands.Vote.Next.Info.CanVote");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "Go Vote!";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteNextInfoError() {
|
||||
String str = getData()
|
||||
.getString("Format.Commands.Vote.Next.Info.Error");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteNextInfoTime() {
|
||||
String str = getData().getString(
|
||||
"Format.Commands.Vote.Next.Info.TimeUntilVote");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&cCould not caculate time until next vote!";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteNextLayout() {
|
||||
String str = getData().getString("Format.Commands.Vote.Next.Layout");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3%SiteName%: &6%info%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteNextTitle() {
|
||||
String str = getData().getString("Format.Commands.Vote.Next.Title");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3&l%player% Next Votes:";
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getCommandsVoteParty() {
|
||||
try {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList(
|
||||
"Format.Commands.Vote.Party");
|
||||
if (list != null) {
|
||||
return list;
|
||||
}
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return msg;
|
||||
} catch (Exception ex) {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
msg.add("&cCurrently at &6%Votes%&c, &6%NeededVotes% &cmore votes to go to reach &6%VotesRequired%");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getCommandsVoteTitle() {
|
||||
List<String> str;
|
||||
try {
|
||||
str = (List<String>) getData()
|
||||
.getList("Format.Commands.Vote.Title");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
str = new ArrayList<String>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return str;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
str = new ArrayList<String>();
|
||||
str.add("&4&lVote for our server!");
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteTotalAllLine() {
|
||||
String str = getData().getString("Format.Commands.Vote.TotalAll.Line");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3%SiteName% &6%Total%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteTotalAllTitle() {
|
||||
String str = getData().getString("Format.Commands.Vote.TotalAll.Title");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3&lAll Votes Total:";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteTotalAllTotal() {
|
||||
String str = getData().getString("Format.Commands.Vote.TotalAll.Total");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3&lTotal: &6&l%Totals%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteTotalLine() {
|
||||
String str = getData().getString("Format.Commands.Vote.Total.Line");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3%SiteName%: &6%Total%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteTotalTitle() {
|
||||
String str = getData().getString("Format.Commands.Vote.Total.Title");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3&l%player% Total Votes:";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteTotalTotal() {
|
||||
String str = getData().getString("Format.Commands.Vote.Total.Total");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3&lTotal: &6&l%Totals%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandsVoteURLS() {
|
||||
String str = getData().getString("Format.Commands.Vote.Sites");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&4%num%: &c&l%SiteName% - &c%url%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandVoteTopLine() {
|
||||
String str = getData().getString("Format.Commands.Vote.Top.Line");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&c%num%: &6%player%, %votes%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getCommandVoteTopTitle() {
|
||||
String str = getData().getString("Format.Commands.Vote.Top.Title");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&3Top Voters %page%/%maxpages%";
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public String getLoginMsg() {
|
||||
String str = getData().getString("Format.LoginMsg");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&cRemember to vote!";
|
||||
}
|
||||
}
|
||||
|
||||
public String getNoPerms() {
|
||||
String str = getData().getString("Format.NoPerms");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&cYou do not have enough permission!";
|
||||
}
|
||||
}
|
||||
|
||||
public String getNotNumber() {
|
||||
String str = getData().getString("Format.NotNumber");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&cError on &6%arg%&c, number expected!";
|
||||
}
|
||||
}
|
||||
|
||||
public int getPageSize() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
public String getRewardMsg() {
|
||||
String str = getData().getString("Format.DefaultRewardMsg");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&aYou were given rewards!";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSignTopVoterSignLine1() {
|
||||
String str = getData().getString("Format.Signs.TopVoterSign.Line1");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "TopVoter: %SiteName%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSignTopVoterSignLine2() {
|
||||
String str = getData().getString("Format.Signs.TopVoterSign.Line2");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "#%position%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSignTopVoterSignLine3() {
|
||||
String str = getData().getString("Format.Signs.TopVoterSign.Line3");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "%player%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSignTopVoterSignLine4() {
|
||||
String str = getData().getString("Format.Signs.TopVoterSign.Line4");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "%votes% Votes";
|
||||
}
|
||||
}
|
||||
|
||||
public String getSignTopVoterSignRightClickMessage() {
|
||||
String str = getData().getString("Format.Signs.RightClickMessage");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cin &c&l%SiteName%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getTimeFormat() {
|
||||
String string = getData().getString("Format.TimeFormat");
|
||||
if (string == null) {
|
||||
return "EEE, d MMM yyyy HH:mm";
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public String getTimeZone() {
|
||||
String str = getData().getString("Format.TimeZone");
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
return "UTC";
|
||||
}
|
||||
|
||||
public String getTopVoterRewardMsg() {
|
||||
String msg = getData().getString("Format.TopVoterAwardMsg");
|
||||
if (msg != null) {
|
||||
return msg;
|
||||
} else {
|
||||
return "&aYou came in %place% in top voters of the month! Here is an award!";
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getVoteHelp() {
|
||||
return (List<String>) getData().getList(
|
||||
"Format.Commands.Vote.Help.Lines");
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
|
||||
}
|
||||
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "Format.yml");
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
plugin.saveResource("Format.yml", true);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer().getLogger()
|
||||
.severe(ChatColor.RED + "Could not create Format.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
}
|
||||
@@ -1,356 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class ConfigGUI {
|
||||
|
||||
static ConfigGUI instance = new ConfigGUI();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigGUI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private ConfigGUI() {
|
||||
}
|
||||
|
||||
public ConfigGUI(Main plugin) {
|
||||
ConfigGUI.plugin = plugin;
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getVoteGUISlotAmount(String slot) {
|
||||
return getData().getInt("GUI.VoteGUI." + slot + ".Item.Amount");
|
||||
}
|
||||
|
||||
public String getVoteGUISlotCommand(String slot) {
|
||||
return getData().getString("GUI.VoteGUI." + slot + ".Command");
|
||||
}
|
||||
|
||||
public int getVoteGUISlotData(String slot) {
|
||||
return getData().getInt("GUI.VoteGUI." + slot + ".Item.Data");
|
||||
}
|
||||
|
||||
public int getVoteGUISlotDurability(String slot) {
|
||||
return getData().getInt("GUI.VoteGUI." + slot + ".Item.Durability");
|
||||
}
|
||||
|
||||
public String getVoteGUISlotMaterial(String slot) {
|
||||
return getData().getString("GUI.VoteGUI." + slot + ".Item.Material");
|
||||
}
|
||||
|
||||
public String getVoteGUISlotName(String slot) {
|
||||
return getData().getString("GUI.VoteGUI." + slot + ".Item.Name");
|
||||
}
|
||||
|
||||
public Set<String> getVoteGUISlots() {
|
||||
try {
|
||||
return getData().getConfigurationSection("GUI.VoteGUI").getKeys(
|
||||
false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public String getVoteGUISlotSkull(Player player, String slot) {
|
||||
String str = getData().getString("GUI.VoteGUI." + slot + ".Item.Skull");
|
||||
if (str != null) {
|
||||
str = str.replace("%Player%", player.getName());
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public int getVoteGUISlotSlot(String slot) {
|
||||
return getData().getInt("GUI.VoteGUI." + slot + ".Slot");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVoteGUISlotLore(String slot) {
|
||||
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList(
|
||||
"GUI.VoteGUI." + slot + ".Lore");
|
||||
if (list != null) {
|
||||
return list;
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
public int getVoteSiteItemAmount(String site) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getInt("GUI.VoteReward." + siteName + ".Item.Amount");
|
||||
}
|
||||
|
||||
public int getVoteSiteItemData(String site) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getInt("GUI.VoteReward." + siteName + ".Item.Data");
|
||||
}
|
||||
|
||||
public int getVoteSiteItemDurability(String site) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getInt(
|
||||
"GUI.VoteReward." + siteName + ".Item.Durability");
|
||||
}
|
||||
|
||||
public String getVoteSiteItemMaterial(String site) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getString(
|
||||
"GUI.VoteReward." + siteName + ".Item.Material");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getVoteSiteItemLore(String site) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return (List<String>) getData().getList(
|
||||
"GUI.VoteReward." + siteName + ".Item.Lore");
|
||||
}
|
||||
|
||||
public String getVoteSiteItemName(String site) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getString("GUI.VoteReward." + siteName + ".Item.Name");
|
||||
}
|
||||
|
||||
public Set<String> getVoteSiteItems(String site) {
|
||||
String siteName = site.replace(".", "-");
|
||||
try {
|
||||
return getData().getConfigurationSection(
|
||||
"GUI.VoteReward." + siteName + ".Items").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getVoteSiteItemsAmount(String site, String item) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getInt(
|
||||
"GUI.VoteReward." + siteName + ".Items." + item + ".Amount");
|
||||
}
|
||||
|
||||
public int getVoteSiteItemsData(String site, String item) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getInt(
|
||||
"GUI.VoteReward." + siteName + ".Items." + item + ".Data");
|
||||
}
|
||||
|
||||
public int getVoteSiteItemsDurability(String site, String item) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData()
|
||||
.getInt("GUI.VoteReward." + siteName + ".Items." + item
|
||||
+ ".Durability");
|
||||
}
|
||||
|
||||
public String getVoteSiteItemsMaterial(String site, String item) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getString(
|
||||
"GUI.VoteReward." + siteName + ".Items." + item + ".Material");
|
||||
|
||||
}
|
||||
|
||||
public String getVoteSiteItemSkull(Player player, String siteName) {
|
||||
String str = getData().getString(
|
||||
"GUI.VoteReward." + siteName + ".Item.Skull");
|
||||
if (str != null) {
|
||||
str = str.replace("%Player%", player.getName());
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getVoteSiteItemsLore(String site, String item) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return (List<String>) getData().getList(
|
||||
"GUI.VoteReward." + siteName + ".Items." + item + ".Lore");
|
||||
}
|
||||
|
||||
public String getVoteSiteItemsName(String site, String item) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getString(
|
||||
"GUI.VoteReward." + siteName + ".Items." + item + ".Name");
|
||||
}
|
||||
|
||||
public String getVoteSiteItemsSkull(Player player, String siteName,
|
||||
String item) {
|
||||
String str = getData().getString(
|
||||
"GUI.VoteReward." + siteName + ".Items." + item + ".Skull");
|
||||
if (str != null) {
|
||||
str = str.replace("%Player%", player.getName());
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public int getVoteSiteItemsSlot(String site, String item) {
|
||||
String siteName = site.replace(".", "-");
|
||||
return getData().getInt(
|
||||
"GUI.VoteReward." + siteName + ".Items." + item + ".Slot");
|
||||
}
|
||||
|
||||
public int getVoteURLAlreadyVotedItemAmount() {
|
||||
int num = getData().getInt("GUI.VoteURL.AlreadyVotedItem.Amount");
|
||||
if (num != 0) {
|
||||
return num;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getVoteURLAlreadyVotedItemData() {
|
||||
int num = getData().getInt("GUI.VoteURL.AlreadyVotedItem.Data");
|
||||
|
||||
return num;
|
||||
|
||||
}
|
||||
|
||||
public int getVoteURLAlreadyVotedItemDurability() {
|
||||
int num = getData().getInt("GUI.VoteURL.AlreadyVotedItem.Durability");
|
||||
|
||||
return num;
|
||||
|
||||
}
|
||||
|
||||
public String getVoteURLAlreadyVotedItemMaterial() {
|
||||
String str = getData().getString(
|
||||
"GUI.VoteURL.AlreadyVotedItem.Material");
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
return "REDSTONE_BLOCK";
|
||||
|
||||
}
|
||||
|
||||
public String getVoteURLAlreadyVotedItemSkull(Player player) {
|
||||
String str = getData().getString("GUI.VoteURL.AlreadyVotedItem.Skull");
|
||||
if (str != null) {
|
||||
str = str.replace("%Player%", player.getName());
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public int getVoteURLCanVoteItemAmount() {
|
||||
int num = getData().getInt("GUI.VoteURL.CanVoteItem.Amount");
|
||||
if (num != 0) {
|
||||
return num;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public int getVoteURLCanVoteItemData() {
|
||||
int num = getData().getInt("GUI.VoteURL.CanVoteItem.Data");
|
||||
|
||||
return num;
|
||||
|
||||
}
|
||||
|
||||
public int getVoteURLCanVoteItemDurability() {
|
||||
int num = getData().getInt("GUI.VoteURL.CanVoteItem.Durability");
|
||||
return num;
|
||||
|
||||
}
|
||||
|
||||
public String getVoteURLCanVoteItemMaterial() {
|
||||
String str = getData().getString("GUI.VoteURL.CanVoteItem.Material");
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
return "EMERALD_BLOCK";
|
||||
}
|
||||
|
||||
public String getVoteURLCanVoteItemSkull(Player player) {
|
||||
String str = getData().getString("GUI.VoteURL.CanVoteItem.Skull");
|
||||
if (str != null) {
|
||||
str = str.replace("%Player%", player.getName());
|
||||
return str;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getVoteURLNextVote() {
|
||||
String str = getData().getString("GUI.VoteURL.NextVote");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&cCan Vote In: %Info%";
|
||||
}
|
||||
}
|
||||
|
||||
public String getVoteURLSeeURL() {
|
||||
String str = getData().getString("GUI.VoteURL.SeeURL");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&cClick to see URL";
|
||||
}
|
||||
}
|
||||
|
||||
public String getVoteURLSiteName() {
|
||||
String str = getData().getString("GUI.VoteURL.SiteName");
|
||||
if (str != null) {
|
||||
return str;
|
||||
} else {
|
||||
return "&c%Name%";
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getVoteURLViewAllUrlsButtonEnabled() {
|
||||
return getData().getBoolean("GUI.VoteURL.ViewAllUrlsButtonEnabled");
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "GUI.yml");
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
plugin.saveResource("GUI.yml", true);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer().getLogger()
|
||||
.severe(ChatColor.RED + "Could not create GUI.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class ConfigOtherRewards {
|
||||
|
||||
static ConfigOtherRewards instance = new ConfigOtherRewards();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigOtherRewards getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private ConfigOtherRewards() {
|
||||
}
|
||||
|
||||
public ConfigOtherRewards(Main plugin) {
|
||||
ConfigOtherRewards.plugin = plugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getAllSitesReward() {
|
||||
try {
|
||||
return (ArrayList<String>) getData().getList("AllSites");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getFirstVoteRewards() {
|
||||
try {
|
||||
return (ArrayList<String>) getData().getList("FirstVote");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getNumberOfVotes() {
|
||||
try {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList(
|
||||
"CumulativeRewards");
|
||||
if (list != null) {
|
||||
return list;
|
||||
}
|
||||
|
||||
return new ArrayList<String>();
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getNumberOfVotesVotesInSameDay() {
|
||||
return getData().getBoolean("VotesInSameDay");
|
||||
}
|
||||
|
||||
public boolean getVotePartyEnabled() {
|
||||
return getData().getBoolean("VoteParty.Enabled");
|
||||
}
|
||||
|
||||
public boolean getVotePartyGiveAllPlayers() {
|
||||
return getData().getBoolean("VoteParty.GiveAllPlayers");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotePartyRewards() {
|
||||
return (ArrayList<String>) getData().getList("VoteParty.Rewards");
|
||||
}
|
||||
|
||||
public int getVotePartyVotesRequired() {
|
||||
return getData().getInt("VoteParty.VotesRequired");
|
||||
}
|
||||
|
||||
public int getVotesRequired() {
|
||||
return getData().getInt("VotesRequired");
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "Rewards.yml");
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
plugin.saveResource("Rewards.yml", true);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED + "Could not create Rewards.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,478 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.Reward;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class ConfigRewards {
|
||||
|
||||
static ConfigRewards instance = new ConfigRewards();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigRewards getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ConfigRewards() {
|
||||
}
|
||||
|
||||
public ConfigRewards(Main plugin) {
|
||||
ConfigRewards.plugin = plugin;
|
||||
}
|
||||
|
||||
public void checkDelayedTimedRewards() {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (Reward reward : plugin.rewards) {
|
||||
long time = user.getTimedReward(reward);
|
||||
if (time != 0) {
|
||||
Date timeDate = new Date(time);
|
||||
if (new Date().after(timeDate)) {
|
||||
reward.giveRewardReward(user);
|
||||
user.setTimedReward(reward, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public double getChance(String reward) {
|
||||
return getData(reward).getDouble("Chance");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getCommandsConsole(String reward) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(reward).getList(
|
||||
"Commands.Console");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getCommandsPlayer(String reward) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(reward).getList(
|
||||
"Commands.Player");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getData(String reward) {
|
||||
File dFile = getRewardFile(reward);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean getDelayedEnabled(String reward) {
|
||||
return getData(reward).getBoolean("Delayed.Enabled");
|
||||
}
|
||||
|
||||
public int getDelayedHours(String reward) {
|
||||
return getData(reward).getInt("Delayed.Hours");
|
||||
}
|
||||
|
||||
public int getDelayedMinutes(String reward) {
|
||||
return getData(reward).getInt("Delayed.Minutes");
|
||||
}
|
||||
|
||||
public int getEffectData(String reward) {
|
||||
return getData(reward).getInt("Effect.Data");
|
||||
}
|
||||
|
||||
public String getEffectEffect(String reward) {
|
||||
String str = getData(reward).getString("Effect.Effect");
|
||||
if (str != null) {
|
||||
return str;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public boolean getEffectEnabled(String reward) {
|
||||
return getData(reward).getBoolean("Effect.Enabled");
|
||||
}
|
||||
|
||||
public int getEffectParticles(String reward) {
|
||||
return getData(reward).getInt("Effect.Particles");
|
||||
}
|
||||
|
||||
public int getEffectRadius(String reward) {
|
||||
return getData(reward).getInt("Effect.Radius");
|
||||
}
|
||||
|
||||
public int getEXP(String reward) {
|
||||
return getData(reward).getInt("EXP");
|
||||
}
|
||||
|
||||
public boolean getGiveInEachWorld(String reward) {
|
||||
return getData(reward).getBoolean("GiveInEachWorld");
|
||||
}
|
||||
|
||||
public int getItemAmount(String reward, String item) {
|
||||
return getData(reward).getInt("Items." + item + ".Amount");
|
||||
}
|
||||
|
||||
public int getItemData(String reward, String item) {
|
||||
return getData(reward).getInt("Items." + item + ".Data");
|
||||
}
|
||||
|
||||
public int getItemDurability(String reward, String item) {
|
||||
return getData(reward).getInt("Items." + item + ".Durability");
|
||||
}
|
||||
|
||||
public Set<String> getItemEnchants(String reward, String item) {
|
||||
try {
|
||||
return getData(reward).getConfigurationSection(
|
||||
"Items." + item + ".Enchants").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getItemEnchantsLevel(String reward, String item, String enchant) {
|
||||
return getData(reward).getInt("Items." + item + ".Enchants." + enchant);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getItemLore(String reward, String item) {
|
||||
return (ArrayList<String>) getData(reward).getList(
|
||||
"Items." + item + ".Lore");
|
||||
}
|
||||
|
||||
public String getItemMaterial(String reward, String item) {
|
||||
return getData(reward).getString("Items." + item + ".Material");
|
||||
}
|
||||
|
||||
public int getItemMaxAmount(String reward, String item) {
|
||||
return getData(reward).getInt("Items." + item + ".MaxAmount");
|
||||
}
|
||||
|
||||
public int getItemMinAmount(String reward, String item) {
|
||||
return getData(reward).getInt("Items." + item + ".MinAmount");
|
||||
}
|
||||
|
||||
public String getItemName(String reward, String item) {
|
||||
return getData(reward).getString("Items." + item + ".Name");
|
||||
}
|
||||
|
||||
public Set<String> getItems(String reward) {
|
||||
try {
|
||||
return getData(reward).getConfigurationSection("Items").getKeys(
|
||||
false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public String getItemSkull(String reward, String item) {
|
||||
return getData(reward).getString("Items." + item + ".Skull");
|
||||
}
|
||||
|
||||
public int getMaxMoney(String reward) {
|
||||
return getData(reward).getInt("MaxMoney");
|
||||
}
|
||||
|
||||
public String getMessagesReward(String reward) {
|
||||
String msg = getData(reward).getString("Messages.Reward");
|
||||
if (msg != null) {
|
||||
return msg;
|
||||
} else {
|
||||
return ConfigFormat.getInstance().getRewardMsg();
|
||||
}
|
||||
}
|
||||
|
||||
public int getMinMoney(String reward) {
|
||||
return getData(reward).getInt("MinMoney");
|
||||
}
|
||||
|
||||
public int getMoney(String reward) {
|
||||
return getData(reward).getInt("Money");
|
||||
}
|
||||
|
||||
public String getPermission(String reward) {
|
||||
return "VotingPlugin.Reward." + reward;
|
||||
}
|
||||
|
||||
public Set<String> getPotions(String reward) {
|
||||
try {
|
||||
return getData(reward).getConfigurationSection("Potions").getKeys(
|
||||
false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getPotionsAmplifier(String reward, String potion) {
|
||||
return getData(reward).getInt("Potions." + potion + ".Amplifier");
|
||||
}
|
||||
|
||||
public int getPotionsDuration(String reward, String potion) {
|
||||
return getData(reward).getInt("Potions." + potion + ".Duration");
|
||||
}
|
||||
|
||||
public double getRandomChance(String reward) {
|
||||
return getData(reward).getDouble("Random.Chance");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getRandomFallBack(String reward) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(reward).getList(
|
||||
"Random.FallBack");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getRandomRewards(String reward) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(reward)
|
||||
.getList("Random.Rewards");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getRequirePermission(String reward) {
|
||||
return getData(reward).getBoolean("RequirePermission");
|
||||
}
|
||||
|
||||
public Reward getReward(String reward) {
|
||||
reward = reward.replace(" ", "_");
|
||||
if (plugin.rewards != null) {
|
||||
for (Reward rewardFile : plugin.rewards) {
|
||||
if (rewardFile.name.equals(reward)) {
|
||||
return rewardFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Reward(reward);
|
||||
}
|
||||
|
||||
public File getRewardFile(String reward) {
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "Rewards", reward + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create Rewards/" + reward
|
||||
+ ".yml!");
|
||||
|
||||
}
|
||||
}
|
||||
return dFile;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> getRewardFiles() {
|
||||
File folder = new File(plugin.getDataFolder() + File.separator
|
||||
+ "Rewards");
|
||||
String[] fileNames = folder.list();
|
||||
return Utils.getInstance().convertArray(fileNames);
|
||||
}
|
||||
|
||||
public ArrayList<String> getRewardNames() {
|
||||
ArrayList<String> rewardFiles = getRewardFiles();
|
||||
if (rewardFiles == null) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
for (int i = 0; i < rewardFiles.size(); i++) {
|
||||
rewardFiles.set(i, rewardFiles.get(i).replace(".yml", ""));
|
||||
}
|
||||
|
||||
Collections.sort(rewardFiles, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return rewardFiles;
|
||||
}
|
||||
|
||||
public boolean getSoundEnabled(String reward) {
|
||||
return getData(reward).getBoolean("Sound.Enabled");
|
||||
}
|
||||
|
||||
public float getSoundPitch(String reward) {
|
||||
return (float) getData(reward).getDouble("Sound.Pitch");
|
||||
}
|
||||
|
||||
public String getSoundSound(String reward) {
|
||||
return getData(reward).getString("Sound.Sound");
|
||||
}
|
||||
|
||||
public float getSoundVolume(String reward) {
|
||||
return (float) getData(reward).getDouble("Sound.Volume");
|
||||
}
|
||||
|
||||
public boolean getTimedEnabled(String reward) {
|
||||
return getData(reward).getBoolean("Timed.Enabled");
|
||||
}
|
||||
|
||||
public int getTimedHour(String reward) {
|
||||
return getData(reward).getInt("Timed.Hour");
|
||||
}
|
||||
|
||||
public int getTimedMinute(String reward) {
|
||||
return getData(reward).getInt("Timed.Minute");
|
||||
}
|
||||
|
||||
public boolean getTitleEnabled(String reward) {
|
||||
return getData(reward).getBoolean("Title.Enabled");
|
||||
}
|
||||
|
||||
public int getTitleFadeIn(String reward) {
|
||||
return getData(reward).getInt("Title.FadeIn");
|
||||
}
|
||||
|
||||
public int getTitleFadeOut(String reward) {
|
||||
return getData(reward).getInt("Title.FadeOut");
|
||||
}
|
||||
|
||||
public int getTitleShowTime(String reward) {
|
||||
return getData(reward).getInt("Title.ShowTime");
|
||||
}
|
||||
|
||||
public String getTitleSubTitle(String reward) {
|
||||
return getData(reward).getString("Title.SubTitle");
|
||||
}
|
||||
|
||||
public String getTitleTitle(String reward) {
|
||||
return getData(reward).getString("Title.Title");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getWorlds(String reward) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(reward).getList("Worlds");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean renameReward(String reward, String newName) {
|
||||
return getRewardFile(reward).renameTo(
|
||||
new File(plugin.getDataFolder() + File.separator + "Rewards",
|
||||
newName + ".yml"));
|
||||
}
|
||||
|
||||
public void set(String reward, String path, Object value) {
|
||||
File dFile = getRewardFile(reward);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
data.set(path, value);
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setChance(String reward, int value) {
|
||||
set(reward, "Chance", value);
|
||||
}
|
||||
|
||||
public void setCommandsConsole(String reward, ArrayList<String> value) {
|
||||
set(reward, "Commands.Console", value);
|
||||
}
|
||||
|
||||
public void setCommandsPlater(String reward, ArrayList<String> value) {
|
||||
set(reward, "Commands.Player", value);
|
||||
}
|
||||
|
||||
public void setGiveInEachWorld(String reward, boolean value) {
|
||||
set(reward, "GiveInEachWorld", value);
|
||||
}
|
||||
|
||||
public void setItemAmount(String reward, String item, int value) {
|
||||
set(reward, "Items." + item + ".Amount", value);
|
||||
}
|
||||
|
||||
public void setItemData(String reward, String item, int value) {
|
||||
set(reward, "Items." + item + ".Data", value);
|
||||
}
|
||||
|
||||
public void setItemEnchant(String reward, String item, String enchant,
|
||||
int value) {
|
||||
set(reward, "Items." + item + ".Enchants." + enchant, value);
|
||||
}
|
||||
|
||||
public void setItemLore(String reward, String item, ArrayList<String> value) {
|
||||
set(reward, "Items." + item + ".Lore", value);
|
||||
}
|
||||
|
||||
public void setItemMaterial(String reward, String item, String value) {
|
||||
set(reward, "Items." + item + ".Material", value);
|
||||
}
|
||||
|
||||
public void setItemMaxAmount(String reward, String item, int value) {
|
||||
set(reward, "Items." + item + ".MaxAmount", value);
|
||||
}
|
||||
|
||||
public void setItemMinAmount(String reward, String item, int value) {
|
||||
set(reward, "Items." + item + ".MinAmount", value);
|
||||
}
|
||||
|
||||
public void setItemName(String reward, String item, String value) {
|
||||
set(reward, "Items." + item + ".Name", value);
|
||||
}
|
||||
|
||||
public void setMaxMoney(String reward, int value) {
|
||||
set(reward, "MaxMoney", value);
|
||||
}
|
||||
|
||||
public void setMessagesReward(String reward, String value) {
|
||||
set(reward, "Messages.Reward", value);
|
||||
}
|
||||
|
||||
public void setMinMoney(String reward, int value) {
|
||||
set(reward, "MinMoney", value);
|
||||
}
|
||||
|
||||
public void setMoney(String reward, int value) {
|
||||
set(reward, "Money", value);
|
||||
}
|
||||
|
||||
public void setPotionsAmplifier(String reward, String potion, int value) {
|
||||
set(reward, "Potions." + potion + ".Amplifier", value);
|
||||
}
|
||||
|
||||
public void setPotionsDuration(String reward, String potion, int value) {
|
||||
set(reward, "Potions." + potion + ".Duration", value);
|
||||
}
|
||||
|
||||
public void setRequirePermission(String reward, boolean value) {
|
||||
set(reward, "RequirePermission", value);
|
||||
}
|
||||
|
||||
public void setupExample() {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File file = new File(plugin.getDataFolder(), "Rewards" + File.separator
|
||||
+ "ExampleReward.yml");
|
||||
if (!file.exists()) {
|
||||
plugin.saveResource("Rewards" + File.separator
|
||||
+ "ExampleReward.yml", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setWorlds(String reward, ArrayList<String> value) {
|
||||
set(reward, "Worlds", value);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class ConfigTopVoterAwards {
|
||||
|
||||
static ConfigTopVoterAwards instance = new ConfigTopVoterAwards();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigTopVoterAwards getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private ConfigTopVoterAwards() {
|
||||
}
|
||||
|
||||
public ConfigTopVoterAwards(Main plugin) {
|
||||
ConfigTopVoterAwards.plugin = plugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getBlackList() {
|
||||
return (List<String>) getData().getList("BlackList");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getDailyAwardRewards(int pos) {
|
||||
return (ArrayList<String>) getData().getList(
|
||||
"DailyAwards." + pos + ".Rewards");
|
||||
}
|
||||
|
||||
public boolean getDailyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableDailyAwards");
|
||||
}
|
||||
|
||||
public Set<String> getDailyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("DailyAwards").getKeys(
|
||||
false);
|
||||
} catch (Exception ex) {
|
||||
Set<String> noValues = new HashSet<String>();
|
||||
return noValues;
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getMonthlyAwardRewards(int pos) {
|
||||
return (ArrayList<String>) getData().getList(
|
||||
"MonthlyAwards." + pos + ".Rewards");
|
||||
}
|
||||
|
||||
public boolean getMonthlyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableMonthlyAwards");
|
||||
}
|
||||
|
||||
public Set<String> getMonthlyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("MonthlyAwards").getKeys(
|
||||
false);
|
||||
} catch (Exception ex) {
|
||||
Set<String> noValues = new HashSet<String>();
|
||||
return noValues;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getWeeklyAwardRewards(int pos) {
|
||||
return (ArrayList<String>) getData().getList(
|
||||
"WeeklyAwards." + pos + ".Rewards");
|
||||
}
|
||||
|
||||
public boolean getWeeklyAwardsEnabled() {
|
||||
return getData().getBoolean("EnableWeeklyAwards");
|
||||
}
|
||||
|
||||
public Set<String> getWeeklyPossibleRewardPlaces() {
|
||||
try {
|
||||
return getData().getConfigurationSection("WeeklyAwards").getKeys(
|
||||
false);
|
||||
} catch (Exception ex) {
|
||||
Set<String> noValues = new HashSet<String>();
|
||||
return noValues;
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "TopVoterAwards.yml");
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
plugin.saveResource("TopVoterAwards.yml", true);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED
|
||||
+ "Could not create TopVoterAwards.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class ConfigVoteReminding {
|
||||
|
||||
static ConfigVoteReminding instance = new ConfigVoteReminding();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigVoteReminding getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private ConfigVoteReminding() {
|
||||
}
|
||||
|
||||
public ConfigVoteReminding(Main plugin) {
|
||||
ConfigVoteReminding.plugin = plugin;
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public boolean getEnabled() {
|
||||
return getData().getBoolean("Enabled");
|
||||
}
|
||||
|
||||
public int getRemindDelay() {
|
||||
int num = getData().getInt("RemindDelay");
|
||||
if (num != 0) {
|
||||
return num;
|
||||
}
|
||||
return 30;
|
||||
}
|
||||
|
||||
public boolean getRemindOnLogin() {
|
||||
return getData().getBoolean("RemindOnLogin");
|
||||
}
|
||||
|
||||
public boolean getRemindOnlyOnce() {
|
||||
return getData().getBoolean("RemindOnlyOnce");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getRewards() {
|
||||
try {
|
||||
ArrayList<String> list = (ArrayList<String>) getData().getList(
|
||||
"Rewards");
|
||||
if (list != null) {
|
||||
return list;
|
||||
} else {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void set(String path, Object value) {
|
||||
getData().set(path, value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "VoteReminding.yml");
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
plugin.saveResource("VoteReminding.yml", true);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED
|
||||
+ "Could not create VoteReminding.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,295 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Config;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class ConfigVoteSites {
|
||||
|
||||
static ConfigVoteSites instance = new ConfigVoteSites();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ConfigVoteSites getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ConfigVoteSites() {
|
||||
}
|
||||
|
||||
public ConfigVoteSites(Main plugin) {
|
||||
ConfigVoteSites.plugin = plugin;
|
||||
}
|
||||
|
||||
public void generateVoteSite(String siteName) {
|
||||
plugin.getLogger().warning(
|
||||
"VoteSite " + siteName
|
||||
+ " doe not exist, generaterating one...");
|
||||
setEnabled(siteName, false);
|
||||
setServiceSite(siteName, "Enter Service Site");
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
setVoteDelay(siteName, 24);
|
||||
setRewards(siteName, new ArrayList<String>());
|
||||
|
||||
plugin.loadVoteSites();
|
||||
plugin.getLogger()
|
||||
.info("Created file VoteSites/"
|
||||
+ siteName
|
||||
+ ".yml! Loaded default values into file, remember to turn Enabled to true, else it won't be read by the plugin");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getCumulativeRewards(String siteName) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(siteName).getList(
|
||||
"Cumulative.Rewards");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getCumulativeRewardVotesAmount(String siteName) {
|
||||
return getData(siteName).getInt("Cumulative.Votes");
|
||||
}
|
||||
|
||||
public FileConfiguration getData(String siteName) {
|
||||
File dFile = getVoteSiteFile(siteName);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getPriority(String siteName) {
|
||||
return getData(siteName).getInt("Priority");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getRewards(String siteName) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(siteName).getList("Rewards");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public String getServiceSite(String siteName) {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
public int getVoteDelay(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelay");
|
||||
}
|
||||
|
||||
public boolean getVoteSiteEnabled(String siteName) {
|
||||
return getData(siteName).getBoolean("Enabled");
|
||||
}
|
||||
|
||||
public File getVoteSiteFile(String siteName) {
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "VoteSites", siteName + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create VoteSites/"
|
||||
+ siteName + ".yml!");
|
||||
|
||||
}
|
||||
}
|
||||
return dFile;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<VoteSite> getVoteSites() {
|
||||
if (plugin.voteSites != null) {
|
||||
return plugin.voteSites;
|
||||
} else {
|
||||
plugin.loadVoteSites();
|
||||
return plugin.voteSites;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getVoteSitesFiles() {
|
||||
File folder = new File(plugin.getDataFolder() + File.separator
|
||||
+ "VoteSites");
|
||||
String[] fileNames = folder.list();
|
||||
return Utils.getInstance().convertArray(fileNames);
|
||||
}
|
||||
|
||||
public ArrayList<VoteSite> getVoteSitesLoad() {
|
||||
ArrayList<VoteSite> voteSites = new ArrayList<VoteSite>();
|
||||
ArrayList<String> voteSiteNames = getVoteSitesNames();
|
||||
if (voteSiteNames != null) {
|
||||
for (String site : voteSiteNames) {
|
||||
if (!site.equalsIgnoreCase("Example")
|
||||
&& getVoteSiteEnabled(site)
|
||||
&& !site.equalsIgnoreCase("null")) {
|
||||
if (!siteCheck(site)) {
|
||||
plugin.getLogger().warning(
|
||||
"Failed to load site " + site + ", see above");
|
||||
} else {
|
||||
voteSites.add(new VoteSite(site));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(voteSites, new Comparator<VoteSite>() {
|
||||
@Override
|
||||
public int compare(VoteSite v1, VoteSite v2) {
|
||||
int v1P = getPriority(v1.getSiteName());
|
||||
int v2P = getPriority(v2.getSiteName());
|
||||
|
||||
if (v1P < v2P) {
|
||||
return 1;
|
||||
}
|
||||
if (v1P > v2P) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
public ArrayList<String> getVoteSitesNames() {
|
||||
ArrayList<String> siteNames = getVoteSitesFiles();
|
||||
if (siteNames == null) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < siteNames.size(); i++) {
|
||||
siteNames.set(i, siteNames.get(i).replace(".yml", ""));
|
||||
}
|
||||
for (int i = siteNames.size() - 1; i >= 0; i--) {
|
||||
// plugin.getLogger().info(siteNames.get(i));
|
||||
if (!getVoteSiteEnabled(siteNames.get(i))
|
||||
|| siteNames.get(i).equalsIgnoreCase("Example")
|
||||
|| siteNames.get(i).equalsIgnoreCase("null")
|
||||
|| !siteCheck(siteNames.get(i))) {
|
||||
// plugin.getLogger().info("Removed: " + siteNames.get(i));
|
||||
siteNames.remove(i);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return siteNames;
|
||||
}
|
||||
|
||||
public String getVoteURL(String siteName) {
|
||||
return getData(siteName).getString("VoteURL");
|
||||
}
|
||||
|
||||
public boolean isServiceSiteGood(String siteName) {
|
||||
if (getServiceSite(siteName) == null) {
|
||||
return false;
|
||||
} else if (getServiceSite(siteName).equalsIgnoreCase("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isVoteURLGood(String siteName) {
|
||||
if (getVoteURL(siteName) == null) {
|
||||
return false;
|
||||
} else if (getVoteURL(siteName).equalsIgnoreCase("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean renameVoteSite(String siteName, String newName) {
|
||||
return getVoteSiteFile(siteName).renameTo(
|
||||
new File(plugin.getDataFolder() + File.separator + "VoteSites",
|
||||
newName + ".yml"));
|
||||
}
|
||||
|
||||
public void set(String siteName, String path, Object value) {
|
||||
// String playerName = user.getPlayerName();
|
||||
File dFile = getVoteSiteFile(siteName);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
data.set(path, value);
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setCumulativeRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Cumulative.Rewards", value);
|
||||
}
|
||||
|
||||
public void setEnabled(String siteName, boolean disabled) {
|
||||
set(siteName, "Enabled", disabled);
|
||||
}
|
||||
|
||||
public void setPriority(String siteName, int value) {
|
||||
set(siteName, "Priority", value);
|
||||
}
|
||||
|
||||
public void setRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Rewards", value);
|
||||
}
|
||||
|
||||
public void setServiceSite(String siteName, String serviceSite) {
|
||||
set(siteName, "ServiceSite", serviceSite);
|
||||
}
|
||||
|
||||
public void setup(String siteName) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "VoteSites", siteName + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
if (siteName.equalsIgnoreCase("ExampleVoteSite")) {
|
||||
plugin.saveResource("VoteSites" + File.separator
|
||||
+ "ExampleVoteSite.yml", true);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create VoteSites/"
|
||||
+ siteName + ".yml!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVoteDelay(String siteName, int voteDelay) {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
public void setVoteURL(String siteName, String url) {
|
||||
set(siteName, "VoteURL", url);
|
||||
}
|
||||
|
||||
public boolean siteCheck(String siteName) {
|
||||
boolean pass = true;
|
||||
if (!isServiceSiteGood(siteName)) {
|
||||
plugin.getLogger().warning(
|
||||
"Issue with ServiceSite in site " + siteName
|
||||
+ ", votes may not work properly");
|
||||
pass = false;
|
||||
}
|
||||
if (!isVoteURLGood(siteName)) {
|
||||
plugin.getLogger()
|
||||
.warning("Issue with VoteURL in site " + siteName);
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,397 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class Data {
|
||||
|
||||
static Data instance = new Data();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static Data getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Data() {
|
||||
}
|
||||
|
||||
public Data(Main plugin) {
|
||||
Data.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addCumulativeSite(User user, String voteSite) {
|
||||
setCumulativeSite(user, voteSite, getCumulativeSite(user, voteSite) + 1);
|
||||
}
|
||||
|
||||
public void addTotal(User user, String voteSite) {
|
||||
set(user, "Total." + voteSite, getTotal(user, voteSite) + 1);
|
||||
}
|
||||
|
||||
public int getAllSitesOffline(User user) {
|
||||
return getData(user).getInt("OtherRewards.AllSites");
|
||||
}
|
||||
|
||||
public int getCumulativeSite(User user, String voteSite) {
|
||||
return getData(user).getInt("Cumulative." + voteSite);
|
||||
}
|
||||
|
||||
public FileConfiguration getData(User user) {
|
||||
File dFile = getPlayerFile(user);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
return data;
|
||||
}
|
||||
|
||||
public ArrayList<String> getFiles() {
|
||||
File folder = new File(plugin.getDataFolder() + File.separator + "Data");
|
||||
String[] fileNames = folder.list();
|
||||
return Utils.getInstance().convertArray(fileNames);
|
||||
}
|
||||
|
||||
public int getFirstVoteOffline(User user) {
|
||||
return getData(user).getInt("OtherRewards.FirstVote");
|
||||
}
|
||||
|
||||
public boolean getHasGottenFirstReward(User user) {
|
||||
return getData(user).getBoolean("FirstVoteGotten");
|
||||
}
|
||||
|
||||
public String getName(User user) {
|
||||
return getData(user).getString("Name");
|
||||
}
|
||||
|
||||
public int getNumberOfVotesOffline(User user) {
|
||||
return getData(user).getInt("OtherRewards.NumberOfVotes");
|
||||
}
|
||||
|
||||
public int getOfflineVotesSite(User user, String siteName) {
|
||||
return getData(user).getInt("OfflineVotes." + siteName);
|
||||
}
|
||||
|
||||
public int getOfflineVotesSiteWorld(User user, String reward, String world) {
|
||||
if (world == null) {
|
||||
world = "AllTheWorlds";
|
||||
}
|
||||
return getData(user)
|
||||
.getInt("OfflineVotesWorld." + reward + "." + world);
|
||||
}
|
||||
|
||||
public File getPlayerFile(User user) {
|
||||
String playerName = user.getPlayerName();
|
||||
String uuid = user.getUUID();
|
||||
// plugin.debug(playerName + ":" + uuid);
|
||||
// plugin.debug(plugin.toString());
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator + "Data",
|
||||
uuid + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
setPlayerName(user);
|
||||
|
||||
plugin.debug("Created file: " + uuid + ".yml from player: "
|
||||
+ playerName);
|
||||
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED + "Could not create " + uuid
|
||||
+ ".yml! Name: " + playerName);
|
||||
|
||||
}
|
||||
}
|
||||
return dFile;
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> getPlayerNames() {
|
||||
ArrayList<String> files = getFiles();
|
||||
ArrayList<String> names = new ArrayList<String>();
|
||||
if (files != null) {
|
||||
for (String playerFile : files) {
|
||||
String uuid = playerFile.replace(".yml", "");
|
||||
String playerName = Utils.getInstance().getPlayerName(uuid);
|
||||
if (playerName != null) {
|
||||
names.add(playerName);
|
||||
}
|
||||
}
|
||||
Set<String> namesSet = new HashSet<String>(names);
|
||||
names = Utils.getInstance().convert(namesSet);
|
||||
if (names == null) {
|
||||
return null;
|
||||
} else {
|
||||
return names;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ArrayList<String> getPlayersUUIDs() {
|
||||
ArrayList<String> files = getFiles();
|
||||
if (files != null) {
|
||||
ArrayList<String> uuids = new ArrayList<String>();
|
||||
if (files.size() > 0) {
|
||||
for (String playerFile : files) {
|
||||
String uuid = playerFile.replace(".yml", "");
|
||||
uuids.add(uuid);
|
||||
}
|
||||
if (uuids == null) {
|
||||
return null;
|
||||
} else {
|
||||
return uuids;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public boolean getReminded(User user) {
|
||||
return getData(user).getBoolean("Reminded");
|
||||
}
|
||||
|
||||
public long getTimedReward(User user, String reward) {
|
||||
return getData(user).getLong("Timed." + reward);
|
||||
}
|
||||
|
||||
public long getTimeSite(User user, String voteSite) {
|
||||
return getData(user).getLong("LastVote." + voteSite + ".Miliseconds");
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getTopVoterAwardOffline(User user) {
|
||||
return getData(user).getInt(
|
||||
"TopVoter." + new Date().getYear() + "."
|
||||
+ new Date().getMonth());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getTopVoterAwardOfflineDaily(User user, int date) {
|
||||
return getData(user).getInt(
|
||||
"TopVoter." + new Date().getYear() + "."
|
||||
+ new Date().getMonth() + "." + date);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getTopVoterAwardOfflineWeekly(User user, int day) {
|
||||
return getData(user).getInt(
|
||||
"TopVoter." + new Date().getYear() + "."
|
||||
+ new Date().getMonth() + "." + day);
|
||||
}
|
||||
|
||||
public int getTotal(User user, String voteSite) {
|
||||
return getData(user).getInt("Total." + voteSite);
|
||||
}
|
||||
|
||||
public int getTotalDaily(User user, String voteSite) {
|
||||
return getData(user).getInt("TotalDay." + voteSite);
|
||||
}
|
||||
|
||||
public int getTotalWeek(User user, String voteSite) {
|
||||
return getData(user).getInt("TotalWeek." + voteSite);
|
||||
}
|
||||
|
||||
public Set<User> getUsers() {
|
||||
Set<User> users = new HashSet<User>();
|
||||
ArrayList<String> players = getPlayerNames();
|
||||
if (players != null) {
|
||||
for (String playerName : players) {
|
||||
User user = new User(playerName);
|
||||
users.add(user);
|
||||
}
|
||||
return users;
|
||||
} else {
|
||||
return new HashSet<User>();
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotingPoints(User user) {
|
||||
return getData(user).getInt("Points");
|
||||
}
|
||||
|
||||
public boolean hasJoinedBefore(User user) {
|
||||
try {
|
||||
return getPlayersUUIDs().contains(user.getUUID());
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void saveData(User user) {
|
||||
File dFile = getPlayerFile(user);
|
||||
String playerName = user.getPlayerName();
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED + "Could not save "
|
||||
+ Utils.getInstance().getUUID(playerName) + ".yml!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void set(User user, String path, Object value) {
|
||||
File dFile = getPlayerFile(user);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
data.set(path, value);
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setAllSitesOffline(User user, int value) {
|
||||
set(user, "OtherRewards.AllSites", value);
|
||||
}
|
||||
|
||||
public void setCumulativeSite(User user, String voteSite, int amount) {
|
||||
set(user, "Cumulative." + voteSite, amount);
|
||||
}
|
||||
|
||||
public void setFirstVoteOffline(User user, int value) {
|
||||
set(user, "OtherRewards.FirstVote", value);
|
||||
}
|
||||
|
||||
public void setHasGottenFirstReward(User user, boolean value) {
|
||||
set(user, "FirstVoteGotten", value);
|
||||
}
|
||||
|
||||
public void setNumberOfVotesOffline(User user, int value) {
|
||||
set(user, "OtherRewards.NumberOfVotes", value);
|
||||
}
|
||||
|
||||
public void setOfflineVotesSite(User user, String siteName, int value) {
|
||||
set(user, "OfflineVotes." + siteName, value);
|
||||
}
|
||||
|
||||
public void setOfflineVotesSiteWorld(User user, String reward,
|
||||
String world, int value) {
|
||||
if (world == null) {
|
||||
world = "AllTheWorlds";
|
||||
}
|
||||
set(user, "OfflineVotesWorld." + reward + "." + world, value);
|
||||
}
|
||||
|
||||
public void setPlayerName(User user) {
|
||||
set(user, "PlayerName", user.getPlayerName());
|
||||
}
|
||||
|
||||
public void setReminded(User user, boolean value) {
|
||||
set(user, "Reminded", value);
|
||||
}
|
||||
|
||||
public void setTime(String siteName, User user) {
|
||||
set(user, "LastVote." + siteName + ".Miliseconds",
|
||||
System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public void setTimedReward(User user, String reward, long time) {
|
||||
set(user, "Timed." + reward, time);
|
||||
}
|
||||
|
||||
/*
|
||||
* public int getVotesBonusReward(User user) { return
|
||||
* getData(user).getInt("BonusVotes"); }
|
||||
*
|
||||
* public void setVotesBonusReward(User user, int value) { set(user,
|
||||
* "BonusVotes", value); }
|
||||
*/
|
||||
|
||||
public void setTimeMill(String siteName, User user, Long mill) {
|
||||
set(user, "LastVote." + siteName + ".Miliseconds", mill);
|
||||
}
|
||||
|
||||
public void setTimeSite(User user, String voteSite, int value) {
|
||||
set(user, "LastVote." + voteSite + ".Miliseconds", value);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setTopVoterAwardOffline(User user, int place) {
|
||||
set(user,
|
||||
"TopVoter." + new Date().getYear() + "."
|
||||
+ new Date().getMonth(), place);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setTopVoterAwardOfflineDaily(User user, int place) {
|
||||
set(user,
|
||||
"TopVoter." + new Date().getYear() + "."
|
||||
+ new Date().getMonth() + "." + new Date().getDate(),
|
||||
place);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setTopVoterAwardOfflineWeekly(User user, int place) {
|
||||
set(user,
|
||||
"TopVoter." + new Date().getYear() + "."
|
||||
+ new Date().getMonth() + "." + new Date().getDay(),
|
||||
place);
|
||||
}
|
||||
|
||||
public void setTotal(User user, String voteSite, int amount) {
|
||||
set(user, "Total." + voteSite, amount);
|
||||
}
|
||||
|
||||
public void setTotalDaily(User user, String voteSite, int amount) {
|
||||
set(user, "TotalDay." + voteSite, amount);
|
||||
}
|
||||
|
||||
public void setTotalWeek(User user, String voteSite, int amount) {
|
||||
set(user, "TotalWeek." + voteSite, amount);
|
||||
}
|
||||
|
||||
public void setup(User user) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
String uuid = user.getUUID();
|
||||
String playerName = user.getPlayerName();
|
||||
if (playerName == null) {
|
||||
Utils.getInstance().getPlayerName(uuid);
|
||||
}
|
||||
|
||||
if (playerName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator + "Data",
|
||||
uuid + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
setPlayerName(user);
|
||||
|
||||
plugin.debug("Created file: " + uuid + ".yml from player: "
|
||||
+ playerName);
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create " + uuid
|
||||
+ ".yml! Name: " + playerName);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVotingPoints(User user, int value) {
|
||||
set(user, "Points", value);
|
||||
}
|
||||
}
|
||||
@@ -1,210 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
|
||||
public class ServerData {
|
||||
|
||||
static ServerData instance = new ServerData();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static ServerData getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private ServerData() {
|
||||
}
|
||||
|
||||
public ServerData(Main plugin) {
|
||||
ServerData.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addSign(Location location, String data, int position) {
|
||||
|
||||
int count = nextSignNumber();
|
||||
|
||||
getData().set("Signs." + count + ".World",
|
||||
location.getWorld().getName());
|
||||
getData().set("Signs." + count + ".X", location.getBlockX());
|
||||
getData().set("Signs." + count + ".Y", location.getBlockY());
|
||||
getData().set("Signs." + count + ".Z", location.getBlockZ());
|
||||
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)));
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getPrevDay() {
|
||||
return getData().getInt("PrevDay");
|
||||
}
|
||||
|
||||
public int getPrevMonth() {
|
||||
return getData().getInt("PrevMonth");
|
||||
}
|
||||
|
||||
public int getPrevWeekDay() {
|
||||
return getData().getInt("PrevWeek");
|
||||
}
|
||||
|
||||
public String getSignData(String sign) {
|
||||
return getData().getString("Signs." + sign + ".Data");
|
||||
}
|
||||
|
||||
public Location getSignLocation(String sign) {
|
||||
return new Location(Bukkit.getWorld(getData().getString(
|
||||
"Signs." + sign + ".World")), getData().getDouble(
|
||||
"Signs." + sign + ".X"), getData().getDouble(
|
||||
"Signs." + sign + ".Y"), getData().getDouble(
|
||||
"Signs." + sign + ".Z"));
|
||||
}
|
||||
|
||||
public int getSignPosition(String sign) {
|
||||
return getData().getInt("Signs." + sign + ".Position");
|
||||
}
|
||||
|
||||
public Set<String> getSigns() {
|
||||
try {
|
||||
return getData().getConfigurationSection("Signs").getKeys(false);
|
||||
} catch (Exception ex) {
|
||||
return new HashSet<String>();
|
||||
}
|
||||
}
|
||||
|
||||
public int nextSignNumber() {
|
||||
Set<String> signs = getSigns();
|
||||
|
||||
if (signs != null) {
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
if (!signs.contains(Integer.toString(i))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void removeSign(String sign) {
|
||||
getData().set("Signs." + sign + ".World", null);
|
||||
getData().set("Signs." + sign + ".X", null);
|
||||
getData().set("Signs." + sign + ".Y", null);
|
||||
getData().set("Signs." + sign + ".Z", null);
|
||||
getData().set("Signs." + sign + ".Data", null);
|
||||
getData().set("Signs." + sign + ".Position", null);
|
||||
getData().set("Signs." + sign, null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
public void setPluginVersion() {
|
||||
getData().set("PluginVersion", plugin.getDescription().getVersion());
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setPrevDay(int day) {
|
||||
getData().set("PrevDay", day);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setPrevMonth(int value) {
|
||||
getData().set("PrevMonth", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setPrevWeekDay(int week) {
|
||||
getData().set("PrevWeek", week);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setSign(String count, Location location, 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 + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
saveData();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "ServerData.yml");
|
||||
|
||||
boolean genFile = false;
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
genFile = true;
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED
|
||||
+ "Could not create ServerData.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
data.options().header("DO NOT EDIT THIS FILE MANUALLY");
|
||||
if (genFile) {
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
setPrevMonth(c.getTime().getMonth());
|
||||
int day = c.getTime().getDay();
|
||||
ServerData.getInstance().setPrevDay(day);
|
||||
ServerData.getInstance().setPrevWeekDay(c.getTime().getDate());
|
||||
}
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVersion() {
|
||||
getData().set("Version", Bukkit.getVersion());
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void updateValues() {
|
||||
setVersion();
|
||||
setPluginVersion();
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
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.Data.ServerData;
|
||||
|
||||
public class BlockBreak implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static Main plugin;
|
||||
|
||||
public BlockBreak(Main plugin) {
|
||||
BlockBreak.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign s = (Sign) event.getBlock().getState();
|
||||
if (s.getLine(0).startsWith("TopVoter")) {
|
||||
Set<String> signs = ServerData.getInstance().getSigns();
|
||||
if (signs != null) {
|
||||
for (String sign : signs) {
|
||||
if (ServerData.getInstance().getSignLocation(sign)
|
||||
.equals(event.getBlock().getLocation())) {
|
||||
ServerData.getInstance().removeSign(sign);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +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.Objects.User;
|
||||
|
||||
public class PlayerInteract implements Listener {
|
||||
|
||||
private static Main plugin;
|
||||
|
||||
public PlayerInteract(Main plugin) {
|
||||
PlayerInteract.plugin = plugin;
|
||||
}
|
||||
|
||||
@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");
|
||||
new User(player.getName()).sendMessage(sign
|
||||
.getRightClickMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +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.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
private static Main plugin;
|
||||
|
||||
Data data = Data.getInstance();
|
||||
|
||||
public PlayerJoinEvent(Main plugin) {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (event.getPlayer() == null) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
User user = new User(player);
|
||||
|
||||
plugin.getServer().getScheduler()
|
||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
user.setPlayerName();
|
||||
|
||||
user.offVoteWorld(player.getWorld().getName());
|
||||
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
|
||||
// msg player if he can vote
|
||||
user.loginMessage();
|
||||
}
|
||||
}, 100L);
|
||||
}
|
||||
}, 20L);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class PlayerVoteEvent extends Event {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private User player;
|
||||
private VoteSite voteSite;
|
||||
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, User player) {
|
||||
super();
|
||||
setPlayer(player);
|
||||
setVoteSite(voteSite);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public User getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public VoteSite getVoteSite() {
|
||||
return voteSite;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
public void setPlayer(User player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public void setVoteSite(VoteSite voteSite) {
|
||||
this.voteSite = voteSite;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.Signs;
|
||||
|
||||
public class SignChange implements Listener {
|
||||
|
||||
private static Main plugin;
|
||||
|
||||
public SignChange(Main plugin) {
|
||||
SignChange.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
if (event.getLine(0).equalsIgnoreCase("[VotingPlugin]")) {
|
||||
if (Utils.getInstance().hasPermission(event.getPlayer(),
|
||||
"Sign.Create")) {
|
||||
try {
|
||||
ServerData.getInstance().addSign(
|
||||
event.getBlock().getLocation(), event.getLine(2),
|
||||
Integer.parseInt(event.getLine(1)));
|
||||
event.getPlayer().sendMessage(
|
||||
Utils.getInstance().colorize("&aAdded sign!"));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,
|
||||
new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().updateSigns();
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
event.getPlayer().sendMessage(
|
||||
Utils.getInstance().colorize(
|
||||
"&cError on sign creation!"));
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
event.getPlayer().sendMessage(
|
||||
ConfigFormat.getInstance().getNoPerms());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,227 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Bungee.BungeeVote;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
public class VotiferEvent implements Listener {
|
||||
|
||||
static ConfigOtherRewards bonusReward = ConfigOtherRewards.getInstance();
|
||||
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static void playerVote(String playerName, String voteSiteURL) {
|
||||
User user = new User(playerName);
|
||||
if (!user.hasJoinedBefore() && !config.allowUnJoined()) {
|
||||
plugin.getLogger().info(
|
||||
"Player " + playerName
|
||||
+ " has not joined before, disregarding vote");
|
||||
return;
|
||||
}
|
||||
|
||||
String voteSiteName = Utils.getInstance().getVoteSiteName(voteSiteURL);
|
||||
|
||||
if (voteSiteName == null) {
|
||||
plugin.getLogger().info("Error on votesite name");
|
||||
return;
|
||||
}
|
||||
|
||||
// ArrayList<String> sites = configVoteSites.getVoteSitesNames();
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(voteSiteName);
|
||||
if (voteSite == null) {
|
||||
|
||||
plugin.debug("VoteSite is null");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VoteParty.getInstance().addTotal();
|
||||
VoteParty.getInstance().addVotePlayer(user);
|
||||
VoteParty.getInstance().check();
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (config.getBroadCastVotesEnabled()) {
|
||||
if (!ConfigFormat.getInstance().getBroadcastWhenOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
} else if (Utils.getInstance().isPlayerOnline(playerName)) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
user.setTime(voteSite);
|
||||
|
||||
// add to total votes
|
||||
user.addTotal(voteSite);
|
||||
user.addTotalDaily(voteSite);
|
||||
user.addTotalWeekly(voteSite);
|
||||
user.addPoints();
|
||||
|
||||
user.setReminded(false);
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
boolean firstVote = OtherVoteReward.getInstance()
|
||||
.checkFirstVote(user);
|
||||
boolean allSites = OtherVoteReward.getInstance().checkAllSites(
|
||||
user);
|
||||
boolean numberOfVotes = OtherVoteReward.getInstance()
|
||||
.checkNumberOfVotes(user);
|
||||
|
||||
if (Utils.getInstance().isPlayerOnline(playerName)) {
|
||||
|
||||
user.playerVote(voteSite);
|
||||
|
||||
if (firstVote) {
|
||||
OtherVoteReward.getInstance()
|
||||
.giveFirstVoteRewards(user);
|
||||
|
||||
}
|
||||
|
||||
if (allSites) {
|
||||
OtherVoteReward.getInstance().giveAllSitesRewards(user);
|
||||
|
||||
}
|
||||
|
||||
if (numberOfVotes) {
|
||||
OtherVoteReward.getInstance().giveNumberOfVotesRewards(
|
||||
user);
|
||||
|
||||
}
|
||||
user.sendVoteEffects();
|
||||
} else {
|
||||
if (firstVote) {
|
||||
Data.getInstance()
|
||||
.setFirstVoteOffline(
|
||||
user,
|
||||
Data.getInstance().getFirstVoteOffline(
|
||||
user) + 1);
|
||||
plugin.debug("Offline first vote reward set for "
|
||||
+ playerName);
|
||||
}
|
||||
|
||||
if (allSites) {
|
||||
Data.getInstance()
|
||||
.setAllSitesOffline(
|
||||
user,
|
||||
Data.getInstance().getAllSitesOffline(
|
||||
user) + 1);
|
||||
plugin.debug("Offline bonus reward set for "
|
||||
+ playerName);
|
||||
}
|
||||
|
||||
if (numberOfVotes) {
|
||||
Data.getInstance().setNumberOfVotesOffline(
|
||||
user,
|
||||
Data.getInstance()
|
||||
.getNumberOfVotesOffline(user) + 1);
|
||||
plugin.debug("Offline number of votes reward set for "
|
||||
+ playerName);
|
||||
}
|
||||
|
||||
user.addOfflineVote(voteSite);
|
||||
|
||||
plugin.debug("Offline vote set for " + playerName + " on "
|
||||
+ voteSiteName);
|
||||
|
||||
}
|
||||
|
||||
plugin.update();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public VotiferEvent(Main plugin) {
|
||||
VotiferEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onVotiferEvent(VotifierEvent event) {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
String voteSite = vote.getServiceName();
|
||||
String voteUsername = vote.getUsername();
|
||||
|
||||
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);
|
||||
|
||||
String voteSiteName = Utils.getInstance().getVoteSiteName(voteSite);
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(voteSiteName), new User(voteUsername));
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
ConfigVoteSites.getInstance().setServiceSite(voteSiteName,
|
||||
voteSite);
|
||||
}
|
||||
} else if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
plugin.getLogger().warning(
|
||||
"VoteSite " + voteSiteName
|
||||
+ " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
ConfigVoteSites.getInstance()
|
||||
.setServiceSite(voteSiteName, voteSite);
|
||||
}
|
||||
|
||||
try {
|
||||
BungeeVote.getInstance().sendVote(vote);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
playerVote(voteUsername, voteSite);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Files;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
public class Files {
|
||||
|
||||
public class ReadThread extends Thread {
|
||||
public void editFile(File file, FileConfiguration data) {
|
||||
try {
|
||||
data.save(file);
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED + "Could not save "
|
||||
+ file.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// plugin.getLogger().info("File Editing Thread Loaded!");
|
||||
}
|
||||
}
|
||||
|
||||
static Files instance = new Files();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static Files getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public ReadThread thread;
|
||||
|
||||
private Files() {
|
||||
}
|
||||
|
||||
public Files(Main plugin) {
|
||||
Files.plugin = plugin;
|
||||
}
|
||||
|
||||
public void editFile(File file, FileConfiguration data) {
|
||||
thread.editFile(file, data);
|
||||
}
|
||||
|
||||
public void loadFileEditngThread() {
|
||||
thread = new ReadThread();
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
/* Obtained from https://www.spigotmc.org/threads/libish-inventory-api-kinda.49339/
|
||||
*/
|
||||
|
||||
package com.Ben12345rocks.VotingPlugin.Inventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
|
||||
public class BInventory implements Listener {
|
||||
|
||||
public static void openInventory(Player player, BInventory inventory) {
|
||||
Inventory inv = Bukkit.createInventory(player,
|
||||
inventory.getInventorySize(), inventory.getInventoryName());
|
||||
Iterator<Entry<Integer, BInventoryButton>> it = inventory.getButtons()
|
||||
.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<Integer, BInventoryButton> pair = it.next();
|
||||
{
|
||||
ItemStack item = pair.getValue().getItem();
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (pair.getValue().getName() != null) {
|
||||
meta.setDisplayName(pair.getValue().getName());
|
||||
}
|
||||
if (pair.getValue().getLore() != null) {
|
||||
meta.setLore(new ArrayList<String>(Arrays.asList(pair
|
||||
.getValue().getLore())));
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
inv.setItem(pair.getKey(), item);
|
||||
}
|
||||
inv.setItem(pair.getKey(), pair.getValue().getItem());
|
||||
}
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
||||
private String inventoryName;
|
||||
|
||||
private Map<Integer, BInventoryButton> buttons = new HashMap<Integer, BInventoryButton>();
|
||||
|
||||
public BInventory(String name) {
|
||||
setInventoryName(name);
|
||||
Bukkit.getPluginManager().registerEvents(this,
|
||||
Bukkit.getPluginManager().getPlugins()[0]);
|
||||
}
|
||||
|
||||
public void addButton(int position, BInventoryButton button) {
|
||||
getButtons().put(position, button);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the inventory buttons
|
||||
*/
|
||||
public Map<Integer, BInventoryButton> getButtons() {
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public int getHighestSlot() {
|
||||
int highestNum = 0;
|
||||
for (int num : buttons.keySet()) {
|
||||
if (num > highestNum) {
|
||||
highestNum = num;
|
||||
}
|
||||
}
|
||||
return highestNum;
|
||||
}
|
||||
|
||||
public String getInventoryName() {
|
||||
return inventoryName;
|
||||
}
|
||||
|
||||
public int getInventorySize() {
|
||||
int highestSlot = getHighestSlot();
|
||||
if (highestSlot <= 9) {
|
||||
return 9;
|
||||
} else if (highestSlot < 18) {
|
||||
return 18;
|
||||
} else if (highestSlot < 27) {
|
||||
return 27;
|
||||
} else if (highestSlot < 36) {
|
||||
return 36;
|
||||
} else if (highestSlot < 45) {
|
||||
return 45;
|
||||
} else {
|
||||
return 45;
|
||||
}
|
||||
}
|
||||
|
||||
// event handling
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Main.plugin.debug("Event ran");
|
||||
|
||||
Inventory inv = event.getInventory();
|
||||
if (inv.getName().equalsIgnoreCase(getInventoryName())) {
|
||||
// Main.plugin.debug("Iventory equal");
|
||||
for (int buttonSlot : getButtons().keySet()) {
|
||||
BInventoryButton button = getButtons().get(buttonSlot);
|
||||
if (event.getSlot() == buttonSlot) {
|
||||
// Main.plugin.debug("Running onclick");
|
||||
button.onClick(event);
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setInventoryName(String inventoryName) {
|
||||
this.inventoryName = Utils.getInstance().colorize(inventoryName);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/* Obtained from https://www.spigotmc.org/threads/libish-inventory-api-kinda.49339/
|
||||
*/
|
||||
|
||||
package com.Ben12345rocks.VotingPlugin.Inventory;
|
||||
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
|
||||
public abstract class BInventoryButton {
|
||||
|
||||
private String name;
|
||||
private String[] lore;
|
||||
private ItemStack item;
|
||||
private int slot;
|
||||
|
||||
public BInventoryButton(String name, String[] lore, ItemStack item) {
|
||||
setName(name);
|
||||
setLore(lore);
|
||||
setItem(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the lore
|
||||
*/
|
||||
public String[] getLore() {
|
||||
return lore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return slot;
|
||||
}
|
||||
|
||||
public abstract void onClick(InventoryClickEvent event);
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* the item to set
|
||||
*/
|
||||
public void setItem(ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lore
|
||||
* the lore to set
|
||||
*/
|
||||
public void setLore(String[] lore) {
|
||||
this.lore = Utils.getInstance().colorize(lore);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = Utils.getInstance().colorize(name);
|
||||
}
|
||||
|
||||
public void setSlot(int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,347 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
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.TabCompleter.AdminVoteTabCompleter;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.TabCompleter.VoteTabCompleter;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigBungeeVoting;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigGUI;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigTopVoterAwards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteReminding;
|
||||
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.Files.Files;
|
||||
import com.Ben12345rocks.VotingPlugin.Metrics.Metrics;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.Reward;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.UUID;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.Signs;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.Updater.CheckUpdate;
|
||||
import com.Ben12345rocks.VotingPlugin.Updater.Updater;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteReminding.VoteReminding;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
public static Config config;
|
||||
|
||||
public static ConfigOtherRewards configBonusReward;
|
||||
|
||||
public static ConfigGUI configGUI;
|
||||
|
||||
public static ConfigFormat configFormat;
|
||||
|
||||
public static ConfigVoteSites configVoteSites;
|
||||
|
||||
public static Main plugin;
|
||||
|
||||
public Economy econ = null;
|
||||
|
||||
public HashMap<User, Integer> topVoterMonthly;
|
||||
|
||||
public HashMap<User, Integer> topVoterWeekly;
|
||||
|
||||
public HashMap<User, Integer> topVoterDaily;
|
||||
|
||||
public Updater updater;
|
||||
|
||||
public ArrayList<CommandHandler> voteCommand;
|
||||
|
||||
public ArrayList<CommandHandler> adminVoteCommand;
|
||||
|
||||
public ArrayList<VoteSite> voteSites;
|
||||
|
||||
public HashMap<User, HashMap<VoteSite, Date>> voteToday;
|
||||
|
||||
public boolean placeHolderAPIEnabled;
|
||||
|
||||
public ArrayList<Reward> rewards;
|
||||
|
||||
public boolean spigotLibEnabled;
|
||||
|
||||
public ArrayList<SignHandler> signs;
|
||||
|
||||
public void checkPlaceHolderAPI() {
|
||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
placeHolderAPIEnabled = true;
|
||||
plugin.debug("PlaceholderAPI found, will attempt to parse placeholders");
|
||||
} else {
|
||||
placeHolderAPIEnabled = false;
|
||||
plugin.debug("PlaceholderAPI not found, PlaceholderAPI placeholders will not work");
|
||||
}
|
||||
}
|
||||
|
||||
public void checkSpigotLib() {
|
||||
if (Bukkit.getPluginManager().getPlugin("SpigotLib") != null) {
|
||||
spigotLibEnabled = true;
|
||||
plugin.debug("Found SpigotLib, will attempt to send titles");
|
||||
} else {
|
||||
spigotLibEnabled = false;
|
||||
plugin.debug("SpigotLib not found, titles will not send");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkVotifier() {
|
||||
if (getServer().getPluginManager().getPlugin("Votifier") == null) {
|
||||
plugin.debug("Votifier not found, votes may not work");
|
||||
}
|
||||
}
|
||||
|
||||
public void debug(String message) {
|
||||
if (config.getDebugEnabled()) {
|
||||
plugin.getLogger().info("Debug: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
public User getUser(String playerName) {
|
||||
return new User(playerName);
|
||||
}
|
||||
|
||||
public User getUser(UUID uuid) {
|
||||
return new User(uuid);
|
||||
}
|
||||
|
||||
public VoteSite getVoteSite(String siteName) {
|
||||
for (VoteSite voteSite : voteSites) {
|
||||
if (voteSite.getSiteName().equalsIgnoreCase(siteName)) {
|
||||
return voteSite;
|
||||
}
|
||||
}
|
||||
if (config.getAutoCreateVoteSites()) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
return new VoteSite(siteName);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadRewards() {
|
||||
ConfigRewards.getInstance().setupExample();
|
||||
rewards = new ArrayList<Reward>();
|
||||
for (String reward : ConfigRewards.getInstance().getRewardNames()) {
|
||||
rewards.add(new Reward(reward));
|
||||
}
|
||||
plugin.debug("Loaded rewards");
|
||||
|
||||
}
|
||||
|
||||
public void loadVoteSites() {
|
||||
configVoteSites.setup("ExampleVoteSite");
|
||||
voteSites = configVoteSites.getVoteSitesLoad();
|
||||
|
||||
plugin.debug("Loaded VoteSites");
|
||||
|
||||
}
|
||||
|
||||
private void metrics() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
plugin.debug("Loaded Metrics");
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info("Can't submit metrics stats");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Signs.getInstance().storeSigns();
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
Files.getInstance().loadFileEditngThread();
|
||||
setupFiles();
|
||||
registerCommands();
|
||||
registerEvents();
|
||||
if (setupEconomy()) {
|
||||
plugin.debug("Succesfully hooked into vault");
|
||||
} else {
|
||||
plugin.getLogger()
|
||||
.info("Failed to load vault, giving players money directy will not work");
|
||||
}
|
||||
checkVotifier();
|
||||
metrics();
|
||||
|
||||
CheckUpdate.getInstance().startUp();
|
||||
|
||||
checkPlaceHolderAPI();
|
||||
checkSpigotLib();
|
||||
|
||||
loadVoteSites();
|
||||
loadRewards();
|
||||
|
||||
VoteReminding.getInstance().loadRemindChecking();
|
||||
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().loadSigns();
|
||||
}
|
||||
});
|
||||
|
||||
topVoterMonthly = new HashMap<User, Integer>();
|
||||
topVoterWeekly = new HashMap<User, Integer>();
|
||||
topVoterDaily = new HashMap<User, Integer>();
|
||||
voteToday = new HashMap<User, HashMap<VoteSite, Date>>();
|
||||
|
||||
VoteParty.getInstance().check();
|
||||
|
||||
startTimer();
|
||||
plugin.getLogger().info(
|
||||
"Enabled VotingPlgin " + plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
plugin.debug("Loaded Commands");
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
plugin.debug("Loaded Events");
|
||||
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
config.reloadData();
|
||||
configGUI.reloadData();
|
||||
configFormat.reloadData();
|
||||
plugin.loadVoteSites();
|
||||
configBonusReward.reloadData();
|
||||
ConfigVoteReminding.getInstance().reloadData();
|
||||
plugin.setupFiles();
|
||||
loadRewards();
|
||||
ServerData.getInstance().reloadData();
|
||||
plugin.update();
|
||||
}
|
||||
|
||||
private boolean setupEconomy() {
|
||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||
return false;
|
||||
}
|
||||
RegisteredServiceProvider<Economy> rsp = getServer()
|
||||
.getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
econ = rsp.getProvider();
|
||||
return econ != null;
|
||||
}
|
||||
|
||||
public void setupFiles() {
|
||||
config = Config.getInstance();
|
||||
configVoteSites = ConfigVoteSites.getInstance();
|
||||
configFormat = ConfigFormat.getInstance();
|
||||
configBonusReward = ConfigOtherRewards.getInstance();
|
||||
configGUI = ConfigGUI.getInstance();
|
||||
|
||||
config.setup(this);
|
||||
configFormat.setup(this);
|
||||
configBonusReward.setup(this);
|
||||
configGUI.setup(plugin);
|
||||
ConfigVoteReminding.getInstance().setup(plugin);
|
||||
|
||||
ConfigBungeeVoting.getInstance().setup(plugin);
|
||||
|
||||
ServerData.getInstance().setup(plugin);
|
||||
|
||||
ConfigTopVoterAwards.getInstance().setup(plugin);
|
||||
|
||||
plugin.debug("Loaded Files");
|
||||
|
||||
}
|
||||
|
||||
public void startTimer() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin,
|
||||
new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
update();
|
||||
}
|
||||
}, 50, config.getBackgroundTaskDelay() * 20);
|
||||
|
||||
plugin.debug("Loaded timer for background task");
|
||||
|
||||
}
|
||||
|
||||
public void update() {
|
||||
try {
|
||||
TopVoter.getInstance().updateTopVoters();
|
||||
TopVoter.getInstance().checkTopVoterAward();
|
||||
|
||||
updater = new Updater(this, 15358, false);
|
||||
Commands.getInstance().updateVoteToday();
|
||||
ServerData.getInstance().updateValues();
|
||||
Signs.getInstance().updateSigns();
|
||||
ConfigRewards.getInstance().checkDelayedTimedRewards();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
new User(player).offVoteWorld(player.getWorld().getName());
|
||||
}
|
||||
plugin.debug("Background task ran");
|
||||
|
||||
} catch (Exception ex) {
|
||||
plugin.getLogger()
|
||||
.info("Looks like there are no data files or something went wrong.");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,616 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Metrics;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The metrics class obtains data about a plugin and submits statistics about it
|
||||
* to the metrics backend.
|
||||
* </p>
|
||||
* <p>
|
||||
* Public methods provided by this class:
|
||||
* </p>
|
||||
* <code>
|
||||
* Graph createGraph(String name); <br/>
|
||||
* void addCustomData(Metrics.Plotter plotter); <br/>
|
||||
* void start(); <br/>
|
||||
* </code>
|
||||
*/
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not
|
||||
* comply to the above when submitted, it is rejected
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<Plotter>();
|
||||
|
||||
private Graph(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void addPlotter(final Plotter plotter) {
|
||||
plotters.add(plotter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Graph graph = (Graph) object;
|
||||
return graph.name.equals(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void removePlotter(final Plotter plotter) {
|
||||
plotters.remove(plotter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public static abstract class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
public Plotter(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(name)
|
||||
&& (plotter.getValue() == getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode() + getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* The base url of the metrics domain
|
||||
*/
|
||||
private static final String BASE_URL = "http://mcstats.org";
|
||||
|
||||
/**
|
||||
* The file where guid and opt out is stored in
|
||||
*/
|
||||
private static final String CONFIG_FILE = "plugins/PluginMetrics/config.yml";
|
||||
|
||||
/**
|
||||
* The separator to use for custom data. This MUST NOT change unless you are
|
||||
* hosting your own version of metrics and want to change it.
|
||||
*/
|
||||
private static final String CUSTOM_DATA_SEPARATOR = "~~";
|
||||
|
||||
/**
|
||||
* Interval of time to ping (in minutes)
|
||||
*/
|
||||
private static final int PING_INTERVAL = 10;
|
||||
|
||||
/**
|
||||
* The url used to report a server's status
|
||||
*/
|
||||
private static final String REPORT_URL = "/report/%s";
|
||||
|
||||
/**
|
||||
* The current revision number
|
||||
*/
|
||||
private final static int REVISION = 5;
|
||||
|
||||
/**
|
||||
* Encode text as UTF-8
|
||||
*
|
||||
* @param text
|
||||
* @return
|
||||
*/
|
||||
private static String encode(final String text)
|
||||
throws UnsupportedEncodingException {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Encode a key/value data pair to be used in a HTTP post request. This
|
||||
* INCLUDES a & so the first key/value pair MUST be included manually, e.g:
|
||||
* </p>
|
||||
* <code>
|
||||
* StringBuffer data = new StringBuffer();
|
||||
* data.append(encode("guid")).append('=').append(encode(guid));
|
||||
* encodeDataPair(data, "version", description.getVersion());
|
||||
* </code>
|
||||
*
|
||||
* @param buffer
|
||||
* @param key
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private static void encodeDataPair(final StringBuilder buffer,
|
||||
final String key, final String value)
|
||||
throws UnsupportedEncodingException {
|
||||
buffer.append('&').append(encode(key)).append('=')
|
||||
.append(encode(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final YamlConfiguration configuration;
|
||||
|
||||
/**
|
||||
* The plugin configuration file
|
||||
*/
|
||||
private final File configurationFile;
|
||||
|
||||
/**
|
||||
* The default graph, used for addCustomData when you don't want a specific
|
||||
* graph
|
||||
*/
|
||||
private final Graph defaultGraph = new Graph("Default");
|
||||
|
||||
/**
|
||||
* All of the custom graphs to submit to metrics
|
||||
*/
|
||||
private final Set<Graph> graphs = Collections
|
||||
.synchronizedSet(new HashSet<Graph>());
|
||||
|
||||
/**
|
||||
* Unique server id
|
||||
*/
|
||||
private final String guid;
|
||||
|
||||
/**
|
||||
* Lock for synchronization
|
||||
*/
|
||||
private final Object optOutLock = new Object();
|
||||
|
||||
/**
|
||||
* The plugin this metrics submits for
|
||||
*/
|
||||
private final Plugin plugin;
|
||||
|
||||
/**
|
||||
* Id of the scheduled task
|
||||
*/
|
||||
private volatile int taskId = -1;
|
||||
|
||||
public Metrics(final Plugin plugin) throws IOException {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
|
||||
this.plugin = plugin;
|
||||
|
||||
// load the config
|
||||
configurationFile = new File(CONFIG_FILE);
|
||||
configuration = YamlConfiguration.loadConfiguration(configurationFile);
|
||||
|
||||
// add some defaults
|
||||
configuration.addDefault("opt-out", false);
|
||||
configuration.addDefault("guid", UUID.randomUUID().toString());
|
||||
|
||||
// Do we need to create the file?
|
||||
if (configuration.get("guid", null) == null) {
|
||||
configuration.options().header("http://mcstats.org")
|
||||
.copyDefaults(true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Load the guid then
|
||||
guid = configuration.getString("guid");
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a custom data plotter to the default graph
|
||||
*
|
||||
* @param plotter
|
||||
*/
|
||||
public void addCustomData(final Plotter plotter) {
|
||||
if (plotter == null) {
|
||||
throw new IllegalArgumentException("Plotter cannot be null");
|
||||
}
|
||||
|
||||
// Add the plotter to the graph o/
|
||||
defaultGraph.addPlotter(plotter);
|
||||
|
||||
// Ensure the default graph is included in the submitted graphs
|
||||
graphs.add(defaultGraph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific
|
||||
* plotters to their own graphs on the metrics website. Plotters can be
|
||||
* added to the graph object returned.
|
||||
*
|
||||
* @param name
|
||||
* @return Graph object created. Will never return NULL under normal
|
||||
* circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(final String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
|
||||
// Construct the graph object
|
||||
final Graph graph = new Graph(name);
|
||||
|
||||
// Now we can add our graph
|
||||
graphs.add(graph);
|
||||
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the
|
||||
* config file and canceling the metrics task.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void disable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the
|
||||
// task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set
|
||||
// it.
|
||||
if (!isOptOut()) {
|
||||
configuration.set("opt-out", true);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Disable Task, if it is running
|
||||
if (taskId > 0) {
|
||||
plugin.getServer().getScheduler().cancelTask(taskId);
|
||||
taskId = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the
|
||||
* config file and starting the metrics task.
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void enable() throws IOException {
|
||||
// This has to be synchronized or it can collide with the check in the
|
||||
// task.
|
||||
synchronized (optOutLock) {
|
||||
// Check if the server owner has already set opt-out, if not, set
|
||||
// it.
|
||||
if (isOptOut()) {
|
||||
configuration.set("opt-out", false);
|
||||
configuration.save(configurationFile);
|
||||
}
|
||||
|
||||
// Enable Task, if it is not running
|
||||
if (taskId < 0) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send
|
||||
* POST requests
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Has the server owner denied plugin metrics?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isOptOut() {
|
||||
synchronized (optOutLock) {
|
||||
try {
|
||||
// Reload the metrics file
|
||||
configuration.load(CONFIG_FILE);
|
||||
} catch (IOException ex) {
|
||||
|
||||
Main.plugin.debug("[Metrics] " + ex.getMessage());
|
||||
|
||||
return true;
|
||||
} catch (InvalidConfigurationException ex) {
|
||||
Main.plugin.debug("[Metrics] " + ex.getMessage());
|
||||
|
||||
return true;
|
||||
}
|
||||
return configuration.getBoolean("opt-out", false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website
|
||||
*/
|
||||
private void postPlugin(final boolean isPing) throws IOException {
|
||||
// The plugin's description file containg all of the plugin data such as
|
||||
// name, version, author, etc
|
||||
final PluginDescriptionFile description = plugin.getDescription();
|
||||
|
||||
// Construct the post data
|
||||
final StringBuilder data = new StringBuilder();
|
||||
data.append(encode("guid")).append('=').append(encode(guid));
|
||||
encodeDataPair(data, "version", description.getVersion());
|
||||
encodeDataPair(data, "server", Bukkit.getVersion());
|
||||
encodeDataPair(data, "players",
|
||||
Integer.toString(Bukkit.getServer().getOnlinePlayers().size()));
|
||||
encodeDataPair(data, "revision", String.valueOf(REVISION));
|
||||
|
||||
// If we're pinging, append it
|
||||
if (isPing) {
|
||||
encodeDataPair(data, "ping", "true");
|
||||
}
|
||||
|
||||
// Acquire a lock on the graphs, which lets us make the assumption we
|
||||
// also lock everything
|
||||
// inside of the graph (e.g plotters)
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
// The key name to send to the metrics server
|
||||
// The format is C-GRAPHNAME-PLOTTERNAME where separator -
|
||||
// is defined at the top
|
||||
// Legacy (R4) submitters use the format Custom%s, or
|
||||
// CustomPLOTTERNAME
|
||||
final String key = String.format("C%s%s%s%s",
|
||||
CUSTOM_DATA_SEPARATOR, graph.getName(),
|
||||
CUSTOM_DATA_SEPARATOR, plotter.getColumnName());
|
||||
|
||||
// The value to send, which for the foreseeable future is
|
||||
// just the string
|
||||
// value of plotter.getValue()
|
||||
final String value = Integer.toString(plotter.getValue());
|
||||
|
||||
// Add it to the http post data :)
|
||||
encodeDataPair(data, key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL
|
||||
+ String.format(REPORT_URL, encode(plugin.getDescription()
|
||||
.getName())));
|
||||
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
|
||||
connection.setDoOutput(true);
|
||||
|
||||
// Write the data
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(
|
||||
connection.getOutputStream());
|
||||
writer.write(data.toString());
|
||||
writer.flush();
|
||||
|
||||
// Now read the response
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
connection.getInputStream()));
|
||||
final String response = reader.readLine();
|
||||
|
||||
// close resources
|
||||
writer.close();
|
||||
reader.close();
|
||||
|
||||
if ((response == null) || response.startsWith("ERR")) {
|
||||
throw new IOException(response); // Throw the exception
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if (response.contains("OK This is your first update this hour")) {
|
||||
synchronized (graphs) {
|
||||
final Iterator<Graph> iter = graphs.iterator();
|
||||
|
||||
while (iter.hasNext()) {
|
||||
final Graph graph = iter.next();
|
||||
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async
|
||||
* repeating task as the plugin and send the initial data to the metrics
|
||||
* backend, and then after that it will post in increments of PING_INTERVAL
|
||||
* * 1200 ticks.
|
||||
*
|
||||
* @return True if statistics measuring is running, otherwise false.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean start() {
|
||||
synchronized (optOutLock) {
|
||||
// Did we opt out?
|
||||
if (isOptOut()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is metrics already running?
|
||||
if (taskId >= 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Begin hitting the server with glorious data
|
||||
taskId = plugin.getServer().getScheduler()
|
||||
.scheduleAsyncRepeatingTask(plugin, new Runnable() {
|
||||
|
||||
private boolean firstPost = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
// This has to be synchronized or it can collide
|
||||
// with the disable method.
|
||||
synchronized (optOutLock) {
|
||||
// Disable Task, if it is running and the
|
||||
// server owner decided to opt-out
|
||||
if (isOptOut() && (taskId > 0)) {
|
||||
plugin.getServer().getScheduler()
|
||||
.cancelTask(taskId);
|
||||
taskId = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// We use the inverse of firstPost because if it
|
||||
// is the first time we are posting,
|
||||
// it is not a interval ping, so it evaluates to
|
||||
// FALSE
|
||||
// Each time thereafter it will evaluate to
|
||||
// TRUE, i.e PING!
|
||||
postPlugin(!firstPost);
|
||||
|
||||
// After the first post we set firstPost to
|
||||
// false
|
||||
// Each post thereafter will be a ping
|
||||
firstPost = false;
|
||||
} catch (IOException e) {
|
||||
|
||||
Main.plugin.debug("[Metrics] " + e.getMessage());
|
||||
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,181 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
|
||||
public abstract class CommandHandler {
|
||||
static Main plugin = Main.plugin;
|
||||
private String[] args;
|
||||
private String perm;
|
||||
private String helpMessage;
|
||||
|
||||
public CommandHandler(String[] args, String perm) {
|
||||
this.args = args;
|
||||
this.perm = perm;
|
||||
helpMessage = "Unknown Help Message";
|
||||
}
|
||||
|
||||
public CommandHandler(String[] args, String perm, String helpMessage) {
|
||||
this.args = args;
|
||||
this.perm = perm;
|
||||
this.helpMessage = helpMessage;
|
||||
}
|
||||
|
||||
public boolean argsMatch(String arg, int i) {
|
||||
if (i < args.length) {
|
||||
String[] cmdArgs = args[i].split("&");
|
||||
for (String cmdArg : cmdArgs) {
|
||||
if (cmdArg.equalsIgnoreCase("(player)")
|
||||
|| cmdArg.equalsIgnoreCase("(SITENAME)")
|
||||
|| cmdArg.equalsIgnoreCase("(reward)")
|
||||
|| cmdArg.equalsIgnoreCase("(number)")
|
||||
|| cmdArg.equalsIgnoreCase("(string)")
|
||||
|| cmdArg.equalsIgnoreCase("(boolean)")
|
||||
|| cmdArg.equalsIgnoreCase("(list)")
|
||||
|| arg.equalsIgnoreCase(cmdArg)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* if (args[i].split("|").length <= 1) { if
|
||||
* (args[i].equalsIgnoreCase("player") ||
|
||||
* args[i].equalsIgnoreCase("SITENAME") ||
|
||||
* args[i].equalsIgnoreCase("number") ||
|
||||
* args[i].equalsIgnoreCase("string") ||
|
||||
* args[i].equalsIgnoreCase("boolean") ||
|
||||
* args[i].equalsIgnoreCase("list") ||
|
||||
* arg.equalsIgnoreCase(args[i])) { return true; } } else {
|
||||
*
|
||||
* }
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract void execute(CommandSender sender, String[] args);
|
||||
|
||||
public String[] getArgs() {
|
||||
return args;
|
||||
}
|
||||
|
||||
public TextComponent getHelpLine(String command) {
|
||||
String line = ConfigFormat.getInstance().getCommandsVoteHelpLine();
|
||||
|
||||
String commandText = getHelpLineCommand(command);
|
||||
line = line.replace("%Command%", commandText);
|
||||
if (getHelpMessage() != "") {
|
||||
line = line.replace("%HelpMessage%", getHelpMessage());
|
||||
}
|
||||
TextComponent txt = Utils.getInstance().stringToComp(line);
|
||||
txt.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND,
|
||||
commandText));
|
||||
txt.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(getHelpMessage()).color(ChatColor.AQUA)
|
||||
.create()));
|
||||
return txt;
|
||||
|
||||
}
|
||||
|
||||
public String getHelpLineCommand(String command) {
|
||||
String commandText = command;
|
||||
for (String arg1 : args) {
|
||||
int count = 1;
|
||||
for (String arg : arg1.split("&")) {
|
||||
if (count == 1) {
|
||||
if (arg.equalsIgnoreCase("(player)")) {
|
||||
commandText += " (Player)";
|
||||
} else if (arg.equalsIgnoreCase("(sitename)")) {
|
||||
commandText += " (SiteName)";
|
||||
} else if (arg.equalsIgnoreCase("(reward)")) {
|
||||
commandText += " (Reward)";
|
||||
} else if (arg.equalsIgnoreCase("(boolean)")) {
|
||||
commandText += " (True/False)";
|
||||
} else if (arg.equalsIgnoreCase("(number)")) {
|
||||
commandText += " (Number)";
|
||||
} else if (arg.equalsIgnoreCase("(string)")) {
|
||||
commandText += " (Text)";
|
||||
} else {
|
||||
commandText += " " + arg;
|
||||
}
|
||||
} else {
|
||||
if (arg.equalsIgnoreCase("(player)")) {
|
||||
commandText += "/(Player)";
|
||||
} else if (arg.equalsIgnoreCase("(sitename)")) {
|
||||
commandText += "/(SiteName)";
|
||||
} else if (arg.equalsIgnoreCase("(reward)")) {
|
||||
commandText += "/(Reward)";
|
||||
} else if (arg.equalsIgnoreCase("(boolean)")) {
|
||||
commandText += "/(True/False)";
|
||||
} else if (arg.equalsIgnoreCase("(number)")) {
|
||||
commandText += "/(Number)";
|
||||
} else if (arg.equalsIgnoreCase("(string)")) {
|
||||
commandText += "/(Text)";
|
||||
} else {
|
||||
commandText += "/" + arg;
|
||||
}
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return commandText;
|
||||
}
|
||||
|
||||
public String getHelpMessage() {
|
||||
return helpMessage;
|
||||
}
|
||||
|
||||
public String getPerm() {
|
||||
return perm;
|
||||
}
|
||||
|
||||
public boolean runCommand(CommandSender sender, String[] args) {
|
||||
if (args.length >= this.args.length) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (!argsMatch(args[i], i)) {
|
||||
return false;
|
||||
}
|
||||
if (this.args[i].equalsIgnoreCase("(number)")) {
|
||||
if (!Utils.getInstance().isInt(args[i])) {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
ConfigFormat.getInstance().getNotNumber()
|
||||
.replace("%arg%", args[i])));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (perm != "") {
|
||||
if (!sender.hasPermission(perm)) {
|
||||
sender.sendMessage(Utils.getInstance().colorize(
|
||||
ConfigFormat.getInstance().getNoPerms()));
|
||||
plugin.debug(sender.getName()
|
||||
+ " was denied access to command");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
execute(sender, args);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setHelpMessage(String helpMessage) {
|
||||
this.helpMessage = helpMessage;
|
||||
}
|
||||
|
||||
public void setPerm(String perm) {
|
||||
this.perm = perm;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,772 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
|
||||
public class Reward {
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public String name;
|
||||
|
||||
private boolean delayEnabled;
|
||||
private int delayHours;
|
||||
private int delayMinutes;
|
||||
|
||||
private boolean timedEnabled;
|
||||
private int timedHour;
|
||||
private int timedMinute;
|
||||
|
||||
private double chance;
|
||||
|
||||
private double randomChance;
|
||||
|
||||
private ArrayList<String> randomRewards;
|
||||
|
||||
private ArrayList<String> randomFallBack;
|
||||
|
||||
private boolean requirePermission;
|
||||
|
||||
private ArrayList<String> worlds;
|
||||
|
||||
private boolean giveInEachWorld;
|
||||
|
||||
private Set<String> items;
|
||||
|
||||
private HashMap<String, String> itemMaterial;
|
||||
private HashMap<String, String> itemSkull;
|
||||
|
||||
private HashMap<String, Integer> itemData;
|
||||
|
||||
private HashMap<String, Integer> itemDurabilty;
|
||||
|
||||
private HashMap<String, Integer> itemAmount;
|
||||
|
||||
private HashMap<String, Integer> itemMinAmount;
|
||||
private HashMap<String, Integer> itemMaxAmount;
|
||||
private HashMap<String, String> itemName;
|
||||
private HashMap<String, ArrayList<String>> itemLore;
|
||||
|
||||
private HashMap<String, HashMap<String, Integer>> itemEnchants;
|
||||
|
||||
private int money;
|
||||
|
||||
private int MinMoney;
|
||||
|
||||
private int MaxMoney;
|
||||
|
||||
private int exp;
|
||||
|
||||
private ArrayList<String> consoleCommands;
|
||||
private ArrayList<String> playerCommands;
|
||||
|
||||
private Set<String> potions;
|
||||
private HashMap<String, Integer> potionsDuration;
|
||||
private HashMap<String, Integer> potionsAmplifier;
|
||||
|
||||
private String rewardMsg;
|
||||
|
||||
public Reward(Main plugin) {
|
||||
Reward.plugin = plugin;
|
||||
}
|
||||
|
||||
public Reward(String reward) {
|
||||
name = reward;
|
||||
|
||||
setDelayEnabled(ConfigRewards.getInstance().getDelayedEnabled(reward));
|
||||
setDelayHours(ConfigRewards.getInstance().getDelayedHours(reward));
|
||||
setDelayMinutes(ConfigRewards.getInstance().getDelayedMinutes(reward));
|
||||
|
||||
setTimedEnabled(ConfigRewards.getInstance().getTimedEnabled(reward));
|
||||
setTimedHour(ConfigRewards.getInstance().getTimedHour(reward));
|
||||
setTimedMinute(ConfigRewards.getInstance().getTimedMinute(reward));
|
||||
|
||||
setChance(ConfigRewards.getInstance().getChance(reward));
|
||||
setRandomChance(ConfigRewards.getInstance().getRandomChance(reward));
|
||||
setRandomRewards(ConfigRewards.getInstance().getRandomRewards(reward));
|
||||
setRandomFallBack(ConfigRewards.getInstance().getRandomFallBack(reward));
|
||||
|
||||
setRequirePermission(ConfigRewards.getInstance().getRequirePermission(
|
||||
reward));
|
||||
setWorlds(ConfigRewards.getInstance().getWorlds(reward));
|
||||
setGiveInEachWorld(ConfigRewards.getInstance().getGiveInEachWorld(
|
||||
reward));
|
||||
|
||||
setItems(ConfigRewards.getInstance().getItems(reward));
|
||||
itemMaterial = new HashMap<String, String>();
|
||||
itemData = new HashMap<String, Integer>();
|
||||
itemSkull = new HashMap<String, String>();
|
||||
itemDurabilty = new HashMap<String, Integer>();
|
||||
itemAmount = new HashMap<String, Integer>();
|
||||
itemMinAmount = new HashMap<String, Integer>();
|
||||
itemMaxAmount = new HashMap<String, Integer>();
|
||||
itemName = new HashMap<String, String>();
|
||||
itemLore = new HashMap<String, ArrayList<String>>();
|
||||
itemName = new HashMap<String, String>();
|
||||
itemEnchants = new HashMap<String, HashMap<String, Integer>>();
|
||||
for (String item : ConfigRewards.getInstance().getItems(reward)) {
|
||||
itemMaterial.put(item,
|
||||
ConfigRewards.getInstance().getItemMaterial(reward, item));
|
||||
itemData.put(item,
|
||||
ConfigRewards.getInstance().getItemData(reward, item));
|
||||
itemAmount.put(item,
|
||||
ConfigRewards.getInstance().getItemAmount(reward, item));
|
||||
itemMinAmount.put(item, ConfigRewards.getInstance()
|
||||
.getItemMinAmount(reward, item));
|
||||
itemMaxAmount.put(item, ConfigRewards.getInstance()
|
||||
.getItemMaxAmount(reward, item));
|
||||
itemName.put(item,
|
||||
ConfigRewards.getInstance().getItemName(reward, item));
|
||||
itemLore.put(item,
|
||||
ConfigRewards.getInstance().getItemLore(reward, item));
|
||||
itemDurabilty.put(item, ConfigRewards.getInstance()
|
||||
.getItemDurability(reward, item));
|
||||
itemSkull.put(item,
|
||||
ConfigRewards.getInstance().getItemSkull(reward, item));
|
||||
HashMap<String, Integer> enchants = new HashMap<String, Integer>();
|
||||
for (String enchant : ConfigRewards.getInstance().getItemEnchants(
|
||||
reward, item)) {
|
||||
enchants.put(enchant, ConfigRewards.getInstance()
|
||||
.getItemEnchantsLevel(reward, item, enchant));
|
||||
|
||||
}
|
||||
itemEnchants.put(item, enchants);
|
||||
}
|
||||
|
||||
setMoney(ConfigRewards.getInstance().getMoney(reward));
|
||||
setMinMoney(ConfigRewards.getInstance().getMinMoney(reward));
|
||||
setMaxMoney(ConfigRewards.getInstance().getMaxMoney(reward));
|
||||
|
||||
setExp(ConfigRewards.getInstance().getEXP(reward));
|
||||
|
||||
setConsoleCommands(ConfigRewards.getInstance().getCommandsConsole(
|
||||
reward));
|
||||
setPlayerCommands(ConfigRewards.getInstance().getCommandsPlayer(reward));
|
||||
|
||||
potions = ConfigRewards.getInstance().getPotions(reward);
|
||||
potionsDuration = new HashMap<String, Integer>();
|
||||
potionsAmplifier = new HashMap<String, Integer>();
|
||||
for (String potion : potions) {
|
||||
potionsDuration.put(potion, ConfigRewards.getInstance()
|
||||
.getPotionsDuration(reward, potion));
|
||||
potionsAmplifier.put(potion, ConfigRewards.getInstance()
|
||||
.getPotionsAmplifier(reward, potion));
|
||||
}
|
||||
|
||||
setRewardMsg(ConfigRewards.getInstance().getMessagesReward(reward));
|
||||
|
||||
}
|
||||
|
||||
public boolean checkChance() {
|
||||
double chance = getChance();
|
||||
|
||||
if ((chance == 0) || (chance == 100)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
double randomNum = (Math.random() * 100) + 1;
|
||||
|
||||
plugin.debug("Random: " + randomNum + ", Chance: " + chance);
|
||||
|
||||
if (randomNum <= chance) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkDelayed(User user) {
|
||||
if (!isDelayEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Date time = new Date();
|
||||
time = DateUtils.addHours(time, getDelayHours());
|
||||
time = DateUtils.addMinutes(time, getDelayMinutes());
|
||||
user.setTimedReward(this, time.getTime());
|
||||
|
||||
plugin.debug("Giving reward " + name + " in " + getDelayHours()
|
||||
+ " hours " + getDelayMinutes() + " minutes ("
|
||||
+ time.toString() + ")");
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
public boolean checkRandomChance() {
|
||||
double chance = getRandomChance();
|
||||
|
||||
if ((chance == 0) || (chance == 100)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
double randomNum = (Math.random() * 100) + 1;
|
||||
|
||||
plugin.debug("Random: Random: " + randomNum + ", Chance: " + chance);
|
||||
|
||||
if (randomNum <= chance) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean checkTimed(User user) {
|
||||
if (!isTimedEnabled()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Date time = new Date();
|
||||
time.setHours(getTimedHour());
|
||||
time.setMinutes(getTimedMinute());
|
||||
if (new Date().after(time)) {
|
||||
time = DateUtils.addDays(time, 1);
|
||||
}
|
||||
user.setTimedReward(this, time.getTime());
|
||||
|
||||
plugin.debug("Giving reward " + name + " at " + time.toString());
|
||||
return true;
|
||||
}
|
||||
|
||||
public double getChance() {
|
||||
return chance;
|
||||
}
|
||||
|
||||
public ArrayList<String> getConsoleCommands() {
|
||||
return consoleCommands;
|
||||
}
|
||||
|
||||
public int getDelayHours() {
|
||||
return delayHours;
|
||||
}
|
||||
|
||||
public int getDelayMinutes() {
|
||||
return delayMinutes;
|
||||
}
|
||||
|
||||
public int getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getItemAmount() {
|
||||
return itemAmount;
|
||||
}
|
||||
|
||||
public int getItemAmount(String item) {
|
||||
int amount = getItemAmount().get(item);
|
||||
int maxAmount = getItemMaxAmount().get(item);
|
||||
int minAmount = getItemMinAmount().get(item);
|
||||
if ((maxAmount == 0) && (minAmount == 0)) {
|
||||
return amount;
|
||||
} else {
|
||||
int num = (int) (Math.random() * maxAmount);
|
||||
num++;
|
||||
if (num < minAmount) {
|
||||
num = minAmount;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getItemData() {
|
||||
return itemData;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getItemDurabilty() {
|
||||
return itemDurabilty;
|
||||
}
|
||||
|
||||
public HashMap<String, HashMap<String, Integer>> getItemEnchants() {
|
||||
return itemEnchants;
|
||||
}
|
||||
|
||||
public HashMap<String, ArrayList<String>> getItemLore() {
|
||||
return itemLore;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getItemMaterial() {
|
||||
return itemMaterial;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getItemMaxAmount() {
|
||||
return itemMaxAmount;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getItemMinAmount() {
|
||||
return itemMinAmount;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getItemName() {
|
||||
return itemName;
|
||||
}
|
||||
|
||||
public Set<String> getItems() {
|
||||
return items;
|
||||
}
|
||||
|
||||
public HashMap<String, String> getItemSkull() {
|
||||
return itemSkull;
|
||||
}
|
||||
|
||||
public int getMaxMoney() {
|
||||
return MaxMoney;
|
||||
}
|
||||
|
||||
public int getMinMoney() {
|
||||
return MinMoney;
|
||||
}
|
||||
|
||||
public int getMoney() {
|
||||
return money;
|
||||
}
|
||||
|
||||
public int getMoneyToGive() {
|
||||
int amount = getMoney();
|
||||
int maxAmount = getMaxMoney();
|
||||
int minAmount = getMinMoney();
|
||||
if ((maxAmount == 0) && (minAmount == 0)) {
|
||||
return amount;
|
||||
} else {
|
||||
int num = (int) (Math.random() * maxAmount);
|
||||
num++;
|
||||
if (num < minAmount) {
|
||||
num = minAmount;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getPlayerCommands() {
|
||||
return playerCommands;
|
||||
}
|
||||
|
||||
public Set<String> getPotions() {
|
||||
return potions;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getPotionsAmplifier() {
|
||||
return potionsAmplifier;
|
||||
}
|
||||
|
||||
public HashMap<String, Integer> getPotionsDuration() {
|
||||
return potionsDuration;
|
||||
}
|
||||
|
||||
public double getRandomChance() {
|
||||
return randomChance;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRandomFallBack() {
|
||||
return randomFallBack;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRandomRewards() {
|
||||
return randomRewards;
|
||||
}
|
||||
|
||||
public String getRewardMsg() {
|
||||
return rewardMsg;
|
||||
}
|
||||
|
||||
public String getRewardName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getTimedHour() {
|
||||
return timedHour;
|
||||
}
|
||||
|
||||
public int getTimedMinute() {
|
||||
return timedMinute;
|
||||
}
|
||||
|
||||
public ArrayList<String> getWorlds() {
|
||||
return worlds;
|
||||
}
|
||||
|
||||
public void giveExp(User user) {
|
||||
user.giveExp(getExp());
|
||||
}
|
||||
|
||||
public void giveItems(User user) {
|
||||
for (String item : getItems()) {
|
||||
ItemStack itemStack = new ItemStack(
|
||||
Material.valueOf(getItemMaterial().get(item)),
|
||||
getItemAmount(item), Short.valueOf(Integer
|
||||
.toString(getItemData().get(item))));
|
||||
String name = getItemName().get(item);
|
||||
if (name != null) {
|
||||
itemStack = Utils.getInstance().nameItem(itemStack,
|
||||
name.replace("%Player%", user.getPlayerName()));
|
||||
}
|
||||
itemStack = Utils.getInstance().addLore(
|
||||
itemStack,
|
||||
Utils.getInstance().replace(getItemLore().get(item),
|
||||
"%Player%", user.getPlayerName()));
|
||||
itemStack = Utils.getInstance().addEnchants(itemStack,
|
||||
getItemEnchants().get(item));
|
||||
itemStack = Utils.getInstance().setDurabilty(itemStack,
|
||||
getItemDurabilty().get(item));
|
||||
String skull = getItemSkull().get(item);
|
||||
if (skull != null) {
|
||||
itemStack = Utils.getInstance().setSkullOwner(itemStack,
|
||||
skull.replace("%Player%", user.getPlayerName()));
|
||||
}
|
||||
user.giveItem(itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveMoney(User user) {
|
||||
user.giveMoney(getMoneyToGive());
|
||||
}
|
||||
|
||||
public void givePotions(User user) {
|
||||
for (String potionName : getPotions()) {
|
||||
user.givePotionEffect(potionName,
|
||||
getPotionsDuration().get(potionName), getPotionsAmplifier()
|
||||
.get(potionName));
|
||||
}
|
||||
}
|
||||
|
||||
public void giveRandom(User user) {
|
||||
if (checkRandomChance()) {
|
||||
ArrayList<String> rewards = getRandomRewards();
|
||||
if (rewards != null) {
|
||||
if (rewards.size() > 0) {
|
||||
String reward = rewards.get((int) Math.random()
|
||||
* rewards.size());
|
||||
if (reward.equalsIgnoreCase("")) {
|
||||
user.giveReward(ConfigRewards.getInstance().getReward(
|
||||
reward));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (String reward : getRandomFallBack()) {
|
||||
if (reward.equalsIgnoreCase("")) {
|
||||
user.giveReward(ConfigRewards.getInstance().getReward(
|
||||
reward));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveReward(User user) {
|
||||
|
||||
if (checkDelayed(user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkTimed(user)) {
|
||||
return;
|
||||
}
|
||||
|
||||
giveRewardReward(user);
|
||||
}
|
||||
|
||||
public void giveRewardReward(User user) {
|
||||
plugin.debug("Attempting to give " + user.getPlayerName() + " reward "
|
||||
+ name);
|
||||
|
||||
if (checkChance()) {
|
||||
ArrayList<String> worlds = getWorlds();
|
||||
Player player = Bukkit.getPlayer(user.getPlayerName());
|
||||
if ((player != null) && (worlds != null)) {
|
||||
if (isGiveInEachWorld()) {
|
||||
for (String world : worlds) {
|
||||
if (player.getWorld().getName().equals(world)) {
|
||||
giveRewardUser(user);
|
||||
} else {
|
||||
Data.getInstance().setOfflineVotesSiteWorld(
|
||||
user,
|
||||
name,
|
||||
world,
|
||||
Data.getInstance()
|
||||
.getOfflineVotesSiteWorld(user,
|
||||
name, world) + 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (worlds.contains(player.getWorld().getName())) {
|
||||
giveRewardUser(user);
|
||||
} else {
|
||||
Data.getInstance().setOfflineVotesSiteWorld(
|
||||
user,
|
||||
name,
|
||||
null,
|
||||
Data.getInstance().getOfflineVotesSiteWorld(
|
||||
user, name, null) + 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
giveRewardUser(user);
|
||||
}
|
||||
}
|
||||
giveRandom(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give the user rewards
|
||||
*
|
||||
* @param user
|
||||
* User to give rewards to
|
||||
*/
|
||||
public void giveRewardUser(User user) {
|
||||
Player player = Bukkit.getPlayer(user.getPlayerName());
|
||||
if (player != null) {
|
||||
if (!isRequirePermission()
|
||||
|| player.hasPermission("VotingPlugin.Reward." + name)) {
|
||||
giveMoney(user);
|
||||
giveItems(user);
|
||||
giveExp(user);
|
||||
runCommands(user);
|
||||
givePotions(user);
|
||||
sendMessage(user);
|
||||
sendTitle(user);
|
||||
playSound(user);
|
||||
playEffect(user);
|
||||
|
||||
plugin.debug("Gave " + user.getPlayerName() + " reward " + name);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDelayEnabled() {
|
||||
return delayEnabled;
|
||||
}
|
||||
|
||||
public boolean isGiveInEachWorld() {
|
||||
return giveInEachWorld;
|
||||
}
|
||||
|
||||
public boolean isRequirePermission() {
|
||||
return requirePermission;
|
||||
}
|
||||
|
||||
public boolean isTimedEnabled() {
|
||||
return timedEnabled;
|
||||
}
|
||||
|
||||
public void playEffect(User user) {
|
||||
if (ConfigRewards.getInstance().getEffectEnabled(name)) {
|
||||
user.playParticleEffect(ConfigRewards.getInstance()
|
||||
.getEffectEffect(name), ConfigRewards.getInstance()
|
||||
.getEffectData(name), ConfigRewards.getInstance()
|
||||
.getEffectParticles(name), ConfigRewards.getInstance()
|
||||
.getEffectRadius(name));
|
||||
}
|
||||
}
|
||||
|
||||
public void playSound(User user) {
|
||||
if (ConfigRewards.getInstance().getSoundEnabled(name)) {
|
||||
try {
|
||||
user.playSound(ConfigRewards.getInstance().getSoundSound(name),
|
||||
ConfigRewards.getInstance().getSoundVolume(name),
|
||||
ConfigRewards.getInstance().getSoundPitch(name));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void runCommands(User user) {
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
// Console commands
|
||||
ArrayList<String> consolecmds = getConsoleCommands();
|
||||
|
||||
if (consolecmds != null) {
|
||||
for (String consolecmd : consolecmds) {
|
||||
if (consolecmd.length() > 0) {
|
||||
consolecmd = consolecmd.replace("%player%", playerName);
|
||||
Bukkit.getServer().dispatchCommand(
|
||||
Bukkit.getConsoleSender(), consolecmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Player commands
|
||||
ArrayList<String> playercmds = getPlayerCommands();
|
||||
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (playercmds != null) {
|
||||
for (String playercmd : playercmds) {
|
||||
if ((player != null) && (playercmd.length() > 0)) {
|
||||
playercmd = playercmd.replace("%player%", playerName);
|
||||
player.performCommand(playercmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendMessage(User user) {
|
||||
if (rewardMsg != null) {
|
||||
user.sendMessage(rewardMsg);
|
||||
} else {
|
||||
user.sendMessage(ConfigFormat.getInstance().getRewardMsg());
|
||||
}
|
||||
}
|
||||
|
||||
public void sendTitle(User user) {
|
||||
if (ConfigRewards.getInstance().getTitleEnabled(name)) {
|
||||
user.sendTitle(ConfigRewards.getInstance().getTitleTitle(name),
|
||||
|
||||
ConfigRewards.getInstance().getTitleSubTitle(name),
|
||||
|
||||
ConfigRewards.getInstance().getTitleFadeIn(name), ConfigRewards
|
||||
.getInstance().getTitleShowTime(name), ConfigRewards
|
||||
.getInstance().getTitleFadeOut(name));
|
||||
}
|
||||
}
|
||||
|
||||
public void setChance(double chance) {
|
||||
this.chance = chance;
|
||||
}
|
||||
|
||||
public void setConsoleCommands(ArrayList<String> consoleCommands) {
|
||||
this.consoleCommands = consoleCommands;
|
||||
}
|
||||
|
||||
public void setDelayEnabled(boolean delayEnabled) {
|
||||
this.delayEnabled = delayEnabled;
|
||||
}
|
||||
|
||||
public void setDelayHours(int delayHours) {
|
||||
this.delayHours = delayHours;
|
||||
}
|
||||
|
||||
public void setDelayMinutes(int delayMinutes) {
|
||||
this.delayMinutes = delayMinutes;
|
||||
}
|
||||
|
||||
public void setExp(int exp) {
|
||||
this.exp = exp;
|
||||
}
|
||||
|
||||
public void setGiveInEachWorld(boolean giveInEachWorld) {
|
||||
this.giveInEachWorld = giveInEachWorld;
|
||||
}
|
||||
|
||||
public void setItemAmount(HashMap<String, Integer> itemAmount) {
|
||||
this.itemAmount = itemAmount;
|
||||
}
|
||||
|
||||
public void setItemData(HashMap<String, Integer> itemData) {
|
||||
this.itemData = itemData;
|
||||
}
|
||||
|
||||
public void setItemDurabilty(HashMap<String, Integer> itemDurabilty) {
|
||||
this.itemDurabilty = itemDurabilty;
|
||||
}
|
||||
|
||||
public void setItemEnchants(
|
||||
HashMap<String, HashMap<String, Integer>> itemEnchants) {
|
||||
this.itemEnchants = itemEnchants;
|
||||
}
|
||||
|
||||
public void setItemLore(HashMap<String, ArrayList<String>> itemLore) {
|
||||
this.itemLore = itemLore;
|
||||
}
|
||||
|
||||
public void setItemMaterial(HashMap<String, String> itemMaterial) {
|
||||
this.itemMaterial = itemMaterial;
|
||||
}
|
||||
|
||||
public void setItemMaxAmount(HashMap<String, Integer> itemMaxAmount) {
|
||||
this.itemMaxAmount = itemMaxAmount;
|
||||
}
|
||||
|
||||
public void setItemMinAmount(HashMap<String, Integer> itemMinAmount) {
|
||||
this.itemMinAmount = itemMinAmount;
|
||||
}
|
||||
|
||||
public void setItemName(HashMap<String, String> itemName) {
|
||||
this.itemName = itemName;
|
||||
}
|
||||
|
||||
public void setItems(Set<String> items) {
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public void setItemSkull(HashMap<String, String> itemSkull) {
|
||||
this.itemSkull = itemSkull;
|
||||
}
|
||||
|
||||
public void setMaxMoney(int maxMoney) {
|
||||
MaxMoney = maxMoney;
|
||||
}
|
||||
|
||||
public void setMinMoney(int minMoney) {
|
||||
MinMoney = minMoney;
|
||||
}
|
||||
|
||||
public void setMoney(int money) {
|
||||
this.money = money;
|
||||
}
|
||||
|
||||
public void setPlayerCommands(ArrayList<String> playerCommands) {
|
||||
this.playerCommands = playerCommands;
|
||||
}
|
||||
|
||||
public void setPotions(Set<String> potions) {
|
||||
this.potions = potions;
|
||||
}
|
||||
|
||||
public void setPotionsAmplifier(HashMap<String, Integer> potionsAmplifier) {
|
||||
this.potionsAmplifier = potionsAmplifier;
|
||||
}
|
||||
|
||||
public void setPotionsDuration(HashMap<String, Integer> potionsDuration) {
|
||||
this.potionsDuration = potionsDuration;
|
||||
}
|
||||
|
||||
public void setRandomChance(double randomChance) {
|
||||
this.randomChance = randomChance;
|
||||
}
|
||||
|
||||
public void setRandomFallBack(ArrayList<String> randomFallBack) {
|
||||
this.randomFallBack = randomFallBack;
|
||||
}
|
||||
|
||||
public void setRandomRewards(ArrayList<String> randomRewards) {
|
||||
this.randomRewards = randomRewards;
|
||||
}
|
||||
|
||||
public void setRequirePermission(boolean requirePermission) {
|
||||
this.requirePermission = requirePermission;
|
||||
}
|
||||
|
||||
public void setRewardMsg(String rewardMsg) {
|
||||
this.rewardMsg = rewardMsg;
|
||||
}
|
||||
|
||||
public void setTimedEnabled(boolean timedEnabled) {
|
||||
this.timedEnabled = timedEnabled;
|
||||
}
|
||||
|
||||
public void setTimedHour(int timedHour) {
|
||||
this.timedHour = timedHour;
|
||||
}
|
||||
|
||||
public void setTimedMinute(int timedMinute) {
|
||||
this.timedMinute = timedMinute;
|
||||
}
|
||||
|
||||
public void setWorlds(ArrayList<String> worlds) {
|
||||
this.worlds = worlds;
|
||||
}
|
||||
}
|
||||
@@ -1,245 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
public class SignHandler {
|
||||
private String sign;
|
||||
private Location location;
|
||||
private String data;
|
||||
private ArrayList<String> lines;
|
||||
private int position;
|
||||
public Main plugin = Main.plugin;
|
||||
private String playerName;
|
||||
private int votes;
|
||||
private boolean isValid;
|
||||
|
||||
public SignHandler(String sign, Location location, String data, int position) {
|
||||
setSign(sign);
|
||||
setLocation(location);
|
||||
setData(data);
|
||||
this.position = position;
|
||||
setValid(true);
|
||||
lines = new ArrayList<String>();
|
||||
checkValidSign();
|
||||
playerName = "";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void checkSkulls() {
|
||||
Location loc = location;
|
||||
Location loc1 = new Location(loc.getWorld(), loc.getBlockX() - 1,
|
||||
loc.getBlockY() - 1, loc.getBlockZ() - 1);
|
||||
Location loc2 = new Location(loc.getWorld(), loc.getBlockX() + 1,
|
||||
loc.getBlockY() + 1, loc.getBlockZ() + 1);
|
||||
for (Block block : Utils.getInstance().getRegionBlocks(loc.getWorld(),
|
||||
loc1, loc2)) {
|
||||
if (block.getState() instanceof Skull) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkValidSign() {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setValid(getLocation().getBlock().getState() instanceof Sign);
|
||||
} catch (Exception ex) {
|
||||
setValid(false);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public String getRightClickMessage() {
|
||||
String msg = ConfigFormat.getInstance()
|
||||
.getSignTopVoterSignRightClickMessage();
|
||||
msg = msg.replace("%player%", playerName);
|
||||
msg = msg.replace("%position%", "" + position);
|
||||
msg = msg.replace("%votes%", "" + votes);
|
||||
msg = msg.replace("%SiteName%", data);
|
||||
return msg;
|
||||
}
|
||||
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
public boolean isLocationSame(Location loc) {
|
||||
return loc.equals(getLocation());
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
public void removeSign() {
|
||||
ServerData.getInstance().removeSign(sign);
|
||||
}
|
||||
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
public void setValid(boolean isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
public void storeSign() {
|
||||
ServerData.getInstance().setSign(sign, location, data, position);
|
||||
}
|
||||
|
||||
public void updateLines() {
|
||||
lines = new ArrayList<String>();
|
||||
checkValidSign();
|
||||
if (position != 0) {
|
||||
String line1 = ConfigFormat.getInstance()
|
||||
.getSignTopVoterSignLine1();
|
||||
String line2 = ConfigFormat.getInstance()
|
||||
.getSignTopVoterSignLine2();
|
||||
String line3 = ConfigFormat.getInstance()
|
||||
.getSignTopVoterSignLine3();
|
||||
String line4 = ConfigFormat.getInstance()
|
||||
.getSignTopVoterSignLine4();
|
||||
lines.add(line1);
|
||||
lines.add(line2);
|
||||
lines.add(line3);
|
||||
lines.add(line4);
|
||||
|
||||
if (data.equalsIgnoreCase("All")) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterMonthly.keySet());
|
||||
|
||||
if (users.size() >= position) {
|
||||
playerName = users.get(position - 1).getPlayerName();
|
||||
votes = users.get(position - 1).getTotalVotes();
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
lines.set(j,
|
||||
lines.get(j).replace("%votes%", "" + votes)
|
||||
.replace("%player%", playerName));
|
||||
}
|
||||
} else {
|
||||
playerName = "No Player";
|
||||
votes = 0;
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
lines.set(j,
|
||||
lines.get(j).replace("%votes%", "" + votes)
|
||||
.replace("%player%", playerName));
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
lines.set(j, lines.get(j).replace("%SiteName%", data)
|
||||
.replace("%position%", "" + position));
|
||||
}
|
||||
|
||||
lines = Utils.getInstance().colorize(lines);
|
||||
|
||||
} else {
|
||||
for (VoteSite voteSite : plugin.voteSites) {
|
||||
if (data.equalsIgnoreCase(voteSite.getSiteName())) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
TopVoter.getInstance()
|
||||
.topVotersSortedVoteSite(voteSite)
|
||||
.keySet());
|
||||
|
||||
if (users.size() >= position) {
|
||||
playerName = users.get(position - 1)
|
||||
.getPlayerName();
|
||||
votes = users.get(position - 1).getTotal(voteSite);
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
lines.set(
|
||||
j,
|
||||
lines.get(j)
|
||||
.replace("%votes%", "" + votes)
|
||||
.replace("%player%", playerName));
|
||||
}
|
||||
} else {
|
||||
playerName = "No Player";
|
||||
votes = 0;
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
lines.set(
|
||||
j,
|
||||
lines.get(j)
|
||||
.replace("%votes%", "" + votes)
|
||||
.replace("%player%", playerName));
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
lines.set(
|
||||
j,
|
||||
lines.get(j)
|
||||
.replace("%SiteName%", data)
|
||||
.replace("%position%",
|
||||
"" + position));
|
||||
}
|
||||
|
||||
lines = Utils.getInstance().colorize(lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateSign(int delay) {
|
||||
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
BlockState state = getLocation().getBlock().getState();
|
||||
if (state instanceof Sign) {
|
||||
Sign s = (Sign) state;
|
||||
|
||||
for (int j = 0; j < lines.size() && j < 4; j++) {
|
||||
s.setLine(j, lines.get(j));
|
||||
}
|
||||
s.update();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (Config.getInstance().getDebugEnabled()) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
public class UUID {
|
||||
private String uuid;
|
||||
|
||||
public UUID(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUUID(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,180 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
|
||||
public class VoteSite {
|
||||
static Config config = Config.getInstance();
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
private String voteURL;
|
||||
private String serviceSite;
|
||||
private String siteName;
|
||||
private int voteDelay;
|
||||
private boolean enabled;
|
||||
|
||||
private ArrayList<String> rewards;
|
||||
|
||||
private int cumulativeVotes;
|
||||
private ArrayList<String> cumulativeRewards;
|
||||
|
||||
public VoteSite(Main plugin) {
|
||||
VoteSite.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New VoteSite
|
||||
*
|
||||
* @param siteName
|
||||
* Sitename
|
||||
*/
|
||||
public VoteSite(String siteName) {
|
||||
setSiteName(siteName);
|
||||
if (!configVoteSites.getVoteSiteFile(siteName).exists()) {
|
||||
if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
}
|
||||
init();
|
||||
plugin.loadVoteSites();
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broad cast a vote
|
||||
*
|
||||
* @param user
|
||||
* User to broadcast with
|
||||
*/
|
||||
public void broadcastVote(User user) {
|
||||
String playerName = user.getPlayerName();
|
||||
String bc = Utils.getInstance().colorize(format.getBroadCastMsg());
|
||||
bc = bc.replace("%player%", playerName).replace("%SiteName%", siteName);
|
||||
Bukkit.broadcastMessage(bc);
|
||||
}
|
||||
|
||||
public ArrayList<String> getCumulativeRewards() {
|
||||
return cumulativeRewards;
|
||||
}
|
||||
|
||||
public int getCumulativeVotes() {
|
||||
return cumulativeVotes;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRewards() {
|
||||
return rewards;
|
||||
}
|
||||
|
||||
public String getServiceSite() {
|
||||
return serviceSite;
|
||||
}
|
||||
|
||||
public String getSiteName() {
|
||||
return siteName;
|
||||
}
|
||||
|
||||
public int getVoteDelay() {
|
||||
return voteDelay;
|
||||
}
|
||||
|
||||
public String getVoteURL() {
|
||||
return voteURL;
|
||||
}
|
||||
|
||||
public void giveCulumativeRewards(User user) {
|
||||
for (String reward : getCumulativeRewards()) {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveRewards(User user) {
|
||||
for (String reward : getRewards()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveSiteReward(User user) {
|
||||
giveRewards(user);
|
||||
|
||||
try {
|
||||
|
||||
user.addCumulativeReward(this);
|
||||
|
||||
if (configVoteSites.getCumulativeRewardVotesAmount(siteName) != 0) {
|
||||
user.addCumulativeReward(this);
|
||||
if ((user.getCumulativeReward(this) >= configVoteSites
|
||||
.getCumulativeRewardVotesAmount(siteName))) {
|
||||
|
||||
giveCulumativeRewards(user);
|
||||
|
||||
user.setCumulativeReward(this, 0);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void init() {
|
||||
setVoteURL(configVoteSites.getVoteURL(siteName));
|
||||
setServiceSite(configVoteSites.getServiceSite(siteName));
|
||||
setVoteDelay(configVoteSites.getVoteDelay(siteName));
|
||||
setEnabled(configVoteSites.getVoteSiteEnabled(siteName));
|
||||
setRewards(configVoteSites.getRewards(siteName));
|
||||
setCumulativeVotes(configVoteSites
|
||||
.getCumulativeRewardVotesAmount(siteName));
|
||||
setCumulativeRewards(configVoteSites.getCumulativeRewards(siteName));
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setCumulativeRewards(ArrayList<String> cumulativeRewards) {
|
||||
this.cumulativeRewards = cumulativeRewards;
|
||||
}
|
||||
|
||||
public void setCumulativeVotes(int cumulativeVotes) {
|
||||
this.cumulativeVotes = cumulativeVotes;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setRewards(ArrayList<String> rewards) {
|
||||
this.rewards = rewards;
|
||||
}
|
||||
|
||||
public void setServiceSite(String serviceSite) {
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
public void setSiteName(String siteName) {
|
||||
this.siteName = siteName;
|
||||
}
|
||||
|
||||
public void setVoteDelay(int voteDelay) {
|
||||
this.voteDelay = voteDelay;
|
||||
}
|
||||
|
||||
public void setVoteURL(String voteURL) {
|
||||
this.voteURL = voteURL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.OtherRewards;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class OtherVoteReward {
|
||||
|
||||
static ConfigOtherRewards bonusReward = ConfigOtherRewards.getInstance();
|
||||
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static OtherVoteReward instance = new OtherVoteReward();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static OtherVoteReward getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private OtherVoteReward() {
|
||||
}
|
||||
|
||||
public OtherVoteReward(Main plugin) {
|
||||
OtherVoteReward.plugin = plugin;
|
||||
}
|
||||
|
||||
public boolean checkAllSites(User user) {
|
||||
return user.checkAllVotes();
|
||||
|
||||
}
|
||||
|
||||
public boolean checkFirstVote(User user) {
|
||||
int userVotesTotal = user.getTotalVotes();
|
||||
if (ConfigOtherRewards.getInstance().getFirstVoteRewards().size() != 0) {
|
||||
if (userVotesTotal <= 1 && !user.hasGottenFirstVote()) {
|
||||
user.setHasGottenFirstVote(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkNumberOfVotes(User user) {
|
||||
if (ConfigOtherRewards.getInstance().getNumberOfVotes().size() != 0) {
|
||||
int votesRequired = ConfigOtherRewards.getInstance()
|
||||
.getVotesRequired();
|
||||
if (votesRequired != 0) {
|
||||
if (ConfigOtherRewards.getInstance()
|
||||
.getNumberOfVotesVotesInSameDay()) {
|
||||
int userVotesTotal = user.getTotalVotesToday();
|
||||
if ((userVotesTotal % votesRequired) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
||||
int userVotesTotal = user.getTotalVotes();
|
||||
if ((userVotesTotal % votesRequired) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void giveAllSitesRewards(User user) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getAllSitesReward()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveFirstVoteRewards(User user) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getFirstVoteRewards()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void giveNumberOfVotesRewards(User user) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getNumberOfVotes()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-74
@@ -1,74 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.PlaceHolderExpansion;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class PlaceHolders {
|
||||
|
||||
static PlaceHolders instance = new PlaceHolders();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static PlaceHolders getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private PlaceHolders() {
|
||||
}
|
||||
|
||||
public PlaceHolders(Main plugin) {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
public String playerCanVote(Player player) {
|
||||
return Boolean.toString(new User(player).canVoteAll());
|
||||
|
||||
}
|
||||
|
||||
public String playerLastVote(Player player, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames()
|
||||
.contains(siteName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
User user = new User(player);
|
||||
return Commands.getInstance().voteCommandLastDate(user, voteSite);
|
||||
}
|
||||
|
||||
public String playerNextVote(Player player, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames()
|
||||
.contains(siteName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
User user = new User(player);
|
||||
return Commands.getInstance().voteCommandNextInfo(user, voteSite);
|
||||
}
|
||||
|
||||
public String playerPoints(Player player) {
|
||||
return Integer.toString(new User(player).getPoints());
|
||||
}
|
||||
|
||||
public String playerTotalVotes(Player player) {
|
||||
return Integer.toString(new User(player).getTotalVotes());
|
||||
}
|
||||
|
||||
public String playerTotalVotesSite(Player player, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames()
|
||||
.contains(siteName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
User user = new User(player);
|
||||
return Integer.toString(user.getTotalVotesSite(voteSite));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,157 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Report;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
|
||||
public class Report {
|
||||
|
||||
static Report instance = new Report();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static void addToZip(File directoryToZip, File file,
|
||||
ZipOutputStream zos) throws FileNotFoundException, IOException {
|
||||
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
|
||||
String zipFilePath = file.getPath();
|
||||
|
||||
plugin.debug("Writing '" + zipFilePath + "' to zip file");
|
||||
|
||||
ZipEntry zipEntry = new ZipEntry(zipFilePath);
|
||||
zos.putNextEntry(zipEntry);
|
||||
|
||||
byte[] bytes = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(bytes)) >= 0) {
|
||||
zos.write(bytes, 0, length);
|
||||
}
|
||||
|
||||
zos.closeEntry();
|
||||
fis.close();
|
||||
}
|
||||
|
||||
public static Report getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
private Report() {
|
||||
}
|
||||
|
||||
public Report(Main plugin) {
|
||||
Report.plugin = plugin;
|
||||
}
|
||||
|
||||
public void create() {
|
||||
File directoryToZip = plugin.getDataFolder();
|
||||
|
||||
List<File> fileList = new ArrayList<File>();
|
||||
try {
|
||||
plugin.getLogger().info(
|
||||
"---Getting references to all files in: "
|
||||
+ directoryToZip.getCanonicalPath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
getAllFiles(directoryToZip, fileList);
|
||||
plugin.getLogger().info("---Creating zip file");
|
||||
writeZipFile(directoryToZip, fileList);
|
||||
plugin.getLogger().info("---Done");
|
||||
}
|
||||
|
||||
public void getAllFiles(File dir, List<File> fileList) {
|
||||
try {
|
||||
File[] files = dir.listFiles();
|
||||
for (File file : files) {
|
||||
fileList.add(file);
|
||||
if (file.isDirectory()) {
|
||||
|
||||
plugin.debug("directory:" + file.getCanonicalPath());
|
||||
|
||||
getAllFiles(file, fileList);
|
||||
} else {
|
||||
|
||||
plugin.debug("file:" + file.getCanonicalPath());
|
||||
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void writeZipFile(File directoryToZip, List<File> fileList) {
|
||||
|
||||
try {
|
||||
Date date = new Date();
|
||||
File fileZipFolder = new File(plugin.getDataFolder()
|
||||
.getAbsolutePath() + File.separator + "Reports");
|
||||
if (!fileZipFolder.exists()) {
|
||||
fileZipFolder.mkdirs();
|
||||
}
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(plugin.getDataFolder()
|
||||
.getAbsolutePath()
|
||||
+ File.separator
|
||||
+ "Reports"
|
||||
+ File.separator
|
||||
+ "Report"
|
||||
+ (date.getYear() + 1900)
|
||||
+ "."
|
||||
+ (date.getMonth() + 1)
|
||||
+ "."
|
||||
+ date.getDate()
|
||||
+ "."
|
||||
+ date.getHours()
|
||||
+ "."
|
||||
+ date.getMinutes()
|
||||
+ "."
|
||||
+ date.getSeconds() + ".zip");
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
|
||||
for (File file : fileList) {
|
||||
if (!file.isDirectory()) { // we only zip files, not directories
|
||||
addToZip(directoryToZip, file, zos);
|
||||
}
|
||||
}
|
||||
|
||||
zos.close();
|
||||
fos.close();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
// credit: https://bukkit.org/threads/simplescoreboard-make-pretty-scoreboards-with-ease.263041/
|
||||
|
||||
package com.Ben12345rocks.VotingPlugin.Scoreboards;
|
||||
|
||||
import java.util.AbstractMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
|
||||
public class SimpleScoreboard {
|
||||
|
||||
private Scoreboard scoreboard;
|
||||
|
||||
private String title;
|
||||
private Map<String, Integer> scores;
|
||||
private List<Team> teams;
|
||||
|
||||
public SimpleScoreboard(String title) {
|
||||
scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
|
||||
this.title = title;
|
||||
scores = Maps.newLinkedHashMap();
|
||||
teams = Lists.newArrayList();
|
||||
}
|
||||
|
||||
public void add(String text) {
|
||||
text = Utils.getInstance().colorize(text);
|
||||
add(text, null);
|
||||
}
|
||||
|
||||
public void add(String text, Integer score) {
|
||||
Preconditions.checkArgument(text.length() < 48,
|
||||
"text cannot be over 48 characters in length");
|
||||
text = Utils.getInstance().colorize(text);
|
||||
text = fixDuplicates(text);
|
||||
scores.put(text, score);
|
||||
}
|
||||
|
||||
public void blankLine() {
|
||||
add(" ");
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void build() {
|
||||
Objective obj = scoreboard
|
||||
.registerNewObjective(
|
||||
(title.length() > 16 ? title.substring(0, 15) : title),
|
||||
"dummy");
|
||||
obj.setDisplayName(title);
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
|
||||
int index = scores.size();
|
||||
|
||||
for (Map.Entry<String, Integer> text : scores.entrySet()) {
|
||||
Map.Entry<Team, String> team = createTeam(text.getKey());
|
||||
Integer score = text.getValue() != null ? text.getValue() : index;
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(team.getValue());
|
||||
if (team.getKey() != null) {
|
||||
team.getKey().addPlayer(player);
|
||||
}
|
||||
obj.getScore(player).setScore(score);
|
||||
index -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
private Map.Entry<Team, String> createTeam(String text) {
|
||||
String result = "";
|
||||
if (text.length() <= 16) {
|
||||
return new AbstractMap.SimpleEntry<>(null, text);
|
||||
}
|
||||
Team team = scoreboard.registerNewTeam("text-"
|
||||
+ scoreboard.getTeams().size());
|
||||
Iterator<String> iterator = Splitter.fixedLength(16).split(text)
|
||||
.iterator();
|
||||
team.setPrefix(iterator.next());
|
||||
result = iterator.next();
|
||||
if (text.length() > 32) {
|
||||
team.setSuffix(iterator.next());
|
||||
}
|
||||
teams.add(team);
|
||||
return new AbstractMap.SimpleEntry<>(team, result);
|
||||
}
|
||||
|
||||
private String fixDuplicates(String text) {
|
||||
while (scores.containsKey(text)) {
|
||||
text += "§r";
|
||||
}
|
||||
if (text.length() > 48) {
|
||||
text = text.substring(0, 47);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public Scoreboard getScoreboard() {
|
||||
return scoreboard;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
title = null;
|
||||
scores.clear();
|
||||
for (Team t : teams) {
|
||||
t.unregister();
|
||||
}
|
||||
teams.clear();
|
||||
}
|
||||
|
||||
public void send(Player... players) {
|
||||
if (Config.getInstance().getSendScoreboards()) {
|
||||
for (Player p : players) {
|
||||
p.setScoreboard(scoreboard);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
|
||||
public class Signs {
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static Signs instance = new Signs();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static Signs getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Signs() {
|
||||
}
|
||||
|
||||
public Signs(Main plugin) {
|
||||
Signs.plugin = plugin;
|
||||
}
|
||||
|
||||
public String getSignFromLocation(Location loc) {
|
||||
for (String sign : ServerData.getInstance().getSigns()) {
|
||||
if (ServerData.getInstance().getSignLocation(sign).equals(loc)) {
|
||||
return sign;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
public void storeSigns() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
sign.storeSign();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSigns() {
|
||||
for (int i = plugin.signs.size() - 1; i >= 0; i--) {
|
||||
if (!plugin.signs.get(i).isValid()) {
|
||||
plugin.signs.get(i).removeSign();
|
||||
plugin.signs.remove(i);
|
||||
plugin.debug("Sign " + plugin.signs.get(i).getSign()
|
||||
+ " invalid, removing from data.");
|
||||
} else {
|
||||
plugin.signs.get(i).updateLines();
|
||||
plugin.signs.get(i).updateSign(i * 3);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug("Signs updated");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,600 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.TopVoter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigTopVoterAwards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class TopVoter {
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static TopVoter instance = new TopVoter();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static TopVoter getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private TopVoter() {
|
||||
}
|
||||
|
||||
public TopVoter(Main plugin) {
|
||||
TopVoter.plugin = plugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void checkTopVoterAward() {
|
||||
if (hasMonthChanged()) {
|
||||
plugin.getLogger().info("Month changed!");
|
||||
TopVoters.getInstance().storeMonthlyTopVoters(
|
||||
new Date().getYear() + 1900, new Date().getMonth(),
|
||||
topVoterNoColor());
|
||||
if (ConfigTopVoterAwards.getInstance().getMonthlyAwardsEnabled()) {
|
||||
Set<String> places = ConfigTopVoterAwards.getInstance()
|
||||
.getMonthlyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
for (User user : plugin.topVoterMonthly.keySet()) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(user
|
||||
.getPlayerName());
|
||||
if (!player.getPlayer().hasPermission(
|
||||
"VotingPlugin.TopVoter.Ignore")) {
|
||||
i++;
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.monthlyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetTotalsMonthly();
|
||||
|
||||
}
|
||||
|
||||
if (hasWeekChanged()) {
|
||||
plugin.getLogger().info("Week changed!");
|
||||
TopVoters.getInstance().storeWeeklyTopVoters(
|
||||
new Date().getYear() + 1900, new Date().getMonth(),
|
||||
new Date().getDate(), topVoterWeeklyNoColor());
|
||||
if (ConfigTopVoterAwards.getInstance().getWeeklyAwardsEnabled()) {
|
||||
Set<String> places = ConfigTopVoterAwards.getInstance()
|
||||
.getWeeklyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
for (User user : plugin.topVoterWeekly.keySet()) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(user
|
||||
.getPlayerName());
|
||||
if (!player.getPlayer().hasPermission(
|
||||
"VotingPlugin.TopVoter.Ignore")) {
|
||||
i++;
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.weeklyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetTotalsWeekly();
|
||||
|
||||
}
|
||||
|
||||
if (hasDayChanged()) {
|
||||
plugin.getLogger().info("Day changed!");
|
||||
TopVoters.getInstance().storeDailyTopVoters(
|
||||
new Date().getYear() + 1900, new Date().getMonth(),
|
||||
new Date().getDate(), topVoterDailyNoColor());
|
||||
if (ConfigTopVoterAwards.getInstance().getDailyAwardsEnabled()) {
|
||||
Set<String> places = ConfigTopVoterAwards.getInstance()
|
||||
.getDailyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
for (User user : plugin.topVoterDaily.keySet()) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(user
|
||||
.getPlayerName());
|
||||
if (!player.getPlayer().hasPermission(
|
||||
"VotingPlugin.TopVoter.Ignore")) {
|
||||
i++;
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.dailyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetTotalsDaily();
|
||||
|
||||
}
|
||||
|
||||
plugin.debug("Checked Top Voter Awards");
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasDayChanged() {
|
||||
int prevDay = ServerData.getInstance().getPrevDay();
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
int day = c.getTime().getDay();
|
||||
ServerData.getInstance().setPrevDay(day);
|
||||
if (prevDay != day) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasMonthChanged() {
|
||||
int prevMonth = ServerData.getInstance().getPrevMonth();
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
int month = c.getTime().getMonth();
|
||||
ServerData.getInstance().setPrevMonth(month);
|
||||
if (prevMonth != month) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasWeekChanged() {
|
||||
int prevDate = ServerData.getInstance().getPrevWeekDay();
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
ServerData.getInstance().setPrevWeekDay(c.getTime().getDate());
|
||||
if (ServerData.getInstance().getPrevDay() == 0
|
||||
&& c.getTime().getDate() != prevDate) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetTotalsDaily() {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance()
|
||||
.getVoteSites()) {
|
||||
user.setTotalDaily(voteSite, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTotalsMonthly() {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance()
|
||||
.getVoteSites()) {
|
||||
user.setTotal(voteSite, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTotalsPlayer(User user) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance().getVoteSites()) {
|
||||
user.setTotal(voteSite, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTotalsWeekly() {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance()
|
||||
.getVoteSites()) {
|
||||
user.setTotalWeekly(voteSite, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String[] topVoterDaily(int page) {
|
||||
int pagesize = ConfigFormat.getInstance().getPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = Utils.getInstance().convertArray(
|
||||
topVotersDaily());
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = format.getCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page)
|
||||
.replace("%maxpages%", "" + pageSize).replace("%Top%", "Daily");
|
||||
msg.add(Utils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size())
|
||||
&& (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterDailyNoColor() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterDaily.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%"
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterDaily.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterMonthly(int page) {
|
||||
int pagesize = ConfigFormat.getInstance().getPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = Utils.getInstance().convertArray(
|
||||
topVoters());
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = format.getCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page)
|
||||
.replace("%maxpages%", "" + pageSize)
|
||||
.replace("%Top%", "Monthly");
|
||||
msg.add(Utils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size())
|
||||
&& (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterNoColor() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterMonthly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%"
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterMonthly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoters() {
|
||||
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 = format.getCommandVoteTopLine()
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", entry.getKey().getPlayerName())
|
||||
.replace("%votes%", "" + entry.getValue().intValue());
|
||||
|
||||
msg.add(line);
|
||||
i++;
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVotersDaily() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterDaily.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = format
|
||||
.getCommandVoteTopLine()
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterDaily.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public ArrayList<User> topVotersSortedAll() {
|
||||
ArrayList<String> blackList = (ArrayList<String>) ConfigTopVoterAwards
|
||||
.getInstance().getBlackList();
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
if (users1 != null) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalVotes() == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
if (blackList != null) {
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (blackList.contains(users.get(i).getPlayerName())) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(users, new Comparator<User>() {
|
||||
|
||||
@Override
|
||||
public int compare(User p1, User p2) {
|
||||
int p1Total = p1.getTotalVotes();
|
||||
int p2Total = p2.getTotalVotes();
|
||||
|
||||
return Integer.compare(p1Total, p2Total);
|
||||
}
|
||||
});
|
||||
|
||||
return users;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<User> topVotersSortedAllDaily() {
|
||||
ArrayList<String> blackList = (ArrayList<String>) ConfigTopVoterAwards
|
||||
.getInstance().getBlackList();
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
if (users1 != null) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalDailyAll() == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
if (blackList != null) {
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (blackList.contains(users.get(i).getPlayerName())) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(users, new Comparator<User>() {
|
||||
|
||||
@Override
|
||||
public int compare(User p1, User p2) {
|
||||
int p1Total = p1.getTotalDailyAll();
|
||||
int p2Total = p2.getTotalDailyAll();
|
||||
|
||||
return Integer.compare(p1Total, p2Total);
|
||||
}
|
||||
});
|
||||
|
||||
return users;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<User> topVotersSortedAllWeekly() {
|
||||
ArrayList<String> blackList = (ArrayList<String>) ConfigTopVoterAwards
|
||||
.getInstance().getBlackList();
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
if (users1 != null) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalWeeklyAll() == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
if (blackList != null) {
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (blackList.contains(users.get(i).getPlayerName())) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(users, new Comparator<User>() {
|
||||
|
||||
@Override
|
||||
public int compare(User p1, User p2) {
|
||||
int p1Total = p1.getTotalWeeklyAll();
|
||||
int p2Total = p2.getTotalWeeklyAll();
|
||||
|
||||
return Integer.compare(p1Total, p2Total);
|
||||
}
|
||||
});
|
||||
|
||||
return users;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> topVotersSortedVoteSite(VoteSite voteSite) {
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalVotesSite(voteSite) == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
for (int j = users.size() - 1; j >= 0; j--) {
|
||||
if (i != j) {
|
||||
if (users.get(i).getPlayerName() == users.get(j)
|
||||
.getPlayerName()) {
|
||||
users.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HashMap<User, Integer> topVoter = new HashMap<User, Integer>();
|
||||
for (User user : users) {
|
||||
topVoter.put(user, user.getTotal(voteSite));
|
||||
}
|
||||
|
||||
return Utils.getInstance().sortByValues(topVoter, false);
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> topVotersSortedVoteSiteDaily(VoteSite voteSite) {
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalDaily(voteSite) == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
for (int j = users.size() - 1; j >= 0; j--) {
|
||||
if (i != j) {
|
||||
if (users.get(i).getPlayerName() == users.get(j)
|
||||
.getPlayerName()) {
|
||||
users.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HashMap<User, Integer> topVoter = new HashMap<User, Integer>();
|
||||
for (User user : users) {
|
||||
topVoter.put(user, user.getTotalDaily(voteSite));
|
||||
}
|
||||
|
||||
return Utils.getInstance().sortByValues(topVoter, false);
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> topVotersSortedVoteSiteWeekly(
|
||||
VoteSite voteSite) {
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalWeekly(voteSite) == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
for (int j = users.size() - 1; j >= 0; j--) {
|
||||
if (i != j) {
|
||||
if (users.get(i).getPlayerName() == users.get(j)
|
||||
.getPlayerName()) {
|
||||
users.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<User, Integer> topVoter = new HashMap<User, Integer>();
|
||||
for (User user : users) {
|
||||
topVoter.put(user, user.getTotalWeekly(voteSite));
|
||||
}
|
||||
|
||||
return Utils.getInstance().sortByValues(topVoter, false);
|
||||
}
|
||||
|
||||
public String[] topVotersWeekly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterWeekly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = format
|
||||
.getCommandVoteTopLine()
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterWeekly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterWeekly(int page) {
|
||||
int pagesize = ConfigFormat.getInstance().getPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = Utils.getInstance().convertArray(
|
||||
topVotersWeekly());
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = format.getCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page)
|
||||
.replace("%maxpages%", "" + pageSize)
|
||||
.replace("%Top%", "Weekly");
|
||||
msg.add(Utils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size())
|
||||
&& (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterWeeklyNoColor() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterWeekly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%"
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterWeekly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public void updateTopVoters() {
|
||||
plugin.topVoterMonthly.clear();
|
||||
ArrayList<User> users = topVotersSortedAll();
|
||||
if (users != null) {
|
||||
for (User user : users) {
|
||||
plugin.topVoterMonthly.put(user, user.getTotalVotes());
|
||||
}
|
||||
plugin.topVoterMonthly = Utils.getInstance().sortByValues(
|
||||
plugin.topVoterMonthly, false);
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly.clear();
|
||||
users = topVotersSortedAllWeekly();
|
||||
if (users != null) {
|
||||
for (User user : users) {
|
||||
plugin.topVoterWeekly.put(user, user.getTotalWeeklyAll());
|
||||
}
|
||||
plugin.topVoterWeekly = Utils.getInstance().sortByValues(
|
||||
plugin.topVoterWeekly, false);
|
||||
}
|
||||
|
||||
plugin.topVoterDaily.clear();
|
||||
users = topVotersSortedAllDaily();
|
||||
if (users != null) {
|
||||
for (User user : users) {
|
||||
plugin.topVoterDaily.put(user, user.getTotalDailyAll());
|
||||
}
|
||||
plugin.topVoterDaily = Utils.getInstance().sortByValues(
|
||||
plugin.topVoterDaily, false);
|
||||
}
|
||||
|
||||
plugin.debug("Updated TopVoter");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.TopVoter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class TopVoters {
|
||||
|
||||
static TopVoters instance = new TopVoters();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static TopVoters getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private TopVoters() {
|
||||
}
|
||||
|
||||
public TopVoters(Main plugin) {
|
||||
TopVoters.plugin = plugin;
|
||||
}
|
||||
|
||||
public void storeDailyTopVoters(int year, int month, int date,
|
||||
String[] topVoters) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "TopVoters" + File.separator + "Daily", "TopVoters." + year
|
||||
+ "." + month + "." + date + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
|
||||
plugin.debug("Created file: " + "TopVoters." + year + "."
|
||||
+ month + "." + date + ".yml");
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create: " + "TopVoters."
|
||||
+ year + "." + month + "." + date + ".yml");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data.set("All", topVoters);
|
||||
for (VoteSite voteSite : plugin.voteSites) {
|
||||
ArrayList<String> voteSiteTop = new ArrayList<String>();
|
||||
int i = 1;
|
||||
HashMap<User, Integer> topVoterSite = TopVoter.getInstance()
|
||||
.topVotersSortedVoteSiteDaily(voteSite);
|
||||
for (Entry<User, Integer> entry : topVoterSite.entrySet()) {
|
||||
voteSiteTop.add(i + ": " + entry.getKey().getPlayerName()
|
||||
+ ", " + entry.getValue().intValue());
|
||||
i++;
|
||||
}
|
||||
data.set(voteSite.getSiteName(), voteSiteTop);
|
||||
}
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info(
|
||||
"Could not save: " + "TopVoters." + year + "." + month
|
||||
+ "." + date + ".yml");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void storeMonthlyTopVoters(int year, int month, String[] topVoters) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "TopVoters" + File.separator + "Monthly", "TopVoters." + year
|
||||
+ "." + month + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
|
||||
plugin.debug("Created file: " + "TopVoters." + year + "."
|
||||
+ month + ".yml");
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create: " + "TopVoters."
|
||||
+ year + "." + month + ".yml");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data.set("All", topVoters);
|
||||
for (VoteSite voteSite : plugin.voteSites) {
|
||||
ArrayList<String> voteSiteTop = new ArrayList<String>();
|
||||
int i = 1;
|
||||
HashMap<User, Integer> topVoterSite = TopVoter.getInstance()
|
||||
.topVotersSortedVoteSite(voteSite);
|
||||
for (Entry<User, Integer> entry : topVoterSite.entrySet()) {
|
||||
voteSiteTop.add(i + ": " + entry.getKey().getPlayerName()
|
||||
+ ", " + entry.getValue().intValue());
|
||||
i++;
|
||||
}
|
||||
data.set(voteSite.getSiteName(), voteSiteTop);
|
||||
}
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info(
|
||||
"Could not save: " + "TopVoters." + year + "." + month
|
||||
+ ".yml");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void storeWeeklyTopVoters(int year, int month, int day,
|
||||
String[] topVoters) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "TopVoters" + File.separator + "Weekly", "TopVoters." + year
|
||||
+ "." + month + "." + day + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
|
||||
plugin.debug("Created file: " + "TopVoters." + year + "."
|
||||
+ month + "." + day + ".yml");
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create: " + "TopVoters."
|
||||
+ year + "." + month + "." + day + ".yml");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data.set("All", topVoters);
|
||||
for (VoteSite voteSite : plugin.voteSites) {
|
||||
ArrayList<String> voteSiteTop = new ArrayList<String>();
|
||||
int i = 1;
|
||||
HashMap<User, Integer> topVoterSite = TopVoter.getInstance()
|
||||
.topVotersSortedVoteSiteWeekly(voteSite);
|
||||
for (Entry<User, Integer> entry : topVoterSite.entrySet()) {
|
||||
voteSiteTop.add(i + ": " + entry.getKey().getPlayerName()
|
||||
+ ", " + entry.getValue().intValue());
|
||||
i++;
|
||||
}
|
||||
data.set(voteSite.getSiteName(), voteSiteTop);
|
||||
}
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info(
|
||||
"Could not save: " + "TopVoters." + year + "." + month
|
||||
+ "." + day + ".yml");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Updater;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
public class CheckUpdate {
|
||||
|
||||
static CheckUpdate instance = new CheckUpdate();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static CheckUpdate getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private CheckUpdate() {
|
||||
}
|
||||
|
||||
public CheckUpdate(Main plugin) {
|
||||
CheckUpdate.plugin = plugin;
|
||||
}
|
||||
|
||||
public void checkUpdate() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case FAIL_SPIGOT: {
|
||||
plugin.getLogger().info(
|
||||
"Failed to check for update for " + plugin.getName() + "!");
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
plugin.getLogger().info(
|
||||
plugin.getName() + " is up to date! Version: "
|
||||
+ plugin.updater.getVersion());
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger().info(
|
||||
plugin.getName()
|
||||
+ " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion()
|
||||
+ " New Version: " + plugin.updater.getVersion());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startUp() {
|
||||
Bukkit.getServer().getScheduler()
|
||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdate();
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Updater;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Updater {
|
||||
|
||||
public enum UpdateResult {
|
||||
BAD_RESOURCEID, DISABLED, FAIL_NOVERSION, FAIL_SPIGOT, NO_UPDATE, UPDATE_AVAILABLE
|
||||
}
|
||||
|
||||
private final String API_KEY = "98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4";
|
||||
private HttpURLConnection connection;
|
||||
private final String HOST = "http://www.spigotmc.org";
|
||||
private String oldVersion;
|
||||
private JavaPlugin plugin;
|
||||
private final String QUERY = "/api/general.php";
|
||||
|
||||
private final String REQUEST_METHOD = "POST";
|
||||
private String RESOURCE_ID = "";
|
||||
|
||||
private Updater.UpdateResult result = Updater.UpdateResult.DISABLED;
|
||||
|
||||
private String version;
|
||||
|
||||
private String WRITE_STRING;
|
||||
|
||||
public Updater(JavaPlugin plugin, Integer resourceId, boolean disabled) {
|
||||
RESOURCE_ID = resourceId + "";
|
||||
this.plugin = plugin;
|
||||
oldVersion = this.plugin.getDescription().getVersion();
|
||||
|
||||
if (disabled) {
|
||||
result = UpdateResult.DISABLED;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
connection = (HttpURLConnection) new URL(HOST + QUERY)
|
||||
.openConnection();
|
||||
} catch (IOException e) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
return;
|
||||
}
|
||||
|
||||
WRITE_STRING = "key=" + API_KEY + "&resource=" + RESOURCE_ID;
|
||||
run();
|
||||
}
|
||||
|
||||
public UpdateResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
private void run() {
|
||||
connection.setDoOutput(true);
|
||||
try {
|
||||
connection.setRequestMethod(REQUEST_METHOD);
|
||||
connection.getOutputStream().write(WRITE_STRING.getBytes("UTF-8"));
|
||||
} catch (ProtocolException e1) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
} catch (IOException e) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
}
|
||||
String version;
|
||||
try {
|
||||
version = new BufferedReader(new InputStreamReader(
|
||||
connection.getInputStream())).readLine();
|
||||
} catch (Exception e) {
|
||||
result = UpdateResult.BAD_RESOURCEID;
|
||||
return;
|
||||
}
|
||||
if (version.length() <= 7) {
|
||||
this.version = version;
|
||||
version.replace("[^A-Za-z]", "").replace("|", "");
|
||||
versionCheck();
|
||||
return;
|
||||
}
|
||||
result = UpdateResult.BAD_RESOURCEID;
|
||||
}
|
||||
|
||||
public boolean shouldUpdate(String localVersion, String remoteVersion) {
|
||||
return !localVersion.equalsIgnoreCase(remoteVersion);
|
||||
}
|
||||
|
||||
private void versionCheck() {
|
||||
if (shouldUpdate(oldVersion, version)) {
|
||||
result = UpdateResult.UPDATE_AVAILABLE;
|
||||
} else {
|
||||
result = UpdateResult.NO_UPDATE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,754 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin;
|
||||
|
||||
import gyurix.api.TitleAPI;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class Utils {
|
||||
|
||||
static Utils instance = new Utils();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static Utils getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
public Utils(Main plugin) {
|
||||
Utils.plugin = plugin;
|
||||
}
|
||||
|
||||
public ItemStack addEnchants(ItemStack item,
|
||||
HashMap<String, Integer> enchants) {
|
||||
if ((enchants == null) || (enchants.size() == 0)) {
|
||||
return item;
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
for (String enchant : enchants.keySet()) {
|
||||
meta.addEnchant(Enchantment.getByName(enchant),
|
||||
enchants.get(enchant), false);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public ItemStack addLore(ItemStack item, List<String> lore) {
|
||||
if (lore == null) {
|
||||
return item;
|
||||
}
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(colorize(lore));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public ArrayList<String> colorize(ArrayList<String> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, colorize(list.get(i)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> colorize(List<String> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, colorize(list.get(i)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public String colorize(String format) {
|
||||
if (format == null) {
|
||||
return null;
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', format);
|
||||
}
|
||||
|
||||
public String[] colorize(String[] list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = colorize(list[i]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<String> comptoString(ArrayList<TextComponent> comps) {
|
||||
ArrayList<String> txt = new ArrayList<String>();
|
||||
for (TextComponent comp : comps) {
|
||||
txt.add(compToString(comp));
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
|
||||
public String compToString(TextComponent comp) {
|
||||
return colorize(comp.toPlainText());
|
||||
}
|
||||
|
||||
public User[] convert(ArrayList<User> array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
}
|
||||
User[] list = new User[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
list[i] = array.get(i);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<String> convert(Set<String> set) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (String st : set) {
|
||||
list.add(st);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String[] convertArray(ArrayList<String> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
String[] string = new String[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
string[i] = list.get(i);
|
||||
}
|
||||
if (string == null) {
|
||||
return null;
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ArrayList<String> convertArray(String[] list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<String> newlist = new ArrayList<String>();
|
||||
for (String element : list) {
|
||||
newlist.add(element);
|
||||
}
|
||||
if (newlist == null) {
|
||||
return null;
|
||||
} else {
|
||||
return newlist;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<User> convertSet(Set<User> set) {
|
||||
if (set == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<User> list = new ArrayList<User>();
|
||||
for (User user : set) {
|
||||
list.add(user);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getDayFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getDate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getHourFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getHours();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getMinutesFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getMinutes();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getMonthFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getMonth();
|
||||
}
|
||||
|
||||
public String getMonthString(int month) {
|
||||
if (month == 0) {
|
||||
month++;
|
||||
}
|
||||
return new DateFormatSymbols().getMonths()[month - 1];
|
||||
}
|
||||
|
||||
public String getPlayerName(String uuid) {
|
||||
if ((uuid == null) || uuid.equalsIgnoreCase("null")) {
|
||||
|
||||
plugin.debug("Null UUID");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
User user = new User(new com.Ben12345rocks.VotingPlugin.Objects.UUID(
|
||||
uuid), false);
|
||||
String playerName = Data.getInstance().getName(user);
|
||||
|
||||
if (playerName != null) {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(UUID.fromString(uuid));
|
||||
if (player == null) {
|
||||
playerName = Bukkit.getOfflinePlayer(UUID.fromString(uuid))
|
||||
.getName();
|
||||
return playerName;
|
||||
} else {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Block> getRegionBlocks(World world, Location loc1, Location loc2) {
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
|
||||
for (double x = loc1.getX(); x <= loc2.getX(); x++) {
|
||||
for (double y = loc1.getY(); y <= loc2.getY(); y++) {
|
||||
for (double z = loc1.getZ(); z <= loc2.getZ(); z++) {
|
||||
Location loc = new Location(world, x, y, z);
|
||||
blocks.add(loc.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getUUID(String playerName) {
|
||||
if (playerName == null) {
|
||||
return null;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player == null) {
|
||||
return Bukkit.getOfflinePlayer(playerName).getUniqueId().toString();
|
||||
} else {
|
||||
return player.getUniqueId().toString();
|
||||
}
|
||||
}
|
||||
|
||||
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.equals(url)) {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getYearFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getYear();
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender, String perm) {
|
||||
return sender.hasPermission(plugin.getName() + "." + perm);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, String perm) {
|
||||
return player.hasPermission(plugin.getName() + "." + perm);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String playerName, String perm) {
|
||||
if (playerName == null) {
|
||||
return false;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
return player.hasPermission(plugin.getName() + "." + perm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayer(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String makeString(int startIndex, String[] strs) {
|
||||
String str = new String();
|
||||
for (int i = startIndex; i < strs.length; i++) {
|
||||
if (i == startIndex) {
|
||||
str += strs[i];
|
||||
} else {
|
||||
str += " " + strs[i];
|
||||
}
|
||||
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String makeStringList(ArrayList<String> list) {
|
||||
if (list == null) {
|
||||
return "";
|
||||
}
|
||||
String string = new String();
|
||||
if (list.size() > 1) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i == 0) {
|
||||
string += list.get(i);
|
||||
} else {
|
||||
string += ", " + list.get(i);
|
||||
}
|
||||
}
|
||||
} else if (list.size() == 1) {
|
||||
string = list.get(0);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public ItemStack nameItem(ItemStack item, String name) {
|
||||
if (name == null) {
|
||||
return item;
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public void printMap(HashMap<User, Integer> topVoterMonthly) {
|
||||
for (Entry<User, Integer> entry : topVoterMonthly.entrySet()) {
|
||||
plugin.debug("Key : " + entry.getKey().getPlayerName()
|
||||
+ " Value : " + entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<User> removeDoubleUsers(ArrayList<User> list) {
|
||||
Set<User> hs = new HashSet<User>();
|
||||
ArrayList<User> al = new ArrayList<User>();
|
||||
hs.addAll(list);
|
||||
al.clear();
|
||||
al.addAll(hs);
|
||||
|
||||
return al;
|
||||
}
|
||||
|
||||
public ArrayList<String> removeDuplicates(ArrayList<String> list) {
|
||||
Set<String> set = new HashSet<String>(list);
|
||||
return new ArrayList<String>(set);
|
||||
}
|
||||
|
||||
public List<String> replace(List<String> list, String toReplace,
|
||||
String replaceWith) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
if (replaceWith == null || toReplace == null) {
|
||||
return list;
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, list.get(i).replace(toReplace, replaceWith));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<String> replaceIgnoreCase(ArrayList<String> list,
|
||||
String toReplace, String replaceWith) {
|
||||
ArrayList<String> newList = new ArrayList<String>();
|
||||
for (String msg : list) {
|
||||
newList.add(replaceIgnoreCase(msg, toReplace, replaceWith));
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
public String replaceIgnoreCase(String str, String toReplace,
|
||||
String replaceWith) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
if ((toReplace == null) || (replaceWith == null)) {
|
||||
return str;
|
||||
}
|
||||
return str.replaceAll("(?i)" + toReplace, replaceWith);
|
||||
}
|
||||
|
||||
public String replacePlaceHolders(Player player, String text) {
|
||||
if (plugin.placeHolderAPIEnabled) {
|
||||
return PlaceholderAPI.setBracketPlaceholders(player, text);
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendTitle(Player player, String title, String subTitle,
|
||||
int fadeIn, int showTime, int fadeOut) {
|
||||
if (plugin.spigotLibEnabled) {
|
||||
|
||||
if (title == null) {
|
||||
title = "";
|
||||
}
|
||||
if (subTitle == null) {
|
||||
subTitle = "";
|
||||
}
|
||||
TitleAPI.set(colorize(title), colorize(subTitle), fadeIn, showTime,
|
||||
fadeOut, player);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack setDurabilty(ItemStack item, int durability) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
if (durability > 0) {
|
||||
item.setDurability((short) durability);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ItemStack setSkullOwner(ItemStack item, String playerName) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
if (playerName == null || playerName.equalsIgnoreCase("")) {
|
||||
return item;
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
((SkullMeta) meta).setOwner(playerName);
|
||||
return item;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String[] setToArray(Set<String> set) {
|
||||
String[] array = new String[set.size()];
|
||||
int i = 0;
|
||||
for (String item : set) {
|
||||
array[i] = item;
|
||||
i++;
|
||||
}
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> sortByValues(
|
||||
HashMap<User, Integer> unsortMap, final boolean order) {
|
||||
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(
|
||||
unsortMap.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
|
||||
HashMap<User, Integer> sortedMap = new LinkedHashMap<User, Integer>();
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
public boolean startsWithIgnoreCase(String str1, String str2) {
|
||||
return str1.toLowerCase().startsWith(str2.toLowerCase());
|
||||
}
|
||||
|
||||
public TextComponent stringToComp(String string) {
|
||||
TextComponent base = new TextComponent("");
|
||||
boolean previousLetter = false;
|
||||
ChatColor currentColor = null;
|
||||
boolean bold = false;
|
||||
boolean italic = false;
|
||||
boolean underline = false;
|
||||
boolean strike = false;
|
||||
boolean magic = false;
|
||||
String currentstring = "";
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
char c = string.charAt(i);
|
||||
if (c == '&') {
|
||||
if (string.charAt(i + 1) == 'l') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
bold = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'k') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
magic = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'm') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
strike = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'n') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
underline = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'o') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
italic = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'r') {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else if (ChatColor.getByChar(string.charAt(i + 1)) != null) {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentColor = ChatColor
|
||||
.getByChar(string.charAt(i + 1));
|
||||
currentstring = "";
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
currentColor = ChatColor
|
||||
.getByChar(string.charAt(i + 1));
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
previousLetter = true;
|
||||
currentstring = currentstring + c;
|
||||
}
|
||||
} else {
|
||||
previousLetter = true;
|
||||
currentstring = currentstring + c;
|
||||
}
|
||||
}
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
return base;
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteParty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.UUID;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class VoteParty {
|
||||
static VoteParty instance = new VoteParty();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static VoteParty getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private VoteParty() {
|
||||
}
|
||||
|
||||
public VoteParty(Main plugin) {
|
||||
VoteParty.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addTotal() {
|
||||
setTotalVotes(getTotalVotes() + 1);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public void check() {
|
||||
if (ConfigOtherRewards.getInstance().getVotePartyEnabled()) {
|
||||
if (getTotalVotes() >= ConfigOtherRewards.getInstance()
|
||||
.getVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes()
|
||||
- ConfigOtherRewards.getInstance().getVotesRequired());
|
||||
giveRewards();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void commandVoteParty(CommandSender sender) {
|
||||
ArrayList<String> msg = ConfigFormat.getInstance()
|
||||
.getCommandsVoteParty();
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
int votesRequired = ConfigOtherRewards.getInstance().getVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
for (String line : msg) {
|
||||
line = line.replace("%VotesRequired%", "" + votesRequired)
|
||||
.replace("%NeededVotes%", "" + neededVotes)
|
||||
.replace("%Votes%", "" + votes);
|
||||
lines.add(Utils.getInstance().colorize(line));
|
||||
}
|
||||
sender.sendMessage(Utils.getInstance().convertArray(lines));
|
||||
}
|
||||
|
||||
public int getOfflineVotePartyVotes(User user) {
|
||||
return Data.getInstance().getData(user)
|
||||
.getInt("VoteParty.OfflineVotes");
|
||||
}
|
||||
|
||||
public int getTotalVotes() {
|
||||
return ServerData.getInstance().getData().getInt("VoteParty.Total");
|
||||
}
|
||||
|
||||
@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>();
|
||||
}
|
||||
|
||||
public void giveReward(User user) {
|
||||
if (Utils.getInstance().isPlayerOnline(user.getPlayerName())) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getVotePartyRewards()) {
|
||||
user.giveReward(ConfigRewards.getInstance().getReward(reward));
|
||||
}
|
||||
} else {
|
||||
setOfflineVotePartyVotes(user, getOfflineVotePartyVotes(user) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveRewards() {
|
||||
if (ConfigOtherRewards.getInstance().getVotePartyGiveAllPlayers()) {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
giveReward(user);
|
||||
}
|
||||
} else {
|
||||
for (String uuid : getVotedUsers()) {
|
||||
User user = new User(new UUID(uuid));
|
||||
giveReward(user);
|
||||
}
|
||||
}
|
||||
setVotedUsers(new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void setOfflineVotePartyVotes(User user, int value) {
|
||||
Data.getInstance().getData(user).set("VoteParty.OfflineVotes", value);
|
||||
}
|
||||
|
||||
public void setTotalVotes(int value) {
|
||||
ServerData.getInstance().getData().set("VoteParty.Total", value);
|
||||
ServerData.getInstance().saveData();
|
||||
}
|
||||
|
||||
public void setVotedUsers(ArrayList<String> value) {
|
||||
ServerData.getInstance().getData().set("VoteParty.Voted", value);
|
||||
ServerData.getInstance().saveData();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteReminding;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteReminding;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.Reward;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class VoteReminding {
|
||||
|
||||
static VoteReminding instance = new VoteReminding();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static VoteReminding getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private VoteReminding() {
|
||||
}
|
||||
|
||||
public VoteReminding(Main plugin) {
|
||||
VoteReminding.plugin = plugin;
|
||||
}
|
||||
|
||||
public void checkRemind(User user) {
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
if (Utils.getInstance().hasPermission(playerName,
|
||||
"VotingPlugin.Login.RemindVotes")
|
||||
|| Utils.getInstance().hasPermission(playerName,
|
||||
"VotingPlugin.Player")) {
|
||||
if (user.canVoteAll()) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
if (!ConfigVoteReminding.getInstance().getRemindOnlyOnce()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
} else if (!user.getReminded()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void loadRemindChecking() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(
|
||||
plugin,
|
||||
new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getServer()
|
||||
.getOnlinePlayers()) {
|
||||
User user = new User(player);
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
}, 10,
|
||||
ConfigVoteReminding.getInstance().getRemindDelay() * 20 * 60);
|
||||
}
|
||||
|
||||
public void runRemind(User user) {
|
||||
if (ConfigVoteReminding.getInstance().getEnabled() && user.canVoteAll()) {
|
||||
user.setReminded(true);
|
||||
for (String reward : ConfigVoteReminding.getInstance().getRewards()) {
|
||||
if (!reward.equalsIgnoreCase("")) {
|
||||
if (ConfigRewards.getInstance().getRewardFile(reward)
|
||||
.exists()) {
|
||||
|
||||
}
|
||||
Reward rewardFile = ConfigRewards.getInstance().getReward(
|
||||
reward);
|
||||
|
||||
rewardFile.giveReward(user);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,251 @@
|
||||
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.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));
|
||||
|
||||
boolean wasOnline = Boolean.valueOf(args.get(4));
|
||||
|
||||
String text = 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));
|
||||
String text = args.get(6);
|
||||
plugin.debug("pluginmessaging voteonline received from " + player + " on " + service);
|
||||
VotingPluginUser user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} 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 > 3) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevoteonline") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 3) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
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,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,611 @@
|
||||
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.event.PluginMessageEvent;
|
||||
import net.md_5.bungee.api.event.PostLoginEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
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) {
|
||||
if (player != null && player.isConnected() && cachedOnlineVotes.containsKey(uuid)) {
|
||||
ArrayList<OfflineBungeeVote> c = cachedOnlineVotes.get(uuid);
|
||||
if (!c.isEmpty()) {
|
||||
String 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.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);
|
||||
}
|
||||
}
|
||||
}, 15l, 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);
|
||||
|
||||
this.getProxy().registerChannel("vp:vp");
|
||||
} 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;
|
||||
}
|
||||
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();
|
||||
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);
|
||||
}
|
||||
|
||||
}, 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) {
|
||||
String uuid = getUUID(name);
|
||||
|
||||
if (config.getSendVotesToAllServers()) {
|
||||
sendServerMessage("bungeevote", uuid, name, service);
|
||||
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);
|
||||
if (config.getBroadcast()) {
|
||||
sendServerMessage("BungeeBroadcast", service, uuid, name);
|
||||
}
|
||||
sendServerMessage("BungeeUpdate");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void status(CommandSender sender) {
|
||||
sendServerMessage("status");
|
||||
}
|
||||
|
||||
public void vote(String player, String service, boolean realVote) {
|
||||
if (player == null || player.isEmpty()) {
|
||||
getLogger().info("No name from vote on " + service);
|
||||
return;
|
||||
}
|
||||
if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
sendSocketVote(player, service);
|
||||
} else if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
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));
|
||||
|
||||
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 (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));
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
} 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));
|
||||
cachedOnlineVotes.put(uuid, list);
|
||||
debug("Caching online vote for " + player + " on " + service);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 162 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user