Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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.Ben12345rocks</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/jdk1.8.0_261">
|
||||
<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,14 @@
|
||||
<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=
|
||||
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,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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large.
Load diff
File renamed without changes.
@@ -0,0 +1,111 @@
|
||||
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'
|
||||
|
||||
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.Ben12345rocks.VotingPlugin.bungee.Bungee
|
||||
author: Ben12345rocks
|
||||
@@ -0,0 +1,60 @@
|
||||
# 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
|
||||
|
||||
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: SOCKETS
|
||||
|
||||
# ----------------------------
|
||||
# SOCKET METHOD Only, ignore otherwise
|
||||
# ----------------------------
|
||||
FallBackServer: factions
|
||||
|
||||
# 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,230 @@
|
||||
name: ${project.name}
|
||||
version: ${project.version}
|
||||
main: com.Ben12345rocks.VotingPlugin.Main
|
||||
description: Highly Customizable Voting Listener!
|
||||
website: https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
author: Ben12345rocks
|
||||
softdepend: [MVdWPlaceholders, Votifier, 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
|
||||
adminvotesettotal:
|
||||
description: Command Alias
|
||||
aliases: avsettotal
|
||||
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
|
||||
adminvoteusers:
|
||||
description: Command Alias
|
||||
aliases: avusers
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteConvertFrom:
|
||||
description: Command Alias
|
||||
aliases: avConvertFrom
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteSetVotePartyCount:
|
||||
description: Command Alias
|
||||
aliases: avSetVotePartyCount
|
||||
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
|
||||
adminvoteUserEditValue:
|
||||
description: Command Alias
|
||||
aliases: avUserEditValue
|
||||
adminvoteSetRequestMethod:
|
||||
description: Command Alias
|
||||
aliases: avSetRequestMethod
|
||||
adminvoteUser:
|
||||
description: Command Alias
|
||||
aliases: avUser
|
||||
permissions:
|
||||
VotingPlugin.Player:
|
||||
description: Allows basic access player commands
|
||||
VotingPlugin.Mod:
|
||||
description: Allows mod access player commands
|
||||
VotingPlugin.Admin:
|
||||
description: Allows admin access player commands
|
||||
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
|
||||
|
||||
@@ -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,324 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.Ben12345rocks</groupId>
|
||||
<artifactId>VotingPlugin</artifactId>
|
||||
<version>5.23</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>
|
||||
</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.Ben12345rocks.AdvancedCore</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.AdvancedCore</shadedPattern>
|
||||
</relocation>
|
||||
<!-- Lets relocate the shaded API so we dont cause any conflicts with
|
||||
other plugins -->
|
||||
<relocation>
|
||||
<pattern>net.pl3x.bukkit.chatapi</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>me.mrten.mysqlapi</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.mysqlapi</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.HikariCP</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.HikariCP</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.slf4j.slf4j-simple</pattern>
|
||||
<shadedPattern>${project.groupId}.${project.artifactId}.slf4j-simple</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>Ben12345rocks</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>${project.artifactId}.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>master-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency> <groupId>com.Ben12345rocks</groupId> <artifactId>AdvancedCore</artifactId>
|
||||
<version>LATEST</version> <scope>compile</scope> </dependency> -->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.2-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>com.swifteh</groupId>
|
||||
<artifactId>GAL</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/GAListener.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mythicacraft</groupId>
|
||||
<artifactId>voteroulette</artifactId>
|
||||
<version>3.2.2</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/VoteRoulette.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.mimimum.minecraft</groupId>
|
||||
<artifactId>SuperbVote</artifactId>
|
||||
<version>0.5.3</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/SuperbVote-0.5.3.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>MVdWPlaceholderAPI</artifactId>
|
||||
<version>LATEST</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/Jars/MVdWPlaceholderAPI.jar</systemPath>
|
||||
</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>
|
||||
</dependencies>
|
||||
</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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package com.Ben12345rocks.VotingPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Encryption.EncryptionHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.PluginMessage.PluginMessage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.PluginMessage.PluginMessageHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Sockets.ClientHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Sockets.SocketHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Sockets.SocketReceiver;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.bungee.BungeeMethod;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public class BungeeHandler {
|
||||
private static BungeeHandler instance = new BungeeHandler();
|
||||
|
||||
public static BungeeHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Getter
|
||||
private SocketHandler socketHandler;
|
||||
|
||||
@Getter
|
||||
private ClientHandler clientHandler;
|
||||
|
||||
private EncryptionHandler encryptionHandler;
|
||||
|
||||
@Getter
|
||||
private BungeeMethod method;
|
||||
|
||||
public void close() {
|
||||
socketHandler.closeConnection();
|
||||
clientHandler.stopConnection();
|
||||
}
|
||||
|
||||
public void load() {
|
||||
Main.plugin.debug("Loading bungee handler");
|
||||
|
||||
method = BungeeMethod.getByName(Config.getInstance().getBungeeMethod());
|
||||
|
||||
Main.plugin.getLogger().info("Using BungeeMethod: " + method.toString());
|
||||
|
||||
if (method.equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
Main.plugin.registerBungeeChannels();
|
||||
|
||||
PluginMessage.getInstance().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));
|
||||
Main.plugin.debug("pluginmessaging vote received from " + player + " on " + service);
|
||||
User user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time);
|
||||
|
||||
if (Boolean.valueOf(args.get(4)) || Config.getInstance().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = Main.plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
Main.plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
PluginMessage.getInstance().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));
|
||||
Main.plugin.debug("pluginmessaging voteonline received from " + player + " on " + service);
|
||||
User user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
user.clearCache();
|
||||
|
||||
user.bungeeVotePluginMessaging(service, time);
|
||||
|
||||
if (Boolean.valueOf(args.get(4)) || Config.getInstance().isBungeeBroadcastAlways()) {
|
||||
VoteSite site = Main.plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
Main.plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
PluginMessage.getInstance().add(new PluginMessageHandler("VoteUpdate") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String player = args.get(0);
|
||||
Main.plugin.debug("pluginmessaging voteupdate received for " + player);
|
||||
User user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(player));
|
||||
user.clearCache();
|
||||
|
||||
user.offVote();
|
||||
|
||||
Main.plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
PluginMessage.getInstance().add(new PluginMessageHandler("VoteBroadcast") {
|
||||
@Override
|
||||
public void onRecieve(String subChannel, ArrayList<String> args) {
|
||||
String uuid = args.get(0);
|
||||
String service = args.get(1);
|
||||
User user = UserManager.getInstance().getVotingPluginUser(UUID.fromString(uuid));
|
||||
VoteSite site = Main.plugin.getVoteSite(service);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
Main.plugin.getLogger().warning("No votesite for " + service);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} else if (method.equals(BungeeMethod.SOCKETS)) {
|
||||
encryptionHandler = new EncryptionHandler(new File(Main.plugin.getDataFolder(), "secretkey.key"));
|
||||
|
||||
clientHandler = new ClientHandler(Config.getInstance().getBungeeServerHost(),
|
||||
Config.getInstance().getBungeeServerPort(), encryptionHandler,
|
||||
Config.getInstance().isBungeeDebug());
|
||||
|
||||
socketHandler = new SocketHandler(Main.plugin.getVersion(), Config.getInstance().getSpigotServerHost(),
|
||||
Config.getInstance().getSpigotServerPort(), encryptionHandler,
|
||||
Config.getInstance().isBungeeDebug());
|
||||
|
||||
socketHandler.add(new SocketReceiver("bungeevote") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 3) {
|
||||
Main.plugin.extraDebug("BungeeVote from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
User 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) {
|
||||
Main.plugin.extraDebug("BungeeVoteOnline from " + data[2] + ", processing");
|
||||
String uuid = data[1];
|
||||
User 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 = Main.plugin.getVoteSite(data[1]);
|
||||
String p = data[3];
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
if (site != null) {
|
||||
site.broadcastVote(user, false);
|
||||
} else {
|
||||
Main.plugin.getLogger().warning("No votesite for " + data[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("Status") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
if (data.length > 0) {
|
||||
Main.plugin.getLogger().info("Received status command, sending status back");
|
||||
sendData("StatusOkay", Main.plugin.getOptions().getServer());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
socketHandler.add(new SocketReceiver("BungeeUpdate") {
|
||||
|
||||
@Override
|
||||
public void onReceive(String[] data) {
|
||||
Main.plugin.setUpdate(true);
|
||||
}
|
||||
});
|
||||
|
||||
if (Main.plugin.getOptions().getServer().equalsIgnoreCase("pleaseset")) {
|
||||
Main.plugin.getLogger().warning("Server name for bungee voting is not set, please set it");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sendData(String... strings) {
|
||||
clientHandler.sendMessage(strings);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+32
-315
@@ -1,359 +1,76 @@
|
||||
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.AdvancedCore.CommandAPI.CommandHandler;
|
||||
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;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAdminVote.
|
||||
*/
|
||||
public class CommandAdminVote implements CommandExecutor {
|
||||
|
||||
/** The instance. */
|
||||
private static CommandAdminVote instance = new CommandAdminVote();
|
||||
|
||||
/**
|
||||
* Gets the single instance of CommandAdminVote.
|
||||
*
|
||||
* @return single instance of CommandAdminVote
|
||||
*/
|
||||
public static CommandAdminVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
ConfigOtherRewards bonusReward = ConfigOtherRewards.getInstance();
|
||||
|
||||
/** The config. */
|
||||
Config config = Config.getInstance();
|
||||
|
||||
ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
/** The vote sites. */
|
||||
ConfigVoteSites voteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/**
|
||||
* Instantiates a new command admin vote.
|
||||
*/
|
||||
private CommandAdminVote() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command admin vote.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CommandAdminVote(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
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))));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||
String[] args) {
|
||||
|
||||
for (CommandHandler commandHandler : plugin.adminVoteCommand) {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (CommandHandler commandHandler : plugin.getAdminVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "No valid arguments, see /adminvote help!");
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+38
-21
@@ -7,23 +7,37 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.CommandHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandAliases.
|
||||
*/
|
||||
public class CommandAliases implements CommandExecutor {
|
||||
|
||||
/** The plugin. */
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
/** The cmd handle. */
|
||||
private CommandHandler cmdHandle;
|
||||
|
||||
public CommandAliases(CommandHandler cmdHandle) {
|
||||
private boolean adminCommand;
|
||||
|
||||
public CommandAliases(CommandHandler cmdHandle, boolean adminCommand) {
|
||||
this.cmdHandle = cmdHandle;
|
||||
this.adminCommand = adminCommand;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
ArrayList<String> argsNew = new ArrayList<String>();
|
||||
argsNew.add(cmdHandle.getArgs()[0]);
|
||||
@@ -31,18 +45,20 @@ public class CommandAliases implements CommandExecutor {
|
||||
argsNew.add(arg);
|
||||
}
|
||||
plugin.debug("Attempting cmd...");
|
||||
plugin.debug("Inputed args: "
|
||||
+ Utils.getInstance().makeStringList(argsNew));
|
||||
plugin.debug("Inputed args: " + ArrayUtils.getInstance().makeStringList(argsNew));
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
cmdHandlers.addAll(plugin.adminVoteCommand);
|
||||
for (CommandHandler cmdHandle : cmdHandlers) {
|
||||
ArrayList<CommandHandler> handles = new ArrayList<CommandHandler>();
|
||||
if (adminCommand) {
|
||||
handles.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
handles.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : handles) {
|
||||
if (cmdHandle.getArgs().length > args.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName()
|
||||
.equalsIgnoreCase("adminvote" + arg)) {
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
argsNew.set(0, arg);
|
||||
|
||||
boolean argsMatch = true;
|
||||
@@ -56,8 +72,7 @@ public class CommandAliases implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (argsMatch) {
|
||||
if (cmdHandle.runCommand(sender, Utils
|
||||
.getInstance().convertArray(argsNew))) {
|
||||
if (cmdHandle.runCommand(sender, ArrayUtils.getInstance().convert(argsNew))) {
|
||||
plugin.debug("cmd found, ran cmd");
|
||||
return true;
|
||||
}
|
||||
@@ -68,15 +83,17 @@ public class CommandAliases implements CommandExecutor {
|
||||
}
|
||||
|
||||
/*
|
||||
* 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; } }
|
||||
* 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!");
|
||||
if (adminCommand) {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /adminvote help!");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No valid arguments, see /vote help!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+30
-320
@@ -1,358 +1,68 @@
|
||||
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.AdvancedCore.CommandAPI.CommandHandler;
|
||||
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;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CommandVote.
|
||||
*/
|
||||
public class CommandVote implements CommandExecutor {
|
||||
|
||||
/** The instance. */
|
||||
private static CommandVote instance = new CommandVote();
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of CommandVote.
|
||||
*
|
||||
* @return single instance of CommandVote
|
||||
*/
|
||||
public static CommandVote getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*/
|
||||
private CommandVote() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new command vote.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CommandVote(Main plugin) {
|
||||
CommandVote.plugin = plugin;
|
||||
}
|
||||
|
||||
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!");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.
|
||||
* CommandSender , org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label,
|
||||
String[] args) {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
for (CommandHandler commandHandler : plugin.voteCommand) {
|
||||
for (CommandHandler commandHandler : plugin.getVoteCommand()) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// invalid command
|
||||
sender.sendMessage(ChatColor.RED
|
||||
+ "No valid arguments, see /vote help!");
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.EditGUI;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.EditGUIButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueBoolean;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueList;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueNumber;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.EditGUI.ValueTypes.EditGUIValueString;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.InputMethod;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequestBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class AdminGUI {
|
||||
static AdminGUI instance = new AdminGUI();
|
||||
|
||||
/**
|
||||
* Gets the single instance of Commands.
|
||||
*
|
||||
* @return single instance of Commands
|
||||
*/
|
||||
public static AdminGUI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*/
|
||||
private AdminGUI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI.
|
||||
*
|
||||
* @return ArrayList of buttons
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
|
||||
buttons.add(new BInventoryButton("&cVoteSites",
|
||||
new String[] { "&cOnly enabled sites are listed in this section", "&cMiddle Click to create" },
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
ConfigVoteSites.getInstance().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openAdminGUIVoteSites(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", new String[] {}, new ItemStack(Material.STONE, 1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
plugin.reload();
|
||||
}
|
||||
|
||||
});
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void loadHook() {
|
||||
for (BInventoryButton b : adminGUIButtons()) {
|
||||
com.Ben12345rocks.AdvancedCore.Commands.GUI.AdminGUI.getInstance().addButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote sites.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public void openAdminGUIVoteSites(Player player) {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
lore.add("Name: " + voteSite.getDisplayName());
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
|
||||
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote site site.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
*/
|
||||
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
|
||||
EditGUI inv = new EditGUI("VoteSite: " + voteSite.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", voteSite);
|
||||
|
||||
inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ArrayList<String> playerNames = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
new ValueRequestBuilder(new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(site, value, site.getServiceSite(), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
.allowCustomOption(true).request(event.getWhoClicked());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("Priority", voteSite.getPriority()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().setPriority(voteSite.getKey(), num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("ServiceSite", voteSite.getServiceSite()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setServiceSite(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("Name", voteSite.getDisplayName()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().setDisplayName(voteSite.getKey(), value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueString("VoteURL", voteSite.getVoteURL()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteURL(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueNumber("VoteDelay", voteSite.getVoteDelay()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, Number num) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelay(siteName, num.intValue());
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("Enabled", voteSite.isEnabled()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setEnabled(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("ForceOffline", voteSite.isGiveOffline()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setForceOffline(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
inv.addButton(new EditGUIButton(new EditGUIValueBoolean("VoteDelayDaily", voteSite.isVoteDelayDaily()) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelayDaily(siteName, value);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
|
||||
if (voteSite.getSiteData().isList("Rewards")) {
|
||||
|
||||
inv.addButton(
|
||||
new EditGUIButton(new EditGUIValueList("Rewards", voteSite.getSiteData().getStringList("Rewards")) {
|
||||
|
||||
@Override
|
||||
public void setValue(Player p, ArrayList<String> rewards) {
|
||||
VoteSite voteSite = (VoteSite) getInv().getMeta(player, "VoteSite");
|
||||
ConfigVoteSites.getInstance().set(voteSite.getKey(), "Rewards", rewards);
|
||||
plugin.reload();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,876 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.NMSManager.NMSManager;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardOptions;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoterHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class PlayerGUIs {
|
||||
static PlayerGUIs instance = new PlayerGUIs();
|
||||
|
||||
/**
|
||||
* Gets the single instance of Commands.
|
||||
*
|
||||
* @return single instance of Commands
|
||||
*/
|
||||
public static PlayerGUIs getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*/
|
||||
private PlayerGUIs() {
|
||||
}
|
||||
|
||||
public BInventoryButton getBackButton() {
|
||||
ConfigurationSection sec = Config.getInstance().getBackButton();
|
||||
ItemBuilder item;
|
||||
if (sec != null) {
|
||||
item = new ItemBuilder(sec);
|
||||
} else {
|
||||
item = new ItemBuilder(Material.BARRIER, 1).setName("&8Back to VoteGUI");
|
||||
}
|
||||
|
||||
BInventoryButton b = new BInventoryButton(item) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getWhoClicked(), getSelectedPlayer(event.getWhoClicked()));
|
||||
}
|
||||
};
|
||||
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
b.dontClose();
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
public User getSelectedPlayer(Player player) {
|
||||
User str = (User) PlayerUtils.getInstance().getPlayerMeta(player, "SelectedPlayerGUIs");
|
||||
return str;
|
||||
}
|
||||
|
||||
public void openVoteBest(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteBestName(), "player", user.getPlayerName()));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestDayBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestWeekBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestMonthBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteGUI(Player player, User user) {
|
||||
if (user == null) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
setSelectedPlayer(player, user);
|
||||
}
|
||||
if ((!player.getName().equals(user.getPlayerName())
|
||||
&& !player.hasPermission("VotingPlugin.Commands.Vote.GUI.Other")
|
||||
&& !player.hasPermission("VotingPlugin.Mod"))
|
||||
|| (!player.hasPermission("VotingPlugin.Commands.Vote.GUI")
|
||||
&& !player.hasPermission("VotingPlugin.Player"))) {
|
||||
player.sendMessage(StringParser.getInstance().colorize(Main.plugin.getOptions().getFormatNoPerms()));
|
||||
return;
|
||||
}
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteGUIName(), "player", user.getPlayerName()));
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
for (String slot : Config.getInstance().getVoteGUISlots()) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteGUISlotSection(slot));
|
||||
|
||||
String[] lore = new String[1];
|
||||
|
||||
lore = ArrayUtils.getInstance().convert(Config.getInstance().getVoteGUISlotLore(slot));
|
||||
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
lore = new String[] { "&aClick me" };
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
lore = Commands.getInstance().voteCommandNext(user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
lore = Commands.getInstance().voteCommandLast(user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
lore = Commands.getInstance().voteCommandTotal(user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
String str = Config.getInstance().getVoteTopDefault();
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterMonthly(1);
|
||||
} else if (str.equalsIgnoreCase("weekly")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterWeekly(1);
|
||||
} else if (str.equalsIgnoreCase("daily")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterDaily(1);
|
||||
} else {
|
||||
lore = TopVoterHandler.getInstance().topVoterAllTime(1);
|
||||
}
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
lore = Commands.getInstance().voteToday();
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
lore = new String[] { "Click to view help" };
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("points", "" + user.getPoints());
|
||||
|
||||
builder.setPlaceholders(placeholders);
|
||||
builder.setLore(ArrayUtils.getInstance().convert(lore));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
String cmd = Config.getInstance().getVoteGUISlotCommand(slot);
|
||||
User user = getSelectedPlayer(player);
|
||||
if (cmd.equalsIgnoreCase("none")) {
|
||||
return;
|
||||
} else if (!cmd.equals("")) {
|
||||
event.runSync(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand(cmd);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
user.sendMessage(Commands.getInstance().voteURLs(user, true));
|
||||
event.closeInventory();
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
openVoteNext(player, user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
openVoteLast(player, user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
openVoteTotal(player, user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
openVoteTop(player, null);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
openVoteToday(player);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
openVoteShop(player);
|
||||
} else if (slot.equalsIgnoreCase("lastmonth")) {
|
||||
openVoteTopLastMonth(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteLast(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteLastName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandLastLine(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteLastBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteNext(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteNextName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandNextInfo(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteNextBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringParser.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (final String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
int limit = Config.getInstance().getIdentifierLimit(identifier);
|
||||
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Config.getInstance().getVoteShopNotBuyable(identifier)) {
|
||||
if (hasPerm && (limitPass || !Config.getInstance().isVoteShopHideLimitedReached())) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
event.getButton().getInv().closeInv(player, null);
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (Config.getInstance().isClearCacheOnVoteShopPurchase()) {
|
||||
user.clearCache();
|
||||
}
|
||||
String identifier = (String) getData("identifier");
|
||||
int limit = (int) getData("Limit");
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
if (identifier != null) {
|
||||
|
||||
// limit fail-safe, should never be needed, except in rare cases
|
||||
boolean limitPass = true;
|
||||
if (limit > 0) {
|
||||
if (user.getVoteShopIdentifierLimit(identifier) >= limit) {
|
||||
limitPass = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (limitPass) {
|
||||
if (!Config.getInstance().isVoteShopRequireConfirmation()) {
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier",
|
||||
Config.getInstance().getIdentifierIdentifierName(identifier));
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopPurchaseMsg(), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier,
|
||||
user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
} else {
|
||||
openVoteShopConfirmation(player, identifier);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getVoteShopLimitReached());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}.addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
} else {
|
||||
if (hasPerm) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
}
|
||||
|
||||
}.dontClose().addData("identifier", identifier).addData("Limit", limit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteShopConfirmation(Player player, String identifier) {
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "ident", identifier);
|
||||
BInventory inv = new BInventory("Confirm Purchase?");
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.EMERALD_BLOCK).setName("&aYes")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
String ident = (String) PlayerUtils.getInstance().getPlayerMeta(event.getPlayer(), "ident");
|
||||
User user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
|
||||
int points = Config.getInstance().getIdentifierCost(ident);
|
||||
int limit = Config.getInstance().getIdentifierLimit(identifier);
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("identifier", identifier);
|
||||
placeholders.put("points", "" + points);
|
||||
placeholders.put("limit", "" + limit);
|
||||
if (user.removePoints(points)) {
|
||||
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier),
|
||||
new RewardOptions().setPlaceholders(placeholders));
|
||||
|
||||
user.sendMessage(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getFormatShopPurchaseMsg(), placeholders));
|
||||
if (limit > 0) {
|
||||
user.setVoteShopIdentifierLimit(identifier, user.getVoteShopIdentifierLimit(identifier) + 1);
|
||||
}
|
||||
} else {
|
||||
user.sendMessage(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getFormatShopFailedMsg(), placeholders));
|
||||
}
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
event.getPlayer().closeInventory();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.BARRIER).setName("&cNo")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().closeInventory();
|
||||
}
|
||||
});
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteStreak(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteStreakName(), "player", user.getPlayerName()));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteStreakBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteToday(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
for (User user : plugin.getVoteToday().keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.getVoteToday().get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.getVoteToday().get(user).get(voteSite).format(formatter);
|
||||
String msg = Config.getInstance().getGUIVoteTodayLine();
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("VoteSite", voteSite.getDisplayName());
|
||||
placeholders.put("Time", timeString);
|
||||
msg = StringParser.getInstance().replacePlaceHolder(msg, placeholders);
|
||||
ItemBuilder item = null;
|
||||
if (Config.getInstance().isGUIVoteTodayUseSkull() && !NMSManager.getInstance().isVersion("1.12")) {
|
||||
item = new ItemBuilder(new ItemStack(Material.PLAYER_HEAD, 1)).setSkullOwner(player);
|
||||
} else {
|
||||
item = new ItemBuilder(Config.getInstance().getGUIVoteTodayPlayerItem());
|
||||
}
|
||||
item.setName(StringParser.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteTodayIconTitle(), "player", user.getPlayerName()));
|
||||
item.setLore(msg);
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(item) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = UserManager.getInstance()
|
||||
.getVotingPluginUser(clickEvent.getClickedItem().getItemMeta().getDisplayName());
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTodayBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteTop(Player player, TopVoter top) {
|
||||
try {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
Set<Entry<User, Integer>> users = null;
|
||||
|
||||
String topVoter = top.getName();
|
||||
@SuppressWarnings("unchecked")
|
||||
LinkedHashMap<User, Integer> topVotes = (LinkedHashMap<User, Integer>) plugin.getTopVoter(top).clone();
|
||||
users = topVotes.entrySet();
|
||||
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTopName(), "topvoter", topVoter));
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<User, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (Config.getInstance().isGuiVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(
|
||||
Material.valueOf(Config.getInstance().getGuiVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = (User) getData("User");
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Config.getInstance().getGUIVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
openVoteTop(player, cur.next());
|
||||
} else {
|
||||
openVoteTop(player, cur.prev());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(getBackButton().setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void openVoteTopLastMonth(Player player) {
|
||||
Set<Entry<User, Integer>> users = null;
|
||||
|
||||
users = plugin.getLastMonthTopVoter().entrySet();
|
||||
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTopName(), "topvoter", "Last Month"));
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
int pos = 1;
|
||||
for (Entry<User, Integer> entry : users) {
|
||||
ItemBuilder playerItem;
|
||||
|
||||
if (Config.getInstance().isGuiVoteTopUseSkull()) {
|
||||
playerItem = new ItemBuilder(entry.getKey().getPlayerHead());
|
||||
} else {
|
||||
playerItem = new ItemBuilder(Material.valueOf(Config.getInstance().getGuiVoteTopPlayerItemMaterial()));
|
||||
}
|
||||
|
||||
playerItem.setLore(new ArrayList<String>());
|
||||
|
||||
inv.addButton(new BInventoryButton(playerItem.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore()).addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = (User) getData("User");
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()).addData("User", entry.getKey()));
|
||||
pos++;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(getBackButton().setSlot(1));
|
||||
}
|
||||
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteTotal(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTotalName(), "player", user.getPlayerName()));
|
||||
|
||||
for (TopVoter top : TopVoter.values()) {
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalItem(top))
|
||||
.addPlaceholder("Total", "" + user.getTotal(top)).addPlaceholder("topvoter", top.getName())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTotalBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote URL.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public void openVoteURL(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteURLName());
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
|
||||
int count = 0;
|
||||
if (Config.getInstance().getVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = new ItemBuilder(
|
||||
Config.getInstance().getVoteURLAlreadyVotedAllUrlsButtonItemSection());
|
||||
if (Config.getInstance().isGuiVoteURLAllUrlsButtonrequireAllSitesVoted()) {
|
||||
if (user.canVoteAny()) {
|
||||
builderAll = new ItemBuilder(Config.getInstance().getVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
} else {
|
||||
if (user.canVoteAll()) {
|
||||
builderAll = new ItemBuilder(Config.getInstance().getVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
}
|
||||
|
||||
if (!builderAll.hasCustomDisplayName()) {
|
||||
builderAll.setName("&4All Voting Sites");
|
||||
}
|
||||
if (!builderAll.hasCustomLore()) {
|
||||
builderAll.setLore("&cClick Me");
|
||||
}
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builderAll) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
|
||||
user.sendMessage(Commands.getInstance().voteURLs(user, true));
|
||||
}
|
||||
});
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
for (final VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteURLAlreadyVotedItemSection());
|
||||
if (user.canVoteSite(voteSite)) {
|
||||
builder = new ItemBuilder(Config.getInstance().getVoteURLCanVoteItemSection());
|
||||
} else {
|
||||
builder.addLoreLine(Config.getInstance().getVoteURLNextVote().replace("%Info%",
|
||||
Commands.getInstance().voteCommandNextInfo(user, voteSite)));
|
||||
}
|
||||
|
||||
builder.setName(Config.getInstance().getVoteURLSiteName().replace("%Name%", voteSite.getDisplayName()));
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player != null) {
|
||||
if (Config.getInstance().isCommandsVoteRewardFromVoteURL()
|
||||
&& event.getClick().equals(ClickType.RIGHT)) {
|
||||
voteReward(player, voteSite.getKey());
|
||||
} else {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringParser.getInstance().replacePlaceHolder(StringParser.getInstance()
|
||||
.replacePlaceHolder(StringParser.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteURLBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteURL(Player player, String voteSite) {
|
||||
if (!plugin.isVoteSite(voteSite)) {
|
||||
player.sendMessage("Not a valid votesite");
|
||||
return;
|
||||
}
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
VoteSite site = plugin.getVoteSite(voteSite);
|
||||
BInventory inv = new BInventory(StringParser.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteURLSiteName(), "site", site.getDisplayName()));
|
||||
inv.setMeta(player, "VoteSite", site);
|
||||
if (!Config.getInstance().isAlwaysCloseInventory()) {
|
||||
inv.dontClose();
|
||||
}
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.BOW).setName("&4URL").addLoreLine("Click to see URL")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VoteSite site = (VoteSite) clickEvent.getMeta("VoteSite");
|
||||
clickEvent.getWhoClicked().sendMessage(site.getVoteURL());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&4Next Vote")
|
||||
.addLoreLine(Commands.getInstance().voteCommandNextInfo(user, site))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
openVoteURL(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.CLOCK).setName("&4Last Vote")
|
||||
.addLoreLine(Commands.getInstance().voteCommandLastLine(user, site))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
openVoteURL(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteURLBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void setSelectedPlayer(Player player, User user) {
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "SelectedPlayerGUIs", user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote reward.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param siteName
|
||||
* the site name
|
||||
*/
|
||||
public void voteReward(Player player, String siteName) {
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteRewardName());
|
||||
|
||||
if ((siteName == null) || (siteName == "")) {
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
try {
|
||||
ItemBuilder builder = voteSite.getItem();
|
||||
|
||||
inv.addButton(new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
voteReward(player, (String) getData("site"));
|
||||
}
|
||||
}.addData("site", voteSite.getKey()));
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (String itemName : Config.getInstance().getVoteSiteItems(siteName)) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteSiteItemsSection(siteName, itemName));
|
||||
|
||||
inv.addButton(Config.getInstance().getVoteSiteItemsSlot(siteName, itemName),
|
||||
new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().isVoteRewardBackButton()) {
|
||||
inv.addButton(getBackButton());
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
+26
-90
@@ -2,115 +2,51 @@ package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
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;
|
||||
|
||||
/**
|
||||
* The Class AdminVoteTabCompleter.
|
||||
*/
|
||||
public class AdminVoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd,
|
||||
String alias, String[] args) {
|
||||
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>();
|
||||
|
||||
List<String> tab = new ArrayList<String>();
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getAdminVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
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));
|
||||
}
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+42
-81
@@ -2,110 +2,70 @@ package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* The Class AliasesTabCompleter.
|
||||
*/
|
||||
public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/** The cmd handle. */
|
||||
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;
|
||||
}
|
||||
private boolean adminCommand;
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd,
|
||||
String alias, String[] argsIn) {
|
||||
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);
|
||||
String[] args = ArrayUtils.getInstance().convert(msgArray);
|
||||
|
||||
ArrayList<String> tab = new ArrayList<String>();
|
||||
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
ArrayList<CommandHandler> cmdHandlers = new ArrayList<CommandHandler>();
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
cmdHandlers.addAll(plugin.adminVoteCommand);
|
||||
|
||||
if (adminCommand) {
|
||||
cmdHandlers.addAll(plugin.getAdminVoteCommand());
|
||||
} else {
|
||||
cmdHandlers.addAll(plugin.getVoteCommand());
|
||||
}
|
||||
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance()
|
||||
.getTabCompleteOptions();
|
||||
for (CommandHandler cmdHandle : cmdHandlers) {
|
||||
if (cmdHandle.getArgs().length >= argsIn.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName()
|
||||
.equalsIgnoreCase("adminvote" + arg)) {
|
||||
// plugin.debug("Found cmd... attempting to get tab complete");
|
||||
|| 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++) {
|
||||
@@ -118,8 +78,7 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
|
||||
if (argsMatch) {
|
||||
|
||||
cmds.addAll(getTabCompleteOptions(sender, args,
|
||||
argsIn.length, cmdHandle));
|
||||
cmds.addAll(cmdHandle.getTabCompleteOptions(sender, args, argsIn.length, tabCompletes));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -127,18 +86,20 @@ public class AliasesTabCompleter implements TabCompleter {
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < cmds.size(); i++) {
|
||||
if (Utils.getInstance().startsWithIgnoreCase(cmds.get(i),
|
||||
args[argsIn.length])) {
|
||||
tab.add(cmds.get(i));
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd) {
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd, boolean adminCommand) {
|
||||
cmdHandle = cmd;
|
||||
this.adminCommand = adminCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+27
-89
@@ -2,114 +2,52 @@ package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.CommandAPI.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
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;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteTabCompleter.
|
||||
*/
|
||||
public class VoteTabCompleter implements TabCompleter {
|
||||
|
||||
/** The plugin. */
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.command.TabCompleter#onTabComplete(org.bukkit.command.
|
||||
* CommandSender, org.bukkit.command.Command, java.lang.String,
|
||||
* java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command cmd,
|
||||
String alias, String[] args) {
|
||||
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> tab = new ArrayList<String>();
|
||||
Set<String> cmds = new HashSet<String>();
|
||||
|
||||
ArrayList<String> cmds = new ArrayList<String>();
|
||||
cmds.addAll(TabCompleteHandler.getInstance().getTabCompleteOptions(plugin.getVoteCommand(), sender, args,
|
||||
args.length - 1));
|
||||
|
||||
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));
|
||||
}
|
||||
for (String str : cmds) {
|
||||
if (StringParser.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
|
||||
return tab;
|
||||
|
||||
}
|
||||
return null;
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,105 +6,182 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFile;
|
||||
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 {
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ConfigVoteSites.
|
||||
*/
|
||||
public class ConfigVoteSites extends YMLFile {
|
||||
|
||||
/** The instance. */
|
||||
static ConfigVoteSites instance = new ConfigVoteSites();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of ConfigVoteSites.
|
||||
*
|
||||
* @return single instance of ConfigVoteSites
|
||||
*/
|
||||
public static ConfigVoteSites getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private ConfigVoteSites() {
|
||||
}
|
||||
|
||||
public ConfigVoteSites(Main plugin) {
|
||||
ConfigVoteSites.plugin = plugin;
|
||||
/**
|
||||
* Instantiates a new config vote sites.
|
||||
*/
|
||||
public ConfigVoteSites() {
|
||||
super(new File(Main.plugin.getDataFolder(), "VoteSites.yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate vote site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
*/
|
||||
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>());
|
||||
if (Config.getInstance().isAutoCreateVoteSites()) {
|
||||
String org = siteName;
|
||||
siteName = siteName.replace(".", "_");
|
||||
plugin.getLogger().warning("VoteSite " + siteName
|
||||
+ " does not exist, creating one, set AutoCreateVoteSites to false to prevent this");
|
||||
setEnabled(siteName, true);
|
||||
setServiceSite(siteName, org);
|
||||
setVoteURL(siteName, "VoteURL");
|
||||
setVoteDelay(siteName, 24);
|
||||
set(siteName, "DisplayItem.Material", "GRASS");
|
||||
set(siteName, "DisplayItem.Amount", 1);
|
||||
set(siteName, "Rewards.Messages.Player", "&aThanks for voting on %ServiceSite%!");
|
||||
|
||||
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");
|
||||
}
|
||||
plugin.loadVoteSites();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getCumulativeRewards(String siteName) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(siteName).getList(
|
||||
"Cumulative.Rewards");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (p.hasPermission("VotingPlugin.Admin.GenerateServiceSite") || p.isOp()) {
|
||||
p.sendMessage(StringParser.getInstance().colorize("&cGenerating votesite for service site "
|
||||
+ siteName + ", please check console for details"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getCumulativeRewardVotesAmount(String siteName) {
|
||||
return getData(siteName).getInt("Cumulative.Votes");
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData(String siteName) {
|
||||
return getData().getConfigurationSection("VoteSites." + siteName);
|
||||
}
|
||||
|
||||
public FileConfiguration getData(String siteName) {
|
||||
File dFile = getVoteSiteFile(siteName);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
return data;
|
||||
public String getDisplayName(String site) {
|
||||
return getData(site).getString("Name");
|
||||
}
|
||||
|
||||
public String getEverySiteRewardPath() {
|
||||
return "EverySiteReward";
|
||||
}
|
||||
|
||||
public ConfigurationSection getItem(String site) {
|
||||
if (getData(site).isConfigurationSection("DisplayItem")) {
|
||||
return getData(site).getConfigurationSection("DisplayItem");
|
||||
}
|
||||
return getData(site).getConfigurationSection("Item");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the priority
|
||||
*/
|
||||
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>();
|
||||
}
|
||||
/**
|
||||
* Gets the rewards.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the rewards
|
||||
*/
|
||||
public String getRewardsPath(String siteName) {
|
||||
return "VoteSites." + siteName + ".Rewards";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the service site
|
||||
*/
|
||||
public String getServiceSite(String siteName) {
|
||||
return getData(siteName).getString("ServiceSite");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the vote delay
|
||||
*/
|
||||
public int getVoteDelay(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelay");
|
||||
}
|
||||
|
||||
public int getTimeOffSet(String siteName) {
|
||||
return getData(siteName).getInt("TimeOffSet", 0);
|
||||
}
|
||||
|
||||
public int getVoteDelayMin(String siteName) {
|
||||
return getData(siteName).getInt("VoteDelayMin", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site enabled.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the vote site enabled
|
||||
*/
|
||||
public boolean getVoteSiteEnabled(String siteName) {
|
||||
return getData(siteName).getBoolean("Enabled");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site file.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the vote site file
|
||||
*/
|
||||
public File getVoteSiteFile(String siteName) {
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "VoteSites", siteName + ".yml");
|
||||
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!");
|
||||
plugin.getLogger().severe(ChatColor.RED + "Could not create VoteSites/" + siteName + ".yml!");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -112,33 +189,27 @@ public class ConfigVoteSites {
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<VoteSite> getVoteSites() {
|
||||
if (plugin.voteSites != null) {
|
||||
return plugin.voteSites;
|
||||
} else {
|
||||
plugin.loadVoteSites();
|
||||
return plugin.voteSites;
|
||||
}
|
||||
public boolean getVoteSiteGiveOffline(String site) {
|
||||
return getData(site).getBoolean("ForceOffline", getData(site).getBoolean("GiveOffline"));
|
||||
}
|
||||
|
||||
public ArrayList<String> getVoteSitesFiles() {
|
||||
File folder = new File(plugin.getDataFolder() + File.separator
|
||||
+ "VoteSites");
|
||||
String[] fileNames = folder.list();
|
||||
return Utils.getInstance().convertArray(fileNames);
|
||||
public boolean getVoteSiteResetVoteDelayDaily(String siteName) {
|
||||
return getData(siteName).getBoolean("VoteDelayDaily");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote sites load.
|
||||
*
|
||||
* @return the vote sites load
|
||||
*/
|
||||
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 (getVoteSiteEnabled(site) && !site.equalsIgnoreCase("null")) {
|
||||
if (!siteCheck(site)) {
|
||||
plugin.getLogger().warning(
|
||||
"Failed to load site " + site + ", see above");
|
||||
plugin.getLogger().warning("Failed to load site " + site + ", see above");
|
||||
} else {
|
||||
voteSites.add(new VoteSite(site));
|
||||
}
|
||||
@@ -149,8 +220,8 @@ public class ConfigVoteSites {
|
||||
Collections.sort(voteSites, new Comparator<VoteSite>() {
|
||||
@Override
|
||||
public int compare(VoteSite v1, VoteSite v2) {
|
||||
int v1P = getPriority(v1.getSiteName());
|
||||
int v2P = getPriority(v2.getSiteName());
|
||||
int v1P = v1.getPriority();
|
||||
int v2P = v2.getPriority();
|
||||
|
||||
if (v1P < v2P) {
|
||||
return 1;
|
||||
@@ -166,19 +237,20 @@ public class ConfigVoteSites {
|
||||
return voteSites;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote sites names.
|
||||
*
|
||||
* @return the vote sites names
|
||||
*/
|
||||
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", ""));
|
||||
ArrayList<String> siteNames = new ArrayList<String>();
|
||||
if (getData().isConfigurationSection("VoteSites")) {
|
||||
siteNames = ArrayUtils.getInstance().convert(getData().getConfigurationSection("VoteSites").getKeys(false));
|
||||
}
|
||||
|
||||
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")
|
||||
if (!getVoteSiteEnabled(siteNames.get(i)) || siteNames.get(i).equalsIgnoreCase("null")
|
||||
|| !siteCheck(siteNames.get(i))) {
|
||||
// plugin.getLogger().info("Removed: " + siteNames.get(i));
|
||||
siteNames.remove(i);
|
||||
@@ -190,104 +262,206 @@ public class ConfigVoteSites {
|
||||
return siteNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL(String siteName) {
|
||||
return getData(siteName).getString("VoteURL");
|
||||
}
|
||||
|
||||
public boolean getWaitUntilVoteDelay(String siteName) {
|
||||
return getData(siteName).getBoolean("WaitUntilVoteDelay", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is service site good.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return true, if is service site good
|
||||
*/
|
||||
public boolean isServiceSiteGood(String siteName) {
|
||||
if (getServiceSite(siteName) == null) {
|
||||
return false;
|
||||
} else if (getServiceSite(siteName).equalsIgnoreCase("")) {
|
||||
if (getServiceSite(siteName) == null || getServiceSite(siteName).equals("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is vote URL good.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return true, if is vote URL good
|
||||
*/
|
||||
public boolean isVoteURLGood(String siteName) {
|
||||
if (getVoteURL(siteName) == null) {
|
||||
return false;
|
||||
} else if (getVoteURL(siteName).equalsIgnoreCase("")) {
|
||||
if (getVoteURL(siteName) == null || getVoteURL(siteName).equals("")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean renameVoteSite(String siteName, String newName) {
|
||||
return getVoteSiteFile(siteName).renameTo(
|
||||
new File(plugin.getDataFolder() + File.separator + "VoteSites",
|
||||
newName + ".yml"));
|
||||
@Override
|
||||
public void onFileCreation() {
|
||||
plugin.saveResource("VoteSites.yml", true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename vote site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param newName
|
||||
* the new name
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean renameVoteSite(String siteName, String newName) {
|
||||
return getVoteSiteFile(siteName)
|
||||
.renameTo(new File(plugin.getDataFolder() + File.separator + "VoteSites", newName + ".yml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param path
|
||||
* the path
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void set(String siteName, String path, Object value) {
|
||||
// String playerName = user.getPlayerName();
|
||||
File dFile = getVoteSiteFile(siteName);
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
ConfigurationSection data = getData(siteName);
|
||||
if (data == null) {
|
||||
getData().createSection("VoteSites." + siteName);
|
||||
data = getData(siteName);
|
||||
}
|
||||
data.set(path, value);
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cumulative rewards.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setCumulativeRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Cumulative.Rewards", value);
|
||||
}
|
||||
|
||||
public void setCumulativeVotes(String siteName, int value) {
|
||||
set(siteName, "Cumulative.Votes", value);
|
||||
}
|
||||
|
||||
public void setDisplayName(String siteName, String value) {
|
||||
set(siteName, "Name", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param disabled
|
||||
* the disabled
|
||||
*/
|
||||
public void setEnabled(String siteName, boolean disabled) {
|
||||
set(siteName, "Enabled", disabled);
|
||||
}
|
||||
|
||||
public void setForceOffline(String siteName, boolean value) {
|
||||
set(siteName, "ForceOffline", value);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setPriority(String siteName, int value) {
|
||||
set(siteName, "Priority", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the rewards.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setRewards(String siteName, ArrayList<String> value) {
|
||||
set(siteName, "Rewards", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the service site.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param serviceSite
|
||||
* the service site
|
||||
*/
|
||||
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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote delay.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param voteDelay
|
||||
* the vote delay
|
||||
*/
|
||||
public void setVoteDelay(String siteName, int voteDelay) {
|
||||
set(siteName, "VoteDelay", voteDelay);
|
||||
}
|
||||
|
||||
public void setVoteDelayDaily(String siteName, boolean value) {
|
||||
set(siteName, "VoteDelayDaily", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @param url
|
||||
* the url
|
||||
*/
|
||||
public void setVoteURL(String siteName, String url) {
|
||||
set(siteName, "VoteURL", url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Site check.
|
||||
*
|
||||
* @param siteName
|
||||
* the site name
|
||||
* @return true, if successful
|
||||
*/
|
||||
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");
|
||||
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);
|
||||
plugin.getLogger().warning("Issue with VoteURL in site " + siteName);
|
||||
}
|
||||
return pass;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.Ben12345rocks.VotingPlugin.CoolDown;
|
||||
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardOptions;
|
||||
import com.Ben12345rocks.AdvancedCore.TimeChecker.Events.DateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UUID;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteCoolDownEndEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteReminding.
|
||||
*/
|
||||
public class CoolDownCheck implements Listener {
|
||||
|
||||
/** The instance. */
|
||||
static CoolDownCheck instance = new CoolDownCheck();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of VoteReminding.
|
||||
*
|
||||
* @return single instance of VoteReminding
|
||||
*/
|
||||
public static CoolDownCheck getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*/
|
||||
private CoolDownCheck() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CoolDownCheck(Main plugin) {
|
||||
CoolDownCheck.plugin = plugin;
|
||||
}
|
||||
|
||||
public void checkAll() {
|
||||
Main.plugin.getTimer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Main.plugin != null) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
if (Main.plugin != null) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getUserData().hasData() && user.hasLoggedOnBefore()) {
|
||||
user.checkCoolDownEvents();
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
}, 1000 * 60 * 3);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onCoolDownEnd(PlayerVoteCoolDownEndEvent event) {
|
||||
RewardHandler.getInstance().giveReward(event.getPlayer(), Config.getInstance().getData(),
|
||||
"VoteCoolDownEndedReward",
|
||||
new RewardOptions().addPlaceholder("Votesite", event.getVoteSite().getDisplayName()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChangeEnd(DateChangedEvent event) {
|
||||
checkAll();
|
||||
}
|
||||
}
|
||||
@@ -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,92 +1,164 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
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 org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Files.Files;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class ServerData.
|
||||
*/
|
||||
public class ServerData {
|
||||
|
||||
/** The instance. */
|
||||
static ServerData instance = new ServerData();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of ServerData.
|
||||
*
|
||||
* @return single instance of ServerData
|
||||
*/
|
||||
public static ServerData getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
FileConfiguration data;
|
||||
|
||||
File dFile;
|
||||
|
||||
/**
|
||||
* Instantiates a new server data.
|
||||
*/
|
||||
private ServerData() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new server data.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public ServerData(Main plugin) {
|
||||
ServerData.plugin = plugin;
|
||||
}
|
||||
|
||||
public synchronized void addServiceSite(String site) {
|
||||
ArrayList<String> l = getServiceSites();
|
||||
if (!getServiceSites().contains(site)) {
|
||||
l.add(site);
|
||||
}
|
||||
setServiceSites(ArrayUtils.getInstance().removeDuplicates(l));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the sign.
|
||||
*
|
||||
* @param location
|
||||
* the location
|
||||
* @param data
|
||||
* the data
|
||||
* @param position
|
||||
* the position
|
||||
*/
|
||||
public void addSign(Location location, String data, int position) {
|
||||
|
||||
int count = nextSignNumber();
|
||||
|
||||
getData().set("Signs." + count + ".World",
|
||||
location.getWorld().getName());
|
||||
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)));
|
||||
plugin.getSigns().add(new SignHandler("" + count, getSignLocation("" + count), getSignSkullLocation("" + count),
|
||||
getSignData("" + count), getSignPosition("" + count)));
|
||||
}
|
||||
|
||||
public FileConfiguration getData() {
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public ConfigurationSection getData() {
|
||||
ConfigurationSection data = com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().getData()
|
||||
.getConfigurationSection("VotingPlugin");
|
||||
if (data == null) {
|
||||
com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().getData().createSection("VotingPlugin");
|
||||
data = com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().getData()
|
||||
.getConfigurationSection("VotingPlugin");
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public int getPrevDay() {
|
||||
return getData().getInt("PrevDay");
|
||||
}
|
||||
|
||||
public int getPrevMonth() {
|
||||
return getData().getInt("PrevMonth");
|
||||
}
|
||||
|
||||
public int getPrevWeekDay() {
|
||||
return getData().getInt("PrevWeek");
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getServiceSites() {
|
||||
return (ArrayList<String>) getData().getList("ServiceSites", new ArrayList<String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign data.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @return the sign data
|
||||
*/
|
||||
public String getSignData(String sign) {
|
||||
return getData().getString("Signs." + sign + ".Data");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign location.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @return the sign location
|
||||
*/
|
||||
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"));
|
||||
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"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign location.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @return the sign location
|
||||
*/
|
||||
public Location getSignSkullLocation(String sign) {
|
||||
if (getData().getString("Signs." + sign + ".Skull.World", "").isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new Location(Bukkit.getWorld(getData().getString("Signs." + sign + ".Skull.World")),
|
||||
getData().getDouble("Signs." + sign + ".Skull.X"), getData().getDouble("Signs." + sign + ".Skull.Y"),
|
||||
getData().getDouble("Signs." + sign + ".Skull.Z"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign position.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @return the sign position
|
||||
*/
|
||||
public int getSignPosition(String sign) {
|
||||
return getData().getInt("Signs." + sign + ".Position");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the signs.
|
||||
*
|
||||
* @return the signs
|
||||
*/
|
||||
public Set<String> getSigns() {
|
||||
try {
|
||||
return getData().getConfigurationSection("Signs").getKeys(false);
|
||||
@@ -95,6 +167,15 @@ public class ServerData {
|
||||
}
|
||||
}
|
||||
|
||||
public int getVotePartyExtraRequired() {
|
||||
return getData().getInt("VotePartyExtraRequired", 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Next sign number.
|
||||
*
|
||||
* @return the int
|
||||
*/
|
||||
public int nextSignNumber() {
|
||||
Set<String> signs = getSigns();
|
||||
|
||||
@@ -108,10 +189,19 @@ public class ServerData {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload data.
|
||||
*/
|
||||
public void reloadData() {
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().reloadData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
*/
|
||||
public void removeSign(String sign) {
|
||||
getData().set("Signs." + sign + ".World", null);
|
||||
getData().set("Signs." + sign + ".X", null);
|
||||
@@ -120,91 +210,68 @@ public class ServerData {
|
||||
getData().set("Signs." + sign + ".Data", null);
|
||||
getData().set("Signs." + sign + ".Position", null);
|
||||
getData().set("Signs." + sign, null);
|
||||
getData().set("Signs." + sign + ".Skull.World", null);
|
||||
getData().set("Signs." + sign + ".Skull.X", null);
|
||||
getData().set("Signs." + sign + ".Skull.Y", null);
|
||||
getData().set("Signs." + sign + ".Skull.Z", null);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void saveData() {
|
||||
Files.getInstance().editFile(dFile, data);
|
||||
/**
|
||||
* Save data.
|
||||
*/
|
||||
public synchronized void saveData() {
|
||||
com.Ben12345rocks.AdvancedCore.Data.ServerData.getInstance().saveData();
|
||||
}
|
||||
|
||||
public void setPluginVersion() {
|
||||
getData().set("PluginVersion", plugin.getDescription().getVersion());
|
||||
public void setServiceSites(ArrayList<String> list) {
|
||||
getData().set("ServiceSites", list);
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setPrevDay(int day) {
|
||||
getData().set("PrevDay", day);
|
||||
saveData();
|
||||
}
|
||||
public void setSign(String count, Location location, Location skullLocation, String data, int position) {
|
||||
|
||||
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 + ".World", location.getWorld().getName());
|
||||
getData().set("Signs." + count + ".X", (int) location.getX());
|
||||
getData().set("Signs." + count + ".Y", (int) location.getY());
|
||||
getData().set("Signs." + count + ".Z", (int) location.getZ());
|
||||
getData().set("Signs." + count + ".Data", data);
|
||||
getData().set("Signs." + count + ".Position", position);
|
||||
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());
|
||||
if (skullLocation != null) {
|
||||
getData().set("Signs." + count + ".Skull.World", skullLocation.getWorld().getName());
|
||||
getData().set("Signs." + count + ".Skull.X", (int) skullLocation.getX());
|
||||
getData().set("Signs." + count + ".Skull.Y", (int) skullLocation.getY());
|
||||
getData().set("Signs." + count + ".Skull.Z", (int) skullLocation.getZ());
|
||||
}
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setSkullLocation(String count, Location skullLocation) {
|
||||
if (skullLocation != null) {
|
||||
getData().set("Signs." + count + ".Skull.World", skullLocation.getWorld().getName());
|
||||
getData().set("Signs." + count + ".Skull.X", (int) skullLocation.getX());
|
||||
getData().set("Signs." + count + ".Skull.Y", (int) skullLocation.getY());
|
||||
getData().set("Signs." + count + ".Skull.Z", (int) skullLocation.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version.
|
||||
*/
|
||||
public void setVersion() {
|
||||
getData().set("Version", Bukkit.getVersion());
|
||||
saveData();
|
||||
}
|
||||
|
||||
public void setVotePartyExtraRequired(int value) {
|
||||
getData().set("VotePartyExtraRequired", value);
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update values.
|
||||
*/
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerReceivePointsEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private User player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int points;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
public PlayerReceivePointsEvent(User user, int points) {
|
||||
super(true);
|
||||
this.player = user;
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerSpecialRewardEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private User user;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private SpecialRewardType type;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerSpecialRewardEvent(User user, SpecialRewardType type) {
|
||||
super(true);
|
||||
this.type = type;
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
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;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteCoolDownEndEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private User player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteCoolDownEndEvent(User user, VoteSite site) {
|
||||
super(true);
|
||||
player = user;
|
||||
voteSite = site;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,54 +3,80 @@ 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;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private User player;
|
||||
@Getter
|
||||
@Setter
|
||||
private String player;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private VoteSite voteSite;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, User player) {
|
||||
super();
|
||||
setPlayer(player);
|
||||
setVoteSite(voteSite);
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean realVote = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean addTotals = true;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite = "";
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long time;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername, String serviceSite, boolean realVote) {
|
||||
super(true);
|
||||
this.player = voteUsername;
|
||||
this.voteSite = voteSite;
|
||||
this.realVote = realVote;
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public User getPlayer() {
|
||||
return player;
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean bungee = false;
|
||||
|
||||
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;
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean forceBungee = false;
|
||||
|
||||
}
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
public enum SpecialRewardType {
|
||||
ALLSITE, CUMMULATIVE, MILESTONE, VOTESTREAK, FIRSTVOTE;
|
||||
|
||||
@Getter
|
||||
private int amount = -1;
|
||||
|
||||
@Getter
|
||||
private String type = "";
|
||||
|
||||
public SpecialRewardType setAmount(int num) {
|
||||
amount = num;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpecialRewardType setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class VotePartyEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean cancelled;
|
||||
|
||||
public VotePartyEvent() {
|
||||
super(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
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.Signs.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class BlockBreak.
|
||||
*/
|
||||
public class BlockBreak implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new block break.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public BlockBreak(Main plugin) {
|
||||
BlockBreak.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On block break.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (event.getBlock().getState() instanceof Sign) {
|
||||
Sign s = (Sign) event.getBlock().getState();
|
||||
final Location loc = s.getLocation();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
if (sign.getLocation().equals(loc)) {
|
||||
sign.removeSign();
|
||||
sign.setValid(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandSendEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.CommandLoader;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerCommandSendListener implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static Main plugin;
|
||||
|
||||
public PlayerCommandSendListener(Main plugin) {
|
||||
PlayerCommandSendListener.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTab(PlayerCommandSendEvent event) {
|
||||
if (Config.getInstance().isDisableAdvancedTab()) {
|
||||
return;
|
||||
}
|
||||
ArrayList<String> removeCmds = new ArrayList<String>();
|
||||
if (!Main.plugin.getAdvancedTab().containsKey(event.getPlayer().getUniqueId())) {
|
||||
ArrayList<String> whiteListed = new ArrayList<String>();
|
||||
for (String cmd : event.getCommands()) {
|
||||
if (CommandLoader.getInstance().isVotingPluginCommand(event.getPlayer(), cmd)) {
|
||||
if (!CommandLoader.getInstance().hasPermission(event.getPlayer(), cmd)
|
||||
&& !whiteListed.contains(cmd)) {
|
||||
removeCmds.add(cmd);
|
||||
// plugin.debug("removed " + cmd);
|
||||
} else {
|
||||
removeCmds.remove(cmd);
|
||||
whiteListed.add(cmd);
|
||||
// plugin.debug("has " + cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
Main.plugin.getAdvancedTab().put(event.getPlayer().getUniqueId(), removeCmds);
|
||||
} else {
|
||||
removeCmds = Main.plugin.getAdvancedTab().get(event.getPlayer().getUniqueId());
|
||||
}
|
||||
event.getCommands().removeAll(removeCmds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
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.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerInteract.
|
||||
*/
|
||||
public class PlayerInteract implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player interact.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerInteract(Main plugin) {
|
||||
PlayerInteract.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player interact.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
// plugin.debug("Checking for sign click");
|
||||
if (event.getClickedBlock().getState() instanceof Sign) {
|
||||
// plugin.debug(player.getName() + " right clicked a sign");
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
if (sign.isLocationSame(event.getClickedBlock().getLocation())) {
|
||||
// plugin.debug(player.getName() +
|
||||
// " right clicked a top voter sign, sending message");
|
||||
UserManager.getInstance().getVotingPluginUser(player).sendMessage(sign.getRightClickMessage());
|
||||
|
||||
if (!sign.isSkullSet()) {
|
||||
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Sign.Create")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Admin")) {
|
||||
player.sendMessage("Skull not set, click to set skull");
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", sign.getSign());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (event.getClickedBlock().getState() instanceof Skull) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "skullset");
|
||||
if (ob != null) {
|
||||
String sign1 = (String) ob;
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
if (sign.getSign().equals(sign1)) {
|
||||
sign.setSkullLocation(event.getClickedBlock().getLocation());
|
||||
sign.storeSign();
|
||||
sign.checkSkulls();
|
||||
player.sendMessage("Skull set");
|
||||
}
|
||||
}
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "skullset", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
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.player.PlayerQuitEvent;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.AdvancedCoreLoginEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.UserManager.UserStorage;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
@SuppressWarnings("unused")
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(Main plugin) {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player login.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(AdvancedCoreLoginEvent event) {
|
||||
if (event.getPlayer() == null
|
||||
|| (Main.plugin.getStorageType().equals(UserStorage.MYSQL) && Main.plugin.getMysql() == null)) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
if (player.isOp() && plugin.isYmlError()) {
|
||||
user.sendMessage("&cVotingPlugin: Detected yml error, please check console for details");
|
||||
}
|
||||
|
||||
boolean data = user.getData().hasData();
|
||||
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
if (data) {
|
||||
// give offline vote (if they voted offline)
|
||||
user.offVote();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (Config.getInstance().isDisableAdvancedTab()) {
|
||||
return;
|
||||
}
|
||||
final java.util.UUID uuid = event.getPlayer().getUniqueId();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Main.plugin.getAdvancedTab().remove(uuid);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.PluginMessage.PluginMessage;
|
||||
import com.Ben12345rocks.VotingPlugin.BungeeHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.SpecialRewards.SpecialRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.Ben12345rocks.VotingPlugin.bungee.BungeeMethod;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class PlayerVoteListener implements Listener {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
private static Object object = new Object();
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerVoteListener(Main plugin) {
|
||||
PlayerVoteListener.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onplayerVote(PlayerVoteEvent event) {
|
||||
String playerName = event.getPlayer();
|
||||
if (!PlayerUtils.getInstance().isValidUser(playerName, Config.getInstance().isAllowUnJoinedCheckServer())) {
|
||||
if (!config.isAllowUnjoined()) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VoteSite voteSite = event.getVoteSite();
|
||||
|
||||
// check valid service sites
|
||||
if (voteSite == null) {
|
||||
if (!Config.getInstance().isDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + event.getServiceSite() + "'");
|
||||
plugin.getLogger().warning(
|
||||
"Please read here on how to fix it: https://github.com/Ben12345rocks/VotingPlugin/wiki/Common-Problems");
|
||||
|
||||
ArrayList<String> services = new ArrayList<String>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger()
|
||||
.warning("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
user.updateName();
|
||||
|
||||
if (Config.getInstance().isClearCacheOnVote() || Config.getInstance().isUseBungeecoord()) {
|
||||
user.clearCache();
|
||||
}
|
||||
|
||||
if (voteSite.isWaitUntilVoteDelay() && !user.canVoteSite(voteSite)) {
|
||||
plugin.getLogger().info(user.getPlayerName() + " must wait until votedelay is over, ignoring vote");
|
||||
return;
|
||||
}
|
||||
|
||||
synchronized (object) {
|
||||
|
||||
// vote party
|
||||
VoteParty.getInstance().vote(user, event.isRealVote());
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (config.isBroadcastVotesEnabled() && (!Config.getInstance().isBungeeBroadcast() || !event.isBungee())) {
|
||||
if (!Config.getInstance().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
if (event.getTime() != 0) {
|
||||
user.setTime(voteSite, event.getTime());
|
||||
} else {
|
||||
user.setTime(voteSite);
|
||||
}
|
||||
user.setLastVoteCoolDownCheck(false, voteSite);
|
||||
|
||||
// check first vote rewards
|
||||
SpecialRewards.getInstance().checkFirstVote(user);
|
||||
|
||||
if (user.isReminded()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
|
||||
if (((user.isOnline() || voteSite.isGiveOffline()) && Main.plugin.getOptions().isProcessRewards())
|
||||
|| event.isBungee()) {
|
||||
user.playerVote(voteSite, true, false, event.isForceBungee());
|
||||
user.closeInv();
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
plugin.debug(
|
||||
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if ((Config.getInstance().isCountFakeVotes() || event.isRealVote()) && event.isAddTotals()) {
|
||||
if (Config.getInstance().isAddTotals()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
|
||||
user.checkDayVoteStreak();
|
||||
|
||||
// other rewards
|
||||
SpecialRewards.getInstance().checkAllSites(user);
|
||||
SpecialRewards.getInstance().checkCumualativeVotes(user);
|
||||
SpecialRewards.getInstance().checkMilestone(user);
|
||||
|
||||
if (config.isUseBungeecoord()) {
|
||||
if (BungeeHandler.getInstance().getMethod().equals(BungeeMethod.MYSQL)) {
|
||||
final String uuid = user.getUUID();
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
PluginMessage.getInstance().sendPluginMessage(
|
||||
PlayerUtils.getInstance().getRandomOnlinePlayer(), "VoteUpdate", uuid);
|
||||
}
|
||||
}
|
||||
}, 40);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Signs.Signs;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SignChange.
|
||||
*/
|
||||
public class SignChange implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new sign change.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public SignChange(Main plugin) {
|
||||
SignChange.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On sign change.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
if (event.getLine(0).equalsIgnoreCase("[VotingPlugin]")) {
|
||||
if (PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(), "VotingPlugin.Sign.Create")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(event.getPlayer().getName(),
|
||||
"VotingPlugin.Admin")) {
|
||||
String data = event.getLine(2);
|
||||
if (!data.equalsIgnoreCase("all") && !data.equalsIgnoreCase("monthly")
|
||||
&& !data.equalsIgnoreCase("weekly") && !data.equalsIgnoreCase("daily")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ServerData.getInstance().addSign(event.getBlock().getLocation(), event.getLine(2),
|
||||
Integer.parseInt(event.getLine(1)));
|
||||
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&aAdded sign!"));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().updateSigns();
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
event.getPlayer().sendMessage(StringParser.getInstance().colorize("&cError on sign creation!"));
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
event.getPlayer()
|
||||
.sendMessage(StringParser.getInstance().colorize(Config.getInstance().getFormatNoPerms()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class VotiferEvent implements Listener {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VotiferEvent(Main plugin) {
|
||||
VotiferEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onVotiferEvent(VotifierEvent event) {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
final String voteSite = vote.getServiceName();
|
||||
final String IP = vote.getAddress();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger()
|
||||
.info("Received a vote from service site '" + voteSite + "' by player '" + voteUsername + "'!");
|
||||
|
||||
plugin.debug("PlayerUsername: " + voteUsername);
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
plugin.debug("IP: " + IP);
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String voteSiteName = plugin.getVoteSiteName(voteSite);
|
||||
|
||||
ArrayList<String> sites = configVoteSites.getVoteSitesNames();
|
||||
boolean createSite = false;
|
||||
if (sites != null) {
|
||||
if (!sites.contains(voteSiteName)) {
|
||||
createSite = true;
|
||||
}
|
||||
} else {
|
||||
createSite = true;
|
||||
}
|
||||
|
||||
if (Config.getInstance().isAutoCreateVoteSites() && createSite) {
|
||||
plugin.getLogger().warning("VoteSite with service site '" + voteSiteName
|
||||
+ "' does not exist, attempting to generaterate...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
|
||||
ArrayList<String> services = new ArrayList<String>();
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
services.add(site.getServiceSite());
|
||||
}
|
||||
plugin.getLogger()
|
||||
.info("Current known service sites: " + ArrayUtils.getInstance().makeStringList(services));
|
||||
}
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName), voteUsername,
|
||||
voteSite, true);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.PluginUpdateVersionEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class AdvancedCoreUpdateEvent.
|
||||
*/
|
||||
public class VotingPluginUpdateEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new advanced core update event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VotingPluginUpdateEvent(Main plugin) {
|
||||
VotingPluginUpdateEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On plugin update.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPluginUpdate(PluginUpdateVersionEvent event) {
|
||||
if (event.getPlugin().getName().equals(plugin.getDescription().getName())) {
|
||||
if (!event.getOldVersion().equals("")) {
|
||||
plugin.getLogger().info("VotingPlugin Updated to " + plugin.getDescription().getVersion() + " from "
|
||||
+ event.getOldVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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 +1,243 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.PluginMessage.PluginMessage;
|
||||
import com.Ben12345rocks.VotingPlugin.BungeeHandler;
|
||||
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;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.bungee.BungeeMethod;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* The Class VoteSite.
|
||||
*/
|
||||
public class VoteSite {
|
||||
static Config config = Config.getInstance();
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
@Setter
|
||||
private String voteURL;
|
||||
|
||||
public String getVoteURL(boolean json) {
|
||||
if (!Config.getInstance().isFormatCommandsVoteForceLinks() || !json) {
|
||||
return voteURL;
|
||||
} else {
|
||||
return "[Text=\"" + voteURL + "\",url=\"" + voteURL + "\"]";
|
||||
}
|
||||
}
|
||||
|
||||
public String getVoteURL() {
|
||||
return getVoteURL(true);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String serviceSite;
|
||||
private String siteName;
|
||||
private int voteDelay;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String key;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String displayName;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private double voteDelay;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private double voteDelayMin;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private double timeOffSet;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean enabled;
|
||||
|
||||
private ArrayList<String> rewards;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean voteDelayDaily;
|
||||
|
||||
private int cumulativeVotes;
|
||||
private ArrayList<String> cumulativeRewards;
|
||||
@Getter
|
||||
@Setter
|
||||
private int priority;
|
||||
|
||||
@Setter
|
||||
private ConfigurationSection item;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean giveOffline;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean waitUntilVoteDelay;
|
||||
|
||||
/**
|
||||
* Instantiates a new vote site.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VoteSite(Main plugin) {
|
||||
VoteSite.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* New VoteSite
|
||||
* Instantiates a new vote site.
|
||||
*
|
||||
* @param siteName
|
||||
* Sitename
|
||||
* the site name
|
||||
*/
|
||||
public VoteSite(String siteName) {
|
||||
setSiteName(siteName);
|
||||
if (!configVoteSites.getVoteSiteFile(siteName).exists()) {
|
||||
if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
configVoteSites.generateVoteSite(siteName);
|
||||
key = siteName.replace(".", "_");
|
||||
init();
|
||||
}
|
||||
|
||||
public void broadcastVote(User user) {
|
||||
broadcastVote(user, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast vote.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param checkBungee
|
||||
* check bungee broadcast
|
||||
*/
|
||||
public void broadcastVote(User user, boolean checkBungee) {
|
||||
if (!user.isVanished()) {
|
||||
if (checkBungee && Config.getInstance().isBungeeBroadcast() && Config.getInstance().isUseBungeecoord()) {
|
||||
if (BungeeHandler.getInstance().getMethod().equals(BungeeMethod.SOCKETS)) {
|
||||
BungeeHandler.getInstance().sendData("Broadcast", getServiceSite(), user.getPlayerName());
|
||||
} else if (BungeeHandler.getInstance().getMethod().equals(BungeeMethod.MYSQL)
|
||||
|| BungeeHandler.getInstance().getMethod().equals(BungeeMethod.PLUGINMESSAGING)) {
|
||||
String uuid = user.getUUID();
|
||||
String service = getServiceSite();
|
||||
|
||||
if (Bukkit.getOnlinePlayers().size() > 0) {
|
||||
PluginMessage.getInstance().sendPluginMessage(PlayerUtils.getInstance().getRandomOnlinePlayer(),
|
||||
"VoteBroadcast", uuid, service);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
String playerName = user.getPlayerName();
|
||||
if (config.getVotingBroadcastBlacklist().contains(playerName)) {
|
||||
plugin.getLogger().info("Not broadcasting for " + playerName + ", in blacklist");
|
||||
return;
|
||||
}
|
||||
String bc = StringParser.getInstance().colorize(config.getFormatBroadCastMsg());
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("player", playerName);
|
||||
placeholders.put("nickname",
|
||||
(user.getPlayer() != null) ? user.getPlayer().getDisplayName() : user.getPlayerName());
|
||||
placeholders.put("sitename", getDisplayName());
|
||||
placeholders.put("servicesite", getServiceSite());
|
||||
bc = StringParser.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
bc = StringParser.getInstance().replacePlaceHolders(user.getOfflinePlayer(), bc);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
MiscUtils.getInstance().broadcast(bc, players);
|
||||
}
|
||||
init();
|
||||
plugin.loadVoteSites();
|
||||
} else {
|
||||
init();
|
||||
plugin.debug(user.getPlayerName() + " is vanished, not broadcasting");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broad cast a vote
|
||||
*
|
||||
* @param user
|
||||
* User to broadcast with
|
||||
* @return the item
|
||||
*/
|
||||
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 ItemBuilder getItem() {
|
||||
if (item == null) {
|
||||
plugin.getLogger().warning("Invalid item section in site: " + key);
|
||||
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid item for site: " + key)
|
||||
.setLore("&cInvalid item for site: " + key);
|
||||
} else {
|
||||
return new ItemBuilder(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveRewards(User user) {
|
||||
for (String reward : getRewards()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
public ConfigurationSection getSiteData() {
|
||||
return configVoteSites.getData(key);
|
||||
}
|
||||
|
||||
public void giveSiteReward(User user) {
|
||||
giveRewards(user);
|
||||
public void giveRewards(User user, boolean online, boolean bungee) {
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getRewardsPath(key)).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL())
|
||||
.setServer(bungee).send(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();
|
||||
}
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getEverySiteRewardPath()).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL())
|
||||
.setServer(bungee).send(user);
|
||||
}
|
||||
|
||||
public boolean hasRewards() {
|
||||
return RewardHandler.getInstance().hasRewards(configVoteSites.getData(), configVoteSites.getRewardsPath(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the.
|
||||
*/
|
||||
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));
|
||||
setVoteURL(configVoteSites.getVoteURL(key));
|
||||
setServiceSite(configVoteSites.getServiceSite(key));
|
||||
setVoteDelay(configVoteSites.getVoteDelay(key));
|
||||
setVoteDelayMin(configVoteSites.getVoteDelayMin(key));
|
||||
setEnabled(configVoteSites.getVoteSiteEnabled(key));
|
||||
setPriority(configVoteSites.getPriority(key));
|
||||
displayName = configVoteSites.getDisplayName(key);
|
||||
if (displayName == null || displayName.equals("")) {
|
||||
displayName = key;
|
||||
}
|
||||
item = configVoteSites.getItem(key);
|
||||
voteDelayDaily = configVoteSites.getVoteSiteResetVoteDelayDaily(key);
|
||||
giveOffline = configVoteSites.getVoteSiteGiveOffline(key);
|
||||
waitUntilVoteDelay = configVoteSites.getWaitUntilVoteDelay(key);
|
||||
timeOffSet = configVoteSites.getTimeOffSet(key);
|
||||
}
|
||||
|
||||
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;
|
||||
public boolean isVaidServiceSite() {
|
||||
return ArrayUtils.getInstance().containsIgnoreCase(ServerData.getInstance().getServiceSites(),
|
||||
getServiceSite());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Signs;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.block.Skull;
|
||||
import org.bukkit.block.data.Directional;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.NMSManager.NMSManager;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SignHandler.
|
||||
*/
|
||||
public class SignHandler {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String sign;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Location location;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Location skullLocation;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String data;
|
||||
|
||||
/** The lines. */
|
||||
private ArrayList<String> lines;
|
||||
|
||||
/** The position. */
|
||||
private int position;
|
||||
|
||||
/** The plugin. */
|
||||
public Main plugin = Main.plugin;
|
||||
|
||||
/** The player name. */
|
||||
private String playerName;
|
||||
|
||||
/** The votes. */
|
||||
private int votes;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean valid;
|
||||
|
||||
public SignHandler(String sign, Location location, Location skullLocation, String data, int position) {
|
||||
setSign(sign);
|
||||
setLocation(location);
|
||||
setSkullLocation(skullLocation);
|
||||
setData(data);
|
||||
this.position = position;
|
||||
setValid(true);
|
||||
lines = new ArrayList<String>();
|
||||
checkValidSign();
|
||||
playerName = "";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private boolean checkSkull(Block block) {
|
||||
if (block.getState() instanceof Skull) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSkullSet() {
|
||||
return skullLocation != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check skulls.
|
||||
*/
|
||||
public void checkSkulls() {
|
||||
if (playerName.equalsIgnoreCase("No Player") || playerName.equals("")) {
|
||||
return;
|
||||
}
|
||||
if (skullLocation != null) {
|
||||
checkSkull(skullLocation.getBlock());
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
updateSkulls(loc1, loc2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check valid sign.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the right click message.
|
||||
*
|
||||
* @return the right click message
|
||||
*/
|
||||
public String getRightClickMessage() {
|
||||
String msg = Config.getInstance().getFormatSignTopVoterSignRightClickMessage();
|
||||
msg = msg.replace("%player%", playerName);
|
||||
msg = msg.replace("%position%", "" + position);
|
||||
msg = msg.replace("%votes%", "" + votes);
|
||||
msg = msg.replace("%SiteName%", data);
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is location same.
|
||||
*
|
||||
* @param loc
|
||||
* the loc
|
||||
* @return true, if is location same
|
||||
*/
|
||||
public boolean isLocationSame(Location loc) {
|
||||
return loc.equals(getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*/
|
||||
public void removeSign() {
|
||||
ServerData.getInstance().removeSign(sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store sign.
|
||||
*/
|
||||
public void storeSign() {
|
||||
ServerData.getInstance().setSign(sign, location, skullLocation, data, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update lines.
|
||||
*/
|
||||
public void updateLines() {
|
||||
lines = new ArrayList<String>();
|
||||
checkValidSign();
|
||||
if (position != 0) {
|
||||
String line1 = Config.getInstance().getFormatSignTopVoterSignLine1();
|
||||
String line2 = Config.getInstance().getFormatSignTopVoterSignLine2();
|
||||
String line3 = Config.getInstance().getFormatSignTopVoterSignLine3();
|
||||
String line4 = Config.getInstance().getFormatSignTopVoterSignLine4();
|
||||
lines.add(line1);
|
||||
lines.add(line2);
|
||||
lines.add(line3);
|
||||
lines.add(line4);
|
||||
|
||||
ArrayList<User> users = null;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.AllTime).keySet());
|
||||
} else if (data.equalsIgnoreCase("monthly")) {
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.Monthly).keySet());
|
||||
} else if (data.equalsIgnoreCase("weekly")) {
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.Weekly).keySet());
|
||||
} else if (data.equalsIgnoreCase("daily")) {
|
||||
users = plugin.convertSet(plugin.getTopVoter(TopVoter.Daily).keySet());
|
||||
}
|
||||
|
||||
if (users != null && users.size() >= position) {
|
||||
User user = users.get(position - 1);
|
||||
playerName = user.getPlayerName();
|
||||
|
||||
votes = 0;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
votes = plugin.getTopVoter(TopVoter.AllTime).get(user);
|
||||
} else if (data.equalsIgnoreCase("monthly")) {
|
||||
votes = plugin.getTopVoter(TopVoter.Monthly).get(user);
|
||||
} else if (data.equalsIgnoreCase("weekly")) {
|
||||
votes = plugin.getTopVoter(TopVoter.Weekly).get(user);
|
||||
} else if (data.equalsIgnoreCase("daily")) {
|
||||
votes = plugin.getTopVoter(TopVoter.Daily).get(user);
|
||||
}
|
||||
|
||||
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 = ArrayUtils.getInstance().colorize(lines);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sign.
|
||||
*
|
||||
* @param delay
|
||||
* the delay
|
||||
*/
|
||||
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();
|
||||
checkSkulls();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
Main.plugin.debug(ex);
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
public void updateSkulls(Location loc1, Location loc2) {
|
||||
if (!NMSManager.getInstance().isVersion("1.12")) {
|
||||
BlockState state = getLocation().getBlock().getState();
|
||||
if (state instanceof Sign && state.getBlockData() instanceof Directional) {
|
||||
Directional s = (Directional) state.getBlockData();
|
||||
Block b = location.getBlock().getRelative(s.getFacing());
|
||||
Block above = b.getRelative(BlockFace.UP);
|
||||
if (checkSkull(above)) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (Block block : MiscUtils.getInstance().getRegionBlocks(location.getWorld(), loc1, loc2)) {
|
||||
checkSkull(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,29 +5,52 @@ 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;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class Signs.
|
||||
*/
|
||||
public class Signs {
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
/** The instance. */
|
||||
static Signs instance = new Signs();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of Signs.
|
||||
*
|
||||
* @return single instance of Signs
|
||||
*/
|
||||
public static Signs getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new signs.
|
||||
*/
|
||||
private Signs() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new signs.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public Signs(Main plugin) {
|
||||
Signs.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign from location.
|
||||
*
|
||||
* @param loc
|
||||
* the loc
|
||||
* @return the sign from location
|
||||
*/
|
||||
public String getSignFromLocation(Location loc) {
|
||||
for (String sign : ServerData.getInstance().getSigns()) {
|
||||
if (ServerData.getInstance().getSignLocation(sign).equals(loc)) {
|
||||
@@ -38,33 +61,43 @@ public class Signs {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load signs.
|
||||
*/
|
||||
public void loadSigns() {
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
plugin.setSigns(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)));
|
||||
plugin.getSigns().add(new SignHandler(sign, ServerData.getInstance().getSignLocation(sign),
|
||||
ServerData.getInstance().getSignSkullLocation(sign), ServerData.getInstance().getSignData(sign),
|
||||
ServerData.getInstance().getSignPosition(sign)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store signs.
|
||||
*/
|
||||
public void storeSigns() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
for (SignHandler sign : plugin.getSigns()) {
|
||||
sign.storeSign();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update signs.
|
||||
*/
|
||||
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.");
|
||||
int time = 0;
|
||||
for (int i = plugin.getSigns().size() - 1; i >= 0; i--) {
|
||||
if (!plugin.getSigns().get(i).isValid()) {
|
||||
plugin.debug("Sign " + i + " invalid, removing from data: "
|
||||
+ plugin.getSigns().get(i).getLocation().toString());
|
||||
plugin.getSigns().get(i).removeSign();
|
||||
plugin.getSigns().remove(i);
|
||||
} else {
|
||||
plugin.signs.get(i).updateLines();
|
||||
plugin.signs.get(i).updateSign(i * 3);
|
||||
plugin.getSigns().get(i).updateLines();
|
||||
plugin.getSigns().get(i).updateSign(time);
|
||||
time += 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,318 @@
|
||||
package com.Ben12345rocks.VotingPlugin.SpecialRewards;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardOptions;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Messages.StringParser;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerSpecialRewardEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.SpecialRewardType;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoter;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OtherVoteReward.
|
||||
*/
|
||||
public class SpecialRewards {
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
/** The instance. */
|
||||
static SpecialRewards instance = new SpecialRewards();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of OtherVoteReward.
|
||||
*
|
||||
* @return single instance of OtherVoteReward
|
||||
*/
|
||||
public static SpecialRewards getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new other vote reward.
|
||||
*/
|
||||
private SpecialRewards() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new other vote reward.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public SpecialRewards(Main plugin) {
|
||||
SpecialRewards.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all sites.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkAllSites(User user) {
|
||||
boolean checkAllVotes = user.checkAllVotes();
|
||||
if (checkAllVotes) {
|
||||
giveAllSitesRewards(user, user.isOnline());
|
||||
}
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check cumualative votes.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkCumualativeVotes(User user) {
|
||||
boolean gotCumulative = false;
|
||||
Set<String> votes = Config.getInstance().getCumulativeVotes();
|
||||
for (String vote : votes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getCumulativeRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getCumulativeRewardsPath(votesRequired))) {
|
||||
int total = 0;
|
||||
if (Config.getInstance().getCumulativeVotesInSameDay(votesRequired)) {
|
||||
total = user.getTotal(TopVoter.Daily);
|
||||
} else if (Config.getInstance().getCumulativeVotesInSameWeek(votesRequired)) {
|
||||
total = user.getTotal(TopVoter.Weekly);
|
||||
} else {
|
||||
total = user.getTotal(TopVoter.AllTime);
|
||||
}
|
||||
|
||||
if ((total % votesRequired) == 0 && total != 0) {
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired);
|
||||
gotCumulative = true;
|
||||
}
|
||||
|
||||
if (gotCumulative) {
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid cumulative number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotCumulative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check first vote.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkFirstVote(User user) {
|
||||
if (RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVote()) {
|
||||
giveFirstVoteRewards(user, user.isOnline());
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check milestone.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkMilestone(User user) {
|
||||
boolean gotMilestone = false;
|
||||
Set<String> votes = Config.getInstance().getMilestoneVotes();
|
||||
for (String vote : votes) {
|
||||
if (StringParser.getInstance().isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getMilestoneRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getMilestoneRewardsPath(votesRequired))) {
|
||||
|
||||
int userVotesTotal = user.getMilestoneCount();
|
||||
if (userVotesTotal >= votesRequired && !user.hasGottenMilestone(votesRequired)) {
|
||||
giveMilestoneVoteReward(user, user.isOnline(), votesRequired);
|
||||
user.setHasGotteMilestone(votesRequired, true);
|
||||
plugin.debug(user.getPlayerName() + " got milestone " + votesRequired);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid milestone number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotMilestone;
|
||||
}
|
||||
|
||||
public boolean checkVoteStreak(User user, String type) {
|
||||
boolean gotReward = false;
|
||||
|
||||
Set<String> streaks = Config.getInstance().getVoteStreakVotes(type);
|
||||
for (String streak : streaks) {
|
||||
String s = streak.replaceAll("-", "");
|
||||
boolean multiple = false;
|
||||
if (streak.contains("-")) {
|
||||
// multiple
|
||||
multiple = true;
|
||||
}
|
||||
if (StringParser.getInstance().isInt(s)) {
|
||||
int streakRequired = Integer.parseInt(s);
|
||||
if (streakRequired != 0) {
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled(type, streak)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getVoteStreakRewardsPath(type, "" + streak))) {
|
||||
int curStreak = 0;
|
||||
if (type.equalsIgnoreCase("day")) {
|
||||
curStreak = user.getDayVoteStreak();
|
||||
} else if (type.equalsIgnoreCase("week")) {
|
||||
curStreak = user.getWeekVoteStreak();
|
||||
} else if (type.equalsIgnoreCase("month")) {
|
||||
curStreak = user.getMonthVoteStreak();
|
||||
}
|
||||
if (!multiple) {
|
||||
if (curStreak == streakRequired) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, "" + streakRequired, curStreak);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + " for " + type);
|
||||
}
|
||||
} else {
|
||||
if (curStreak != 0 && curStreak % streakRequired == 0) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, streakRequired + "-", curStreak);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + "* for " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return gotReward;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Give all sites rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveAllSitesRewards(User user, boolean online) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.ALLSITE);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getAllSitesRewardPath(), new RewardOptions().setOnline(online));
|
||||
}
|
||||
|
||||
/**
|
||||
* Give cumulative vote reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
* @param cumulative
|
||||
* the cumulative
|
||||
*/
|
||||
public void giveCumulativeVoteReward(User user, boolean online, int cumulative) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.CUMMULATIVE.setAmount(cumulative));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getCumulativeRewardsPath(cumulative))
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give first vote rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveFirstVoteRewards(User user, boolean online) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user, SpecialRewardType.FIRSTVOTE);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath(), new RewardOptions().setOnline(online));
|
||||
}
|
||||
|
||||
/**
|
||||
* Give milestone vote reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
* @param milestone
|
||||
* the milestone
|
||||
*/
|
||||
public void giveMilestoneVoteReward(User user, boolean online, int milestone) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.MILESTONE.setAmount(milestone));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMilestoneRewardsPath(milestone))
|
||||
.setOnline(online).withPlaceHolder("Milestone", "" + milestone).send(user);
|
||||
}
|
||||
|
||||
public void giveVoteStreakReward(User user, boolean online, String type, String string, int votes) {
|
||||
PlayerSpecialRewardEvent event = new PlayerSpecialRewardEvent(user,
|
||||
SpecialRewardType.VOTESTREAK.setType(type).setAmount(votes));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVoteStreakRewardsPath(type, string))
|
||||
.setOnline(online).withPlaceHolder("Type", type).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.Reward;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Rewards.RewardOptions;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class VoteTester {
|
||||
|
||||
private static VoteTester instance = new VoteTester();
|
||||
|
||||
public static VoteTester getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Main plugin = Main.plugin;
|
||||
|
||||
public void testRewards(int amount, String name, String rewardName) {
|
||||
long time1 = System.currentTimeMillis();
|
||||
ArrayList<Long> timesPerReward = new ArrayList<Long>();
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
Reward reward = RewardHandler.getInstance().getReward(rewardName);
|
||||
int rewardsGiven = 0;
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long start1 = System.currentTimeMillis();
|
||||
if (reward.canGiveReward(user, new RewardOptions())) {
|
||||
rewardsGiven++;
|
||||
RewardHandler.getInstance().giveReward(user, reward, new RewardOptions().setIgnoreRequirements(true));
|
||||
}
|
||||
long start2 = System.currentTimeMillis();
|
||||
timesPerReward.add(start2 - start1);
|
||||
}
|
||||
long time2 = System.currentTimeMillis();
|
||||
long time = time2 - time1;
|
||||
long timeTotal = 0;
|
||||
for (Long t : timesPerReward) {
|
||||
timeTotal += t.longValue();
|
||||
}
|
||||
long timePerRewardAvg = timeTotal / timesPerReward.size();
|
||||
Main.plugin.getLogger().info("Time to process rewards (" + amount + "): " + time + " ms, average per reward "
|
||||
+ timePerRewardAvg + " ms. " + Main.plugin.getStorageType() + ", "
|
||||
+ UserManager.getInstance().getAllUUIDs().size() + " users. " + rewardsGiven + " rewards given");
|
||||
}
|
||||
|
||||
public void testVotes(int amount, String name, String site) {
|
||||
long time1 = System.currentTimeMillis();
|
||||
ArrayList<Long> timesPerVote = new ArrayList<Long>();
|
||||
for (int i = 0; i < amount; i++) {
|
||||
long start1 = System.currentTimeMillis();
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(site), name,
|
||||
plugin.getVoteSiteServiceSite(site), false);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
long start2 = System.currentTimeMillis();
|
||||
timesPerVote.add(start2 - start1);
|
||||
}
|
||||
long time2 = System.currentTimeMillis();
|
||||
long time = time2 - time1;
|
||||
long timeTotal = 0;
|
||||
for (Long t : timesPerVote) {
|
||||
timeTotal += t.longValue();
|
||||
}
|
||||
long timePerVoteAvg = timeTotal / timesPerVote.size();
|
||||
Main.plugin.getLogger()
|
||||
.info("Time to process votes (" + amount + "): " + time + " ms, average per vote " + timePerVoteAvg
|
||||
+ " ms. " + Main.plugin.getStorageType() + ", " + UserManager.getInstance().getAllUUIDs().size()
|
||||
+ " users. " + Main.plugin.getVoteSites().size() + " votesites");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,600 +1,90 @@
|
||||
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.Config.Config;
|
||||
|
||||
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 enum TopVoter {
|
||||
AllTime, Monthly, Weekly, Daily;
|
||||
|
||||
public class TopVoter {
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static TopVoter instance = new TopVoter();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static TopVoter getInstance() {
|
||||
return instance;
|
||||
public static TopVoter getDefault() {
|
||||
TopVoter top = getTopVoter(Config.getInstance().getVoteTopDefault());
|
||||
if (top != null) {
|
||||
return top;
|
||||
}
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
private TopVoter() {
|
||||
public static TopVoter getTopVoter(String str) {
|
||||
for (TopVoter value : values()) {
|
||||
if (value.toString().equalsIgnoreCase(str)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public TopVoter(Main plugin) {
|
||||
TopVoter.plugin = plugin;
|
||||
public String getName() {
|
||||
if (this.equals(TopVoter.Monthly)) {
|
||||
return Config.getInstance().getFormatTopVoterMonthly();
|
||||
} else if (this.equals(TopVoter.Weekly)) {
|
||||
return Config.getInstance().getFormatTopVoterWeekly();
|
||||
} else if (this.equals(TopVoter.Daily)) {
|
||||
return Config.getInstance().getFormatTopVoterDaily();
|
||||
} else {
|
||||
return Config.getInstance().getFormatTopVoterAllTime();
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int next = i + 1;
|
||||
if (next > list.size() - 1) {
|
||||
next = 0;
|
||||
}
|
||||
return TopVoter.values()[next];
|
||||
}
|
||||
resetTotalsMonthly();
|
||||
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
public TopVoter prev() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int prev = i - 1;
|
||||
if (prev < 0) {
|
||||
prev = list.size() - 1;
|
||||
}
|
||||
}
|
||||
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);
|
||||
return TopVoter.values()[prev];
|
||||
}
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 118 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user