Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
@@ -2,6 +2,26 @@
|
||||
Plugin on SpigotMC
|
||||
https://www.spigotmc.org/resources/votingplugin.15358/
|
||||
|
||||
##License
|
||||
###Creative Commons Arttribution 3.0 Unported
|
||||
## License
|
||||
### Creative Commons Arttribution 3.0 Unported
|
||||
https://github.com/Ben12345rocks/VotingPlugin/blob/master/VotingPlugin/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/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry exported="true" kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="Resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
@@ -1 +1,3 @@
|
||||
/bin/
|
||||
/target/
|
||||
/doc/
|
||||
@@ -10,8 +10,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
|
||||
@@ -1,4 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
|
||||
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
|
||||
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
@@ -7,6 +16,108 @@ 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.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
|
||||
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsNotVisibleRef=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsVisibility=public
|
||||
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocComments=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingJavadocCommentsVisibility=public
|
||||
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.missingOverrideAnnotation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
|
||||
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
|
||||
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
|
||||
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=info
|
||||
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.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.
@@ -0,0 +1,869 @@
|
||||
# VotingPlugin by Ben12345rocks
|
||||
# Main Config
|
||||
# See wiki for help:
|
||||
# https://github.com/Ben12345rocks/VotingPlugin/wiki
|
||||
|
||||
# Valid Options:
|
||||
# - SQLITE
|
||||
# - FLAT
|
||||
# - MYSQL
|
||||
DataStorage: SQLITE
|
||||
|
||||
# Information for mysql
|
||||
MySQL:
|
||||
Host: ''
|
||||
# Default port is 3306
|
||||
Port: 3306
|
||||
Database: ''
|
||||
Username: ''
|
||||
Password: ''
|
||||
# Max number of connections
|
||||
MaxConnections: 1
|
||||
# Maxium size of caching mysql
|
||||
# -1 for no limit
|
||||
# Affecting this value may affect performance
|
||||
MaxSize: -1
|
||||
# Table name prefix, for use with mutliple servers
|
||||
Prefix: ''
|
||||
#UseSSL: true
|
||||
|
||||
# Let players who never joined before vote
|
||||
# Recommend: False (Will prevent creating random user data files)
|
||||
AllowUnjoined: false
|
||||
|
||||
# If true, plugin will send scoreboards on some commands
|
||||
SendScoreboards: true
|
||||
|
||||
# If true, plugin will automaticly generate votesites
|
||||
# Disable this if you experience issues with sites being created randomly
|
||||
AutoCreateVoteSites: true
|
||||
|
||||
# Automaticly download the latest version
|
||||
# Will require a restart to actually update
|
||||
# Note that updates take 30-40 minutes to load before they can be downloaded
|
||||
AutoDownload: false
|
||||
|
||||
# ------------------------------------------------
|
||||
# VoteReminding
|
||||
# ------------------------------------------------
|
||||
|
||||
# Configuration for VoteReminding
|
||||
# By default this should be all setup to work
|
||||
# as long as vote delays are done properly
|
||||
VoteReminding:
|
||||
# Enable vote reminding
|
||||
# This will remind player when he can vote on all sites
|
||||
# Requires 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 t to remind only once when the player can vote
|
||||
# Does not apply to login reminds.
|
||||
RemindOnlyOnce: true
|
||||
|
||||
# Will remind player on login if he can vote
|
||||
# Ignores value above
|
||||
RemindOnLogin: true
|
||||
|
||||
# Delay to remind votes in minutes
|
||||
# Only works if above is false
|
||||
RemindDelay: 30
|
||||
|
||||
# Run reward files on remind
|
||||
# By default, the reward file will be created for you
|
||||
# and have the default message
|
||||
# Edit the message at AdvancedCore/Rewards/Remind.yml (or any other reward listed)
|
||||
# Can add titles and more in the reward file
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aRemember to vote!'
|
||||
Title:
|
||||
Enabled: false
|
||||
Title: '&cRemember to vote!'
|
||||
SubTitle: '&aType /vote'
|
||||
FadeIn: 10
|
||||
ShowTime: 50
|
||||
FadeOut: 10
|
||||
|
||||
# ------------------------------------------------
|
||||
# Format
|
||||
# ------------------------------------------------
|
||||
|
||||
# Common PlacesHolders:
|
||||
# Please Note: Not all are usable in all sections
|
||||
# Special PlaceHolders will be commented where available
|
||||
# %player% = player name
|
||||
# %SiteName% = vote site name
|
||||
#
|
||||
# Set Message to '' (2 ') to disable message
|
||||
|
||||
Commands:
|
||||
# Wether or not the following commands will open GUIs rather than display text
|
||||
UseGUI:
|
||||
Today: true
|
||||
TopVoter: true
|
||||
Last: true
|
||||
Next: true
|
||||
Total: true
|
||||
Vote: true
|
||||
Best: true
|
||||
Streak: true
|
||||
# If true, you can right click a votesite from /vote (gui version) and open the vote reward gui for that site
|
||||
# Can be used to display rewards for that site
|
||||
VoteRewardFromVoteURL: false
|
||||
|
||||
Format:
|
||||
# CommandHandler help message
|
||||
HelpLine: '&3&l%Command% - &3%HelpMessage%'
|
||||
|
||||
# Broadcast vote message
|
||||
# Set to an empty message to disable
|
||||
BroadcastMsg: '&6[&4Broadcast&6] &2Thanks &c%player% &2for voting on %SiteName%'
|
||||
|
||||
# Broadcast only when player is online
|
||||
BroadcastWhenOnline: false
|
||||
|
||||
Commands:
|
||||
# Format for /vote
|
||||
# %num% = the number of the site, for a numbered list
|
||||
# %url% = site URL
|
||||
Vote:
|
||||
Text:
|
||||
- '&4&lVote for our server!'
|
||||
|
||||
# If you want to want to use the feature below where the plugin will
|
||||
# automaticly list the sites then set the message in the text above
|
||||
AutoInputSites: true
|
||||
# For each VoteSite
|
||||
# make sure to set VoteURL in your VoteSites
|
||||
# Requires above to be true
|
||||
# Text will be sent before this
|
||||
Sites: '&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!'
|
||||
# For sites that have this, requires votedelaydaily to be set to true in the site
|
||||
VoteDelayDaily: '%hours% Hours and %minutes% Minutes'
|
||||
|
||||
# Format for /vote last
|
||||
Last:
|
||||
# First line
|
||||
Title: '&3&l%player% Last Vote Times:'
|
||||
# Lines for each vote site
|
||||
# %time% = time, using timeformat below
|
||||
# %timesince% = time since vote
|
||||
Line: '&3%SiteName%: &6%timeSince% ago'
|
||||
# Spelling of TimeType can be changed under Format.Commands.TimeFormats
|
||||
TimeFormat: '%amount% %TimeType%'
|
||||
NeverVoted: 'Never voted'
|
||||
|
||||
# Format for /vote total
|
||||
Total:
|
||||
- '&3&l%player% Total Votes:'
|
||||
- '&3&lDaily Total: &6&l%DailyTotal%'
|
||||
- '&3&lWeekly Total: &6&l%WeeklyTotal%'
|
||||
- '&3&lMonthly Total: &6&l%MonthlyTotal%'
|
||||
- '&3&lAllTime Total: &6&l%AllTimeTotal%'
|
||||
|
||||
# Format for /vote total all
|
||||
TotalAll:
|
||||
- '&3&lServer Total Votes:'
|
||||
- '&3&lDaily Total: &6&l%DailyTotal%'
|
||||
- '&3&lWeekly Total: &6&l%WeeklyTotal%'
|
||||
- '&3&lMonthly Total: &6&l%MonthlyTotal%'
|
||||
- '&3&lAllTime Total: &6&l%AllTimeTotal%'
|
||||
|
||||
# Format for /vote top
|
||||
Top:
|
||||
# First line
|
||||
# %page% = current page
|
||||
# %maxpages% = max number of pages
|
||||
# %Top% = Monthly/Weekly/Daily (depending on command)
|
||||
Title: '&3Top %Top% Voters %page%/%maxpages%'
|
||||
# Line for each player in that page
|
||||
Line: '&c%num%: &6%player%, %votes%'
|
||||
|
||||
# Format for /vote help
|
||||
Help:
|
||||
# Title of /vote help
|
||||
Title: '&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
|
||||
|
||||
Best:
|
||||
Title: '&3&l%player% Best Votes'
|
||||
Lines:
|
||||
- '&3Highest Daily Total: &3&l%HighestDailyTotal%'
|
||||
- '&3Highest Week Total: &3&l%HighestWeeklyTotal%'
|
||||
- '&3Highest Month Total: &3&l%HighestMonthlyTotal%'
|
||||
|
||||
Streak:
|
||||
Title: '&3&l%player% Vote Streak'
|
||||
Lines:
|
||||
- '&3Current Daily Streak: &3&l%DailyStreak%'
|
||||
- '&3Current Week Streak: &3&l%WeeklyStreak%'
|
||||
- '&3Current Month Streak: &3&l%MonthlyStreak%'
|
||||
- '&3&lHighest Streaks:'
|
||||
- '&3Highest Daily Streak: &3&l%BestDailyStreak%'
|
||||
- '&3Highest Week Streak: &3&l%BestWeeklyStreak%'
|
||||
- '&3Highest Month Streak: &3&l%BestMonthlyStreak%'
|
||||
|
||||
# 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!'
|
||||
|
||||
ToggleBroadcast:
|
||||
Enabled: '&cYou will now see vote broadcasts'
|
||||
Disabled: '&cYou will no longer see vote broadcasts'
|
||||
|
||||
# Msg on top voter award, will only send message if that place has a reward set
|
||||
# %place% = place - 1,2,3,etc
|
||||
TopVoterAwardMsg: '&aYou came in %place% in top voters of the month! Here is an award!'
|
||||
|
||||
# Time Format
|
||||
# See https://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html
|
||||
TimeFormat: 'EEE, d MMM yyyy HH:mm'
|
||||
|
||||
TimeFomrats:
|
||||
Day: 'Day'
|
||||
Days: 'Days'
|
||||
Hour: 'Hour'
|
||||
Hours: 'Hours'
|
||||
Minute: 'Minute'
|
||||
Minutes: 'Minutes'
|
||||
Second: 'Second'
|
||||
Seconds: 'Seconds'
|
||||
|
||||
# Format for signs
|
||||
# SiteName may be all, depending on sign
|
||||
# %position% = position of player, set by sign
|
||||
# %votes% = Number of votes
|
||||
Signs:
|
||||
TopVoterSign:
|
||||
Line1: 'TopVoter: %SiteName%'
|
||||
Line2: '#%position%'
|
||||
Line3: '%player%'
|
||||
Line4: '%votes% Votes'
|
||||
# Message when right clicking sign, uses same placeholders as above
|
||||
RightClickMessage: '&c&l%player% &cis &c&l%position% &cwith &c&l%votes% &cvotes in &c&l%SiteName%'
|
||||
|
||||
# Message when player tries to run command without required permissions
|
||||
NoPerms: '&cYou do not have enough permission!'
|
||||
|
||||
# Message when player types a command but does not input a number where needed
|
||||
NotNumber: '&cError on &6%arg%&c, number expected!'
|
||||
|
||||
# Shop messages when using the /vote shop
|
||||
ShopPurchase: '&aYou bought the %Identifier% for %Points% Points!'
|
||||
ShopFailed: '&cYou do not have %Points% points to purchase this!'
|
||||
|
||||
# User not exist message, from commands such as /vote next (player)
|
||||
UserNotExist: '&cUser does not exist: %player%'
|
||||
|
||||
# Text for page buttons in inventories
|
||||
PrevPage: '&aPrevious Page'
|
||||
NextPage: '&aNext Page'
|
||||
|
||||
InvFull: '&cInventory full, dropping items on ground'
|
||||
|
||||
# Display text
|
||||
# Used in /vote top (GUI)
|
||||
TopVoter:
|
||||
Daily: 'Daily'
|
||||
Weekly: 'Weekly'
|
||||
Monthly: 'Monthly'
|
||||
AllTime: 'AllTime'
|
||||
|
||||
# ------------------------------------------------
|
||||
# GUI Options
|
||||
# ------------------------------------------------
|
||||
|
||||
# Configure GUI's here
|
||||
# Note: Slots start at 0 instead of 1, max slot is 53 (don't go over) (E.g: last slot in first row of inventory is 8)
|
||||
# Item Material's can be found here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html
|
||||
GUI:
|
||||
# GUI for /vote gui, /vgui, votegui
|
||||
VoteGUI:
|
||||
# Items will be orders as it is below
|
||||
URL:
|
||||
# Standard item format, lore is automaticly applied
|
||||
Item:
|
||||
Material: 'BOW'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4URL'
|
||||
# You can set skulls of the player using the following
|
||||
# Remove the # to enable
|
||||
#Skull: '%Player%'
|
||||
Slot: 0
|
||||
Next:
|
||||
Item:
|
||||
Material: 'COMPASS'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Next'
|
||||
Slot: 1
|
||||
Last:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Last'
|
||||
Slot: 2
|
||||
Total:
|
||||
Item:
|
||||
Material: 'CHEST'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Total'
|
||||
Slot: 3
|
||||
Top:
|
||||
Item:
|
||||
Material: 'SIGN'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Top'
|
||||
Slot: 4
|
||||
Today:
|
||||
Item:
|
||||
Material: 'BOOK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Today'
|
||||
Slot: 5
|
||||
Shop:
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Vote Shop'
|
||||
Lore:
|
||||
- '&aYou currently have %points% points'
|
||||
Slot: 6
|
||||
|
||||
# GUI for /vote url
|
||||
# And /vote if enabled in Config.yml
|
||||
VoteURL:
|
||||
# GUI Name
|
||||
Name: '&cVoteURL'
|
||||
BackButton: true
|
||||
SiteName: '&c%Name%'
|
||||
SeeURL: '&cClick to see URL'
|
||||
NextVote: '&cCan Vote In: %Info%'
|
||||
ViewAllUrlsButtonEnabled: true
|
||||
AllUrlsButton:
|
||||
AlreadyVotedItem:
|
||||
Material: 'REDSTONE_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4All Voting Sites'
|
||||
Lore:
|
||||
- '&cClick Me'
|
||||
CanVoteItem:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4All Voting Sites'
|
||||
Lore:
|
||||
- '&cClick Me'
|
||||
AlreadyVotedItem:
|
||||
Material: 'REDSTONE_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
CanVoteItem:
|
||||
Material: 'EMERALD_BLOCK'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
URLText: '%VoteUrl%'
|
||||
# Customize /vote reward
|
||||
# Show players what you get when you vote on each site
|
||||
VoteReward:
|
||||
# Name of votesite
|
||||
ExampleVoteSite:
|
||||
# items in /vote reward sitename
|
||||
Items:
|
||||
# Item
|
||||
# This is not the item display name
|
||||
# Do not have 2 of the same items
|
||||
Diamond:
|
||||
# Item ID
|
||||
Material: 'DIAMOND'
|
||||
# Item Data (Eg 1:4, data is 4)
|
||||
Data: 0
|
||||
# Amount of items
|
||||
# Should be greater than 0
|
||||
Amount: 1
|
||||
# Item name
|
||||
# Remove this line for no name
|
||||
Name: '&4Example'
|
||||
# Lore
|
||||
# Remove this line for no lore
|
||||
Lore:
|
||||
- '&4Line 1'
|
||||
Slot: 0
|
||||
VoteLast:
|
||||
Name: 'VoteLast: %player%'
|
||||
BackButton: true
|
||||
VoteNext:
|
||||
Name: 'VoteNext: %player%'
|
||||
BackButton: true
|
||||
VoteToday:
|
||||
Name: 'VoteToday'
|
||||
BackButton: true
|
||||
VoteTop:
|
||||
Name: 'VoteTop %topvoter%'
|
||||
BackButton: false
|
||||
Item:
|
||||
Name: '&3&l%position%: &3%player%'
|
||||
Lore: '&3&lVotes: &3%votes%'
|
||||
SwitchItem:
|
||||
Name: 'Switch TopVoter'
|
||||
Lore: 'Currently: %Top%'
|
||||
Material: 'SIGN'
|
||||
Amount: 1
|
||||
# 8 Slots over from the bottom left
|
||||
Slot: 7
|
||||
# Number of topvoters to display on page +9
|
||||
# 9 Slots on the botton are used for page buttons
|
||||
Size: 27
|
||||
VoteTotal:
|
||||
Name: 'VoteTotal: %player%'
|
||||
BackButton: true
|
||||
DayTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
WeekTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
MonthTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
AllTimeTotal:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cAllTime Total'
|
||||
Lore: '&c&lTotal: &c%Total%'
|
||||
Amount: 1
|
||||
VoteBest:
|
||||
Name: 'VoteBest: %player%'
|
||||
DayBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cDaily Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
WeekBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cWeekly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
MonthBest:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cMonthly Best'
|
||||
Lore: '&c&lBest: &c%Best%'
|
||||
Amount: 1
|
||||
VoteStreak:
|
||||
Name: 'VoteStreak: %player%'
|
||||
BackButton: false
|
||||
CurrentDayStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentWeekStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
CurrentMonthStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cCurrent Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestDayStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Daily Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestWeekStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Weekly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
HighestMonthStreak:
|
||||
Item:
|
||||
Material: 'CLOCK'
|
||||
Name: '&cHighest Monthly Streak'
|
||||
Lore: '&c&lStreak: &c%Streak%'
|
||||
Amount: 1
|
||||
VoteURLSite:
|
||||
Name: 'VoteSite: %site%'
|
||||
VoteGUIName: '&cVoteGUI: &c&l%player%'
|
||||
VoteRewardName: 'VoteReward'
|
||||
VoteShopName: 'VoteShop'
|
||||
|
||||
BackButton:
|
||||
Material: 'PAPER'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&8Back to VoteGUI'
|
||||
|
||||
VoteShopBackButton: true
|
||||
VoteShopEnabled: true
|
||||
Shop:
|
||||
# Identifier
|
||||
# Used in placeholders for formats
|
||||
Diamond:
|
||||
# Item
|
||||
Material: 'DIAMOND'
|
||||
Data: 0
|
||||
Amount: 1
|
||||
Name: '&4Buy A Diamond'
|
||||
# You can set skulls of the player using the following
|
||||
# Remove the # to enable
|
||||
#Skull: '%Player%'
|
||||
Lore:
|
||||
- '&c&lCost: &c3 Voting Points'
|
||||
# Number of voting points this cost
|
||||
Cost: 3
|
||||
# Permission required, leave blank for no permission
|
||||
Permission: ''
|
||||
# Rewards to run if player buys succesfully
|
||||
Rewards:
|
||||
Items:
|
||||
Diamond:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
# Slot
|
||||
Slot: 0
|
||||
|
||||
# ------------------------------------------------
|
||||
# Extra Rewards
|
||||
# ------------------------------------------------
|
||||
|
||||
# To disable reward set value to []
|
||||
# Eg:
|
||||
# FirstVote: [] (All in one line)
|
||||
# By default all rewards are disabled
|
||||
|
||||
# First vote rewards
|
||||
FirstVote:
|
||||
Messages:
|
||||
Player: '&aYou voted for your first time!'
|
||||
Money: 100
|
||||
|
||||
# All vote rewards
|
||||
# Reward for voting on all sites in one day
|
||||
AllSites:
|
||||
Messages:
|
||||
Player: '&aYou voted on all sites in 1 day!'
|
||||
|
||||
Cumulative:
|
||||
# Number of votes required
|
||||
# Allows multiple cumulative rewards
|
||||
# Number be be around ' (E.g. '1')
|
||||
# Can have multiple listed here
|
||||
'20':
|
||||
Enabled: false
|
||||
# Wether or not votes must be made in same day/week
|
||||
# Useful if you want to require a certain number of voting sites to be voted on
|
||||
# for a daily/weekly reward instead of all of them
|
||||
VotesInSameDay: false
|
||||
VotesInSameWeek: false
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %cumulative% cumulative votes!'
|
||||
|
||||
VoteParty:
|
||||
# Wether or not vote party is enabled
|
||||
Enabled: false
|
||||
# Number of votes required to give rewards
|
||||
VotesRequired: 20
|
||||
# Increase the amount of votes required on each vote party reached
|
||||
#IncreaseVotesRquired: 10
|
||||
# If true, players who did not vote to reach the votes required will
|
||||
# recieve the reward
|
||||
GiveAllPlayers: false
|
||||
# If true, the vote count will reset each day
|
||||
ResetEachDay: false
|
||||
# Reset at the end of the month
|
||||
ResetMonthly: false
|
||||
# Count votes from /av vote?
|
||||
CountFakeVotes: true
|
||||
# Number of user votes that apply to vote party total the user needs to get rewards
|
||||
UserVotesRequired: 0
|
||||
# Broadcast when vote party reached
|
||||
Broadcast: '&cReached the vote party amount!'
|
||||
# List of commands to execute, these only execute once.
|
||||
Commands: []
|
||||
# Reward files to give
|
||||
Rewards: []
|
||||
|
||||
# Reset milestons at end of the month
|
||||
ResetMilestonesMonthly: false
|
||||
|
||||
MileStones:
|
||||
# Number of votes required
|
||||
# Allows multiple milestones
|
||||
# Number be be around ' (E.g. '1')
|
||||
# Can have multiple listed here
|
||||
'20':
|
||||
Enabled: false
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou got %milestone% milestone votes!'
|
||||
|
||||
VoteStreak:
|
||||
# Valid options: Day, Week, Month
|
||||
Day:
|
||||
# Number of days in a row
|
||||
# Each day requires one vote
|
||||
# Add a - to give a reward for every multiple (e.g. 2-)
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
# Rewards to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: "&aYou voted for %Streak% %Type%'s in a row!"
|
||||
Week:
|
||||
# Number of weeks in a row
|
||||
# Requires atleast one vote per week
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
# Rewards to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: "&aYou voted for %Streak% %Type%'s in a row!"
|
||||
Month:
|
||||
# Number of months in a row
|
||||
# Requires atleast 1 vote per month
|
||||
'2':
|
||||
# Enabled or not
|
||||
Enabled: false
|
||||
# Rewards to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: "&aYou voted for %Streak% %Type%'s in a row!"
|
||||
|
||||
|
||||
# ONLY USE THIS FOR TITLES/SOUNDS AND OTHER EFFECTS
|
||||
# IT WILL ONLY RUN ONE TIME FOR ANY NUMBER OF OFFLINE VOTES
|
||||
# Any reward files listed here are ran on vote of any site
|
||||
# It is recommended to add rewards to each site instead of here
|
||||
# Using forceoffline won't work here
|
||||
AnySiteRewards: []
|
||||
|
||||
|
||||
# ------------------------------------------------
|
||||
# Top Voter
|
||||
# ------------------------------------------------
|
||||
|
||||
# Top voter blacklist
|
||||
BlackList:
|
||||
- 'Notch'
|
||||
|
||||
# If true players with the permission 'VotingPlugin.TopVoter.Ignore' will act
|
||||
# as if there name was added on the the blacklist above
|
||||
# This also applies for ops
|
||||
TopVoterIgnorePermission: false
|
||||
|
||||
# /vote top default data displayed
|
||||
# Valid Options: AllTime, Monthly, Weekly, Daily
|
||||
VoteTopDefault: Monthly
|
||||
|
||||
# Whether or not to have ties on top voter rewards
|
||||
TopVoterAwardsTies: true
|
||||
|
||||
# These are required to be enabled in order for top voter awards to work
|
||||
LoadTopVoter:
|
||||
AllTime: true
|
||||
Monthly: true
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
# When top voter awards are given (even if there are none listed) it will store top voters
|
||||
# Files will created in TopVoters folder.
|
||||
StoreTopVoters:
|
||||
Monthly: true
|
||||
Weekly: false
|
||||
Daily: false
|
||||
|
||||
EnableMonthlyAwards: true
|
||||
# Rewards to give
|
||||
MonthlyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
# Using 1-10 will reward players in first to tenth place with the same reward
|
||||
1:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in first place in %TopVoter%!'
|
||||
2:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in second place in %TopVoter%!'
|
||||
|
||||
EnableWeeklyAwards: false
|
||||
# Rewards to give on weekly top voter
|
||||
WeeklyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
1:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in first place in %TopVoter%!'
|
||||
2:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in second place in %TopVoter%!'
|
||||
|
||||
EnableDailyRewards: false
|
||||
# Rewards to give on daily top voter
|
||||
DailyAwards:
|
||||
# Position. 1 is first in top voter, 2 is second, etc...
|
||||
1:
|
||||
# Reward files to give
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in first place in %TopVoter%!'
|
||||
2:
|
||||
Rewards:
|
||||
Messages:
|
||||
Player: '&aYou came in second place in %TopVoter%!'
|
||||
|
||||
# ------------------------------------------------
|
||||
# Advanced
|
||||
# Most of these values can be left untouched
|
||||
# ------------------------------------------------
|
||||
|
||||
# Number of points to give on vote
|
||||
# Set to 0 to give no points
|
||||
PointsOnVote: 1
|
||||
|
||||
# Set this to false to disable the plugin adding totals
|
||||
# Not really recommended
|
||||
AddTotals: true
|
||||
|
||||
# Disable checking on world change
|
||||
# May improve performance
|
||||
DisableCheckOnWorldChange: false
|
||||
|
||||
# Debug
|
||||
Debug: false
|
||||
|
||||
# Extra Debug
|
||||
# Only needed in extreme cases
|
||||
ExtraDebug: false
|
||||
|
||||
# Debug info ingame
|
||||
# Players with permission "VotingPlugin.Debug"
|
||||
# will see debug info if debug is true
|
||||
DebugInGame: false
|
||||
|
||||
# Will log debug messages to VotingPlugin/Log/log.txt
|
||||
# Requires Debug to be on
|
||||
LogDebugToFile: false
|
||||
|
||||
# Options for request api
|
||||
# Current methods
|
||||
# ANVIL
|
||||
# BOOK
|
||||
# CHAT
|
||||
# This is mainly used for admin gui's to type in values
|
||||
RequestAPI:
|
||||
DefaultMethod: 'Anvil'
|
||||
DisabledMethods: []
|
||||
|
||||
# Wether or not to log every vote to a file
|
||||
# Use this if you wanna track player votes
|
||||
# Not recommended though
|
||||
LogVotesToFile: false
|
||||
|
||||
# Delay between background updates like signs and more
|
||||
# Default: 3 Minutes
|
||||
# Longer times result in longer wait in stuff updating after a vote, like topvoter
|
||||
DelayBetweenUpdates: 3
|
||||
|
||||
# Clear cache on update, setting to true reduces performance
|
||||
ClearCacheOnUpdate: false
|
||||
|
||||
# Clears cache for the player who voted only
|
||||
# Only effects if using mysql
|
||||
# Would recommend for some bungee setups
|
||||
ClearCacheOnVote: false
|
||||
|
||||
# Set to true to disable no service site message on voting
|
||||
# You should never have to touch this if everything is setup properly
|
||||
# Will also disable a few other warnings about vote sites
|
||||
DisableNoServiceSiteMessage: false
|
||||
|
||||
# Used in special cases
|
||||
# Much slower, but may work better
|
||||
AlternateUUIDLookup: false
|
||||
|
||||
# Shouldn't need to change this
|
||||
AutoKillInvs: true
|
||||
|
||||
# Count fake votes
|
||||
# If true fake votes will give points and totals
|
||||
CountFakeVotes: true
|
||||
|
||||
# Give VotingPlugin.Player by default
|
||||
# Requires restart to take affect
|
||||
GiveDefaultPermission: true
|
||||
|
||||
# Remove old player files
|
||||
# Happens on startup or /av purge
|
||||
PurgeOldData: false
|
||||
|
||||
# Minimum number of days offline in order to purge
|
||||
PurgeMin: 90
|
||||
|
||||
# Whether or not to disable checking names on mojang, disable if you hit the rate limit
|
||||
# Shouldn't make a noticeable impact if set to false
|
||||
CheckNameMojang: false
|
||||
|
||||
# Whether or not to create daily backups. (Only the most recent ones get saved)
|
||||
CreateBackups: true
|
||||
File renamed without changes.
@@ -0,0 +1,56 @@
|
||||
VoteSites:
|
||||
# VoteSite name
|
||||
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)
|
||||
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
|
||||
|
||||
# Reset vote delay each day (for certain sites that do this)
|
||||
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 GUI's
|
||||
# Removing this may result in an error, required on each site
|
||||
Item:
|
||||
Material: 'DIAMOND'
|
||||
Amount: 1
|
||||
|
||||
# Rewards to give
|
||||
# https://github.com/Ben12345rocks/AdvancedCore/wiki/Rewards
|
||||
Rewards:
|
||||
Commands:
|
||||
- 'say hello'
|
||||
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,221 @@
|
||||
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: [AdvancedCore]
|
||||
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
|
||||
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
|
||||
votebest:
|
||||
description: A command
|
||||
aliases: vbest
|
||||
votestreak:
|
||||
description: A command
|
||||
aliases: vstreak
|
||||
votepoints:
|
||||
description: A command
|
||||
aliases: vpoints
|
||||
votegivereward:
|
||||
description: A command
|
||||
voteselectChoiceReward:
|
||||
description: A command
|
||||
adminvotehelp:
|
||||
description: Open adminvote help
|
||||
aliases: avhelp
|
||||
adminvote?:
|
||||
description: Open adminvote help
|
||||
aliases: av?
|
||||
adminvoteconvert:
|
||||
description: A command
|
||||
adminvotereport:
|
||||
description: Command Alias
|
||||
aliases: avreport
|
||||
adminvoteperms:
|
||||
description: Command Alias
|
||||
aliases: avperms
|
||||
adminvoteDownload:
|
||||
description: Command Alias
|
||||
aliases: avdownload
|
||||
adminvotereload:
|
||||
description: Command Alias
|
||||
aliases: avreload
|
||||
adminvoteversion:
|
||||
description: Command Alias
|
||||
aliases: avversion
|
||||
adminvotesites:
|
||||
description: Command Alias
|
||||
aliases: avsites
|
||||
adminvoterewards:
|
||||
description: Command Alias
|
||||
aliases: avrewards
|
||||
adminvotereward:
|
||||
description: Command Alias
|
||||
aliases: avreward
|
||||
adminvoteuuid:
|
||||
description: Command Alias
|
||||
aliases: avuuid
|
||||
adminvotereset:
|
||||
description: Command Alias
|
||||
aliases: avreset
|
||||
adminvotevotesite:
|
||||
description: Command Alias
|
||||
aliases: avvotesite
|
||||
adminvoteconfig:
|
||||
description: Command Alias
|
||||
aliases: avconfig
|
||||
adminvoteserverdata:
|
||||
description: Command Alias
|
||||
aliases: avserverdata
|
||||
adminvotesettotal:
|
||||
description: Command Alias
|
||||
aliases: avsettotal
|
||||
adminvoteupdatecheck:
|
||||
description: Command Alias
|
||||
aliases: avupdatecheck
|
||||
adminvotevote:
|
||||
description: Command Alias
|
||||
aliases: [avvote, fakevote]
|
||||
adminvoteTriggerPlayerVoteEvent:
|
||||
description: Command Alias
|
||||
aliases: avTriggerPlayerVoteEvent
|
||||
adminvotesetpoints:
|
||||
description: Command Alias
|
||||
aliases: avsetpoints
|
||||
adminvoteaddpoints:
|
||||
description: Command Alias
|
||||
aliases: avaddpoints
|
||||
adminvotegui:
|
||||
description: Command Alias
|
||||
aliases: avgui
|
||||
votesetrequestmethod:
|
||||
description: Command Alias
|
||||
aliases: [vsetrequestmethod, setrequesetmethod]
|
||||
adminvotegivereward:
|
||||
description: Command Alias
|
||||
aliases: avgivereward
|
||||
adminvoteusers:
|
||||
description: Command Alias
|
||||
aliases: avusers
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
aliases: avClearTotal
|
||||
adminvoteConvertFromData:
|
||||
description: Command Alias
|
||||
aliases: avConvertFromData
|
||||
adminvoteClearTotal:
|
||||
description: Command Alias
|
||||
aliases: avClearTotal
|
||||
adminvoteBackgroundUpdate:
|
||||
description: Command Alias
|
||||
aliases: avBackgroundUpdate
|
||||
adminvoteClearCache:
|
||||
description: Command Alias
|
||||
aliases: avClearCache
|
||||
adminvoteConvertFrom:
|
||||
description: Command Alias
|
||||
aliases: avConvertFrom
|
||||
adminvoteRemovePoints:
|
||||
description: Command Alias
|
||||
aliases: avRemovePoints
|
||||
adminvoteServiceSites:
|
||||
description: Command Alias
|
||||
aliases: avServiceSites
|
||||
adminvoteSetVotePartyCount:
|
||||
description: Command Alias
|
||||
aliases: avSetVotePartyCount
|
||||
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
|
||||
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
|
||||
|
||||
@@ -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,193 @@
|
||||
<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.14.2</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>
|
||||
</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>
|
||||
</includes>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>Resources</directory>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<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.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>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>
|
||||
</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>
|
||||
</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>
|
||||
</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.13-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>
|
||||
</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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+32
-314
@@ -1,141 +1,67 @@
|
||||
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.Objects.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) {
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (CommandHandler commandHandler : plugin.adminVoteCommand) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
return true;
|
||||
@@ -143,217 +69,9 @@ public class CommandAdminVote implements CommandExecutor {
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+39
-21
@@ -7,23 +7,38 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
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 +46,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.adminVoteCommand);
|
||||
} else {
|
||||
handles.addAll(plugin.voteCommand);
|
||||
}
|
||||
|
||||
for (CommandHandler cmdHandle : handles) {
|
||||
if (cmdHandle.getArgs().length > args.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName()
|
||||
.equalsIgnoreCase("adminvote" + arg)) {
|
||||
|| cmd.getName().equalsIgnoreCase("adminvote" + arg)) {
|
||||
argsNew.set(0, arg);
|
||||
|
||||
boolean argsMatch = true;
|
||||
@@ -56,8 +73,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 +84,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
-319
@@ -1,139 +1,59 @@
|
||||
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.Objects.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) {
|
||||
if (commandHandler.runCommand(sender, args)) {
|
||||
@@ -142,217 +62,8 @@ public class CommandVote implements CommandExecutor {
|
||||
}
|
||||
|
||||
// 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,306 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.InputMethod;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequest;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.ValueRequestBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.BooleanListener;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.NumberListener;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.ValueRequest.Listeners.StringListener;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotiferEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class AdminGUI {
|
||||
static AdminGUI instance = new AdminGUI();
|
||||
|
||||
/**
|
||||
* Gets the single instance of Commands.
|
||||
*
|
||||
* @return single instance of Commands
|
||||
*/
|
||||
public static AdminGUI getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*/
|
||||
private AdminGUI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI.
|
||||
*
|
||||
* @return ArrayList of buttons
|
||||
*/
|
||||
public ArrayList<BInventoryButton> adminGUIButtons() {
|
||||
ArrayList<BInventoryButton> buttons = new ArrayList<BInventoryButton>();
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("&cOnly enabled sites are listed in this section");
|
||||
lore.add("&cMiddle Click to create");
|
||||
buttons.add(new BInventoryButton("&cVoteSites", ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (event.getClick().equals(ClickType.MIDDLE)) {
|
||||
|
||||
new ValueRequest().requestString(player, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
ConfigVoteSites.getInstance().generateVoteSite(value);
|
||||
player.sendMessage("Generated site");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
openAdminGUIVoteSites(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
lore = new ArrayList<String>();
|
||||
buttons.add(new BInventoryButton("&cReload Plugin", ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE, 1, (short) 3)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
event.getPlayer().performCommand("av reload");
|
||||
}
|
||||
|
||||
});
|
||||
return buttons;
|
||||
}
|
||||
|
||||
public void loadHook() {
|
||||
for (BInventoryButton b : adminGUIButtons()) {
|
||||
com.Ben12345rocks.AdvancedCore.Commands.GUI.AdminGUI.getInstance().addButton(b);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote sites.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public void openAdminGUIVoteSites(Player player) {
|
||||
BInventory inv = new BInventory("VoteSites");
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add("Priority: " + voteSite.getPriority());
|
||||
lore.add("Name: " + voteSite.getDisplayName());
|
||||
lore.add("ServiceSite: " + voteSite.getServiceSite());
|
||||
lore.add("VoteURL: " + voteSite.getVoteURL());
|
||||
lore.add("VoteDelay: " + voteSite.getVoteDelay());
|
||||
// lore.add("Rewards: " +
|
||||
// ArrayUtils.getInstance().makeStringList(voteSite.getRewards()));
|
||||
|
||||
inv.addButton(count, new BInventoryButton(voteSite.getKey(), ArrayUtils.getInstance().convert(lore),
|
||||
new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
openAdminGUIVoteSiteSite(player, voteSite);
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Open admin GUI vote site site.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param voteSite
|
||||
* the vote site
|
||||
*/
|
||||
public void openAdminGUIVoteSiteSite(Player player, VoteSite voteSite) {
|
||||
BInventory inv = new BInventory("VoteSite: " + voteSite.getDisplayName());
|
||||
inv.setMeta(player, "VoteSite", voteSite);
|
||||
|
||||
inv.addButton(new BInventoryButton(voteSite.getItem().setName("&cForce vote")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
ArrayList<String> playerNames = new ArrayList<String>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
playerNames.add(p.getName());
|
||||
}
|
||||
new ValueRequestBuilder(new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
Object ob = PlayerUtils.getInstance().getPlayerMeta(player, "VoteSite");
|
||||
if (ob != null) {
|
||||
VoteSite site = (VoteSite) ob;
|
||||
VotiferEvent.playerVote(value, site.getServiceSite(), false);
|
||||
}
|
||||
}
|
||||
}, ArrayUtils.getInstance().convert(playerNames)).usingMethod(InputMethod.INVENTORY)
|
||||
.allowCustomOption(true).request(event.getWhoClicked());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetPriority", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestNumber(player, "" + voteSite.getPriority(), null, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
ConfigVoteSites.getInstance().setPriority(voteSite.getKey(), value.intValue());
|
||||
player.sendMessage("Set Priority");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetServiceSite", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setServiceSite(siteName, value);
|
||||
player.sendMessage("Set ServiceSite");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetName", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestString(player, voteSite.getServiceSite(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
ConfigVoteSites.getInstance().setDisplayName(voteSite.getKey(), value);
|
||||
player.sendMessage("Set name");
|
||||
plugin.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteURL", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
new ValueRequest().requestString(player, voteSite.getVoteURL(), null, new StringListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, String value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteURL(siteName, value);
|
||||
player.sendMessage("Set VoteURL");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton("SetVoteDelay", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestNumber(player, "" + voteSite.getVoteDelay(), null, new NumberListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, Number value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setVoteDelay(siteName, value.intValue());
|
||||
player.sendMessage("Set VoteDelay");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(inv.getNextSlot(),
|
||||
new BInventoryButton("SetEnabled", new String[0], new ItemStack(Material.STONE)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
Player player = event.getWhoClicked();
|
||||
new ValueRequest().requestBoolean(player,
|
||||
"" + ConfigVoteSites.getInstance().getVoteSiteEnabled(voteSite.getKey()),
|
||||
new BooleanListener() {
|
||||
|
||||
@Override
|
||||
public void onInput(Player player, boolean value) {
|
||||
VoteSite voteSite = (VoteSite) event.getMeta("VoteSite");
|
||||
String siteName = voteSite.getKey();
|
||||
ConfigVoteSites.getInstance().setEnabled(siteName, value);
|
||||
player.sendMessage("Set Enabled");
|
||||
plugin.reload();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,691 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Commands.GUI;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.TopVoter;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.TopVoter.TopVoterHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteShop.VoteShop;
|
||||
|
||||
public class PlayerGUIs {
|
||||
static PlayerGUIs instance = new PlayerGUIs();
|
||||
|
||||
/**
|
||||
* Gets the single instance of Commands.
|
||||
*
|
||||
* @return single instance of Commands
|
||||
*/
|
||||
public static PlayerGUIs getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** The plugin. */
|
||||
Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Instantiates a new commands.
|
||||
*/
|
||||
private PlayerGUIs() {
|
||||
}
|
||||
|
||||
public ItemBuilder getBackButton() {
|
||||
ConfigurationSection sec = Config.getInstance().getBackButton();
|
||||
if (sec != null) {
|
||||
return new ItemBuilder(sec);
|
||||
}
|
||||
return new ItemBuilder(Material.PAPER, 1).setName("&8Back to VoteGUI");
|
||||
}
|
||||
|
||||
public User getSelectedPlayer(Player player) {
|
||||
User str = (User) PlayerUtils.getInstance().getPlayerMeta(player, "SelectedPlayerGUIs");
|
||||
return str;
|
||||
}
|
||||
|
||||
public void openVoteBest(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteBestName(), "player", user.getPlayerName()));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestDayBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestWeekBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteBestMonthBestItem())
|
||||
.addPlaceholder("Best", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteGUI(Player player, User user) {
|
||||
if (user == null) {
|
||||
user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
setSelectedPlayer(player, user);
|
||||
}
|
||||
if ((!player.getName().equals(user.getPlayerName())
|
||||
&& !player.hasPermission("VotingPlugin.Commands.Vote.GUI.Other")
|
||||
&& !player.hasPermission("VotingPlugin.Mod"))
|
||||
|| (!player.hasPermission("VotingPlugin.Commands.Vote.GUI")
|
||||
&& !player.hasPermission("VotingPlugin.Player"))) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize(AdvancedCoreHook.getInstance().getFormatNoPerms()));
|
||||
return;
|
||||
}
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteGUIName(), "player", user.getPlayerName()));
|
||||
|
||||
for (String slot : Config.getInstance().getVoteGUISlots()) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteGUISlotSection(slot));
|
||||
|
||||
String[] lore = new String[1];
|
||||
|
||||
lore = ArrayUtils.getInstance().convert(Config.getInstance().getVoteGUISlotLore(slot));
|
||||
|
||||
if (lore.length == 0) {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
lore = Commands.getInstance().voteURLs(user);
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
lore = Commands.getInstance().voteCommandNext(user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
lore = Commands.getInstance().voteCommandLast(user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
lore = Commands.getInstance().voteCommandTotal(user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
String str = Config.getInstance().getVoteTopDefault();
|
||||
if (str.equalsIgnoreCase("monthly")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterMonthly(1);
|
||||
} else if (str.equalsIgnoreCase("weekly")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterWeekly(1);
|
||||
} else if (str.equalsIgnoreCase("daily")) {
|
||||
lore = TopVoterHandler.getInstance().topVoterDaily(1);
|
||||
} else {
|
||||
lore = TopVoterHandler.getInstance().topVoterAllTime(1);
|
||||
}
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
lore = Commands.getInstance().voteToday();
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
lore = new String[] { "Click to view help" };
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("points", "" + user.getPoints());
|
||||
|
||||
builder.setPlaceholders(placeholders);
|
||||
builder.setLore(ArrayUtils.getInstance().convert(lore));
|
||||
|
||||
inv.addButton(Config.getInstance().getVoteGUISlotSlot(slot), new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
String cmd = Config.getInstance().getVoteGUISlotCommand(slot);
|
||||
User user = getSelectedPlayer(player);
|
||||
if (!cmd.equals("")) {
|
||||
player.performCommand(cmd);
|
||||
} else {
|
||||
if (slot.equalsIgnoreCase("url")) {
|
||||
openVoteURL(player);
|
||||
} else if (slot.equalsIgnoreCase("next")) {
|
||||
openVoteNext(player, user);
|
||||
} else if (slot.equalsIgnoreCase("last")) {
|
||||
openVoteLast(player, user);
|
||||
} else if (slot.equalsIgnoreCase("total")) {
|
||||
openVoteTotal(player, user);
|
||||
} else if (slot.equalsIgnoreCase("top")) {
|
||||
openVoteTop(player, null);
|
||||
} else if (slot.equalsIgnoreCase("today")) {
|
||||
openVoteToday(player);
|
||||
} else if (slot.equalsIgnoreCase("help")) {
|
||||
player.performCommand("vote help");
|
||||
} else if (slot.equalsIgnoreCase("shop")) {
|
||||
VoteShop.getInstance().voteShop(player);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteLast(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteLastName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandLastLine(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteLastBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteNext(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteNextName(), "player", user.getPlayerName()));
|
||||
for (VoteSite site : plugin.getVoteSites()) {
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(site.getItem().setName(site.getDisplayName())
|
||||
.setLore(Commands.getInstance().voteCommandNextInfo(user, site)).setAmountNone(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteNextBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteStreak(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteStreakName(), "player", user.getPlayerName()));
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakCurrentMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestDayStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestDayVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestWeekStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestWeekVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteStreakHighestMonthStreakItem())
|
||||
.addPlaceholder("Streak", "" + user.getBestMonthVoteStreak())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteStreakBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteToday(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteTodayName());
|
||||
for (User user : plugin.voteToday.keySet()) {
|
||||
|
||||
for (VoteSite voteSite : plugin.voteToday.get(user).keySet()) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(Config.getInstance().getFormatTimeFormat());
|
||||
String timeString = plugin.voteToday.get(user).get(voteSite).format(formatter);
|
||||
String msg = "&6" + user.getPlayerName() + " : " + voteSite.getDisplayName() + " : " + timeString;
|
||||
inv.addButton(inv.getNextSlot(), new BInventoryButton(user.getPlayerName(), new String[] { msg },
|
||||
MiscUtils.getInstance().setSkullOwner(user.getOfflinePlayer())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
User user = UserManager.getInstance()
|
||||
.getVotingPluginUser(clickEvent.getClickedItem().getItemMeta().getDisplayName());
|
||||
openVoteGUI(player, user);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteTodayBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void openVoteTop(Player player, TopVoter top) {
|
||||
if (top == null) {
|
||||
top = TopVoter.getDefault();
|
||||
}
|
||||
BInventory inv = null;
|
||||
Set<Entry<User, Integer>> users = null;
|
||||
String topVoter = "";
|
||||
if (top.equals(TopVoter.Monthly)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterMonthly();
|
||||
users = plugin.topVoterMonthly.entrySet();
|
||||
} else if (top.equals(TopVoter.Weekly)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterWeekly();
|
||||
users = plugin.topVoterWeekly.entrySet();
|
||||
} else if (top.equals(TopVoter.Daily)) {
|
||||
topVoter = Config.getInstance().getFormatTopVoterDaily();
|
||||
users = plugin.topVoterDaily.entrySet();
|
||||
} else {
|
||||
topVoter = Config.getInstance().getFormatTopVoterAllTime();
|
||||
users = plugin.topVoterAllTime.entrySet();
|
||||
}
|
||||
inv = new BInventory(StringUtils.getInstance().replacePlaceHolder(Config.getInstance().getGUIVoteTopName(),
|
||||
"topvoter", topVoter));
|
||||
int pos = 1;
|
||||
for (Entry<User, Integer> entry : users) {
|
||||
|
||||
inv.addButton(new BInventoryButton(
|
||||
new ItemBuilder(MiscUtils.getInstance().setSkullOwner(entry.getKey().getOfflinePlayer()))
|
||||
.setName(Config.getInstance().getGUIVoteTopItemName())
|
||||
.addLoreLine(Config.getInstance().getGUIVoteTopItemLore())
|
||||
.addPlaceholder("position", "" + pos)
|
||||
.addPlaceholder("player", entry.getKey().getPlayerName())
|
||||
.addPlaceholder("votes", "" + entry.getValue())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
// ItemBuilder item = new ItemBuilder(clickEvent.getClickedItem());
|
||||
// String name = ChatColor.stripColor(item.getName()).split(":")[1].trim();
|
||||
String name = (String) clickEvent.getButton().getData("player");
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(name);
|
||||
openVoteGUI(player, user);
|
||||
}
|
||||
}.addData("player", entry.getKey().getPlayerName()));
|
||||
pos++;
|
||||
}
|
||||
final TopVoter cur = top;
|
||||
inv.getPageButtons().add(new BInventoryButton(
|
||||
new ItemBuilder(Config.getInstance().getGUIVoteTopSwitchItem()).addPlaceholder("Top", topVoter)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
if (!clickEvent.getClick().equals(ClickType.RIGHT)) {
|
||||
openVoteTop(player, cur.next());
|
||||
} else {
|
||||
openVoteTop(player, cur.prev());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteTopBackButton()) {
|
||||
inv.getPageButtons().add(new BInventoryButton(getBackButton().setSlot(1)) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.setPages(true);
|
||||
inv.setMaxInvSize(Config.getInstance().getGUIVoteTopSize());
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteTotal(Player player, User user) {
|
||||
setSelectedPlayer(player, user);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteTotalName(), "player", user.getPlayerName()));
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalDayTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getDailyTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalWeekTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getWeeklyTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalMonthTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getMonthTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
|
||||
}
|
||||
});
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Config.getInstance().getGUIVoteTotalAllTimeTotalItem())
|
||||
.addPlaceholder("Total", "" + user.getAllTimeTotal())) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
}
|
||||
});
|
||||
|
||||
if (Config.getInstance().getGUIVoteTotalBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote URL.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
*/
|
||||
public void openVoteURL(Player player) {
|
||||
setSelectedPlayer(player, null);
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteURLName());
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
|
||||
int count = 0;
|
||||
if (Config.getInstance().getVoteURLViewAllUrlsButtonEnabled()) {
|
||||
ItemBuilder builderAll = new ItemBuilder(
|
||||
Config.getInstance().getVoteURLAlreadyVotedAllUrlsButtonItemSection());
|
||||
if (user.canVoteAll()) {
|
||||
builderAll = new ItemBuilder(Config.getInstance().getVoteURLCanVoteAllUrlsButtonItemSection());
|
||||
}
|
||||
|
||||
if (!builderAll.hasCustomDisplayName()) {
|
||||
builderAll.setName("&4All Voting Sites");
|
||||
}
|
||||
if (!builderAll.hasCustomLore()) {
|
||||
builderAll.setLore("&cClick Me");
|
||||
}
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builderAll) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(event.getPlayer());
|
||||
Player player = event.getWhoClicked();
|
||||
player.closeInventory();
|
||||
user.sendMessage(Commands.getInstance().voteURLs(user));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
count++;
|
||||
}
|
||||
|
||||
for (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.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
|
||||
if (Config.getInstance().commandsVoteRewardFromVoteURL
|
||||
&& event.getClick().equals(ClickType.RIGHT)) {
|
||||
voteReward(player, voteSite.getKey());
|
||||
} else {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
user.sendMessage(StringUtils.getInstance().replacePlaceHolder(StringUtils.getInstance()
|
||||
.replacePlaceHolder(StringUtils.getInstance().replacePlaceHolder(
|
||||
Config.getInstance().getGUIVoteURLURLText(), "voteurl",
|
||||
voteSite.getVoteURL()), "sitename", voteSite.getDisplayName()),
|
||||
"player", player.getName()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
}
|
||||
|
||||
if (Config.getInstance().getGUIVoteURLBackButton()) {
|
||||
inv.addButton(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
|
||||
}
|
||||
|
||||
public void openVoteURL(Player player, String voteSite) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
VoteSite site = plugin.getVoteSite(voteSite);
|
||||
BInventory inv = new BInventory(StringUtils.getInstance()
|
||||
.replacePlaceHolder(Config.getInstance().getGUIVoteURLSiteName(), "site", site.getDisplayName()));
|
||||
inv.setMeta(player, "VoteSite", site);
|
||||
|
||||
inv.addButton(
|
||||
new BInventoryButton(new ItemBuilder(Material.BOW).setName("&4URL").addLoreLine("Click to see URL")) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
VoteSite site = (VoteSite) clickEvent.getMeta("VoteSite");
|
||||
clickEvent.getWhoClicked().sendMessage(site.getVoteURL());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.COMPASS).setName("&4Next Vote")
|
||||
.addLoreLine(Commands.getInstance().voteCommandNextInfo(user, site))) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent clickEvent) {
|
||||
openVoteURL(clickEvent.getPlayer());
|
||||
}
|
||||
});
|
||||
|
||||
inv.addButton(new BInventoryButton(new ItemBuilder(Material.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(new BInventoryButton(getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
openVoteGUI(event.getPlayer(), getSelectedPlayer(event.getPlayer()));
|
||||
}
|
||||
});
|
||||
}
|
||||
inv.openInventory(player);
|
||||
}
|
||||
|
||||
public void setSelectedPlayer(Player player, User user) {
|
||||
PlayerUtils.getInstance().setPlayerMeta(player, "SelectedPlayerGUIs", user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vote reward.
|
||||
*
|
||||
* @param player
|
||||
* the player
|
||||
* @param siteName
|
||||
* the site name
|
||||
*/
|
||||
public void voteReward(Player player, String siteName) {
|
||||
BInventory inv = new BInventory(Config.getInstance().getGUIVoteRewardName());
|
||||
|
||||
if ((siteName == null) || (siteName == "")) {
|
||||
int count = 0;
|
||||
for (VoteSite voteSite : plugin.getVoteSites()) {
|
||||
try {
|
||||
ItemBuilder builder = voteSite.getItem();
|
||||
final VoteSite site = voteSite;
|
||||
|
||||
inv.addButton(count, new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
player.performCommand("vote reward " + site.getKey());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
count++;
|
||||
} catch (Exception ex) {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (String itemName : Config.getInstance().getVoteSiteItems(siteName)) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getVoteSiteItemsSection(siteName, itemName));
|
||||
|
||||
inv.addButton(Config.getInstance().getVoteSiteItemsSlot(siteName, itemName),
|
||||
new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
if (player != null) {
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
+27
-90
@@ -2,115 +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.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
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.adminVoteCommand, 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 (StringUtils.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
return tab;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+43
-81
@@ -2,110 +2,71 @@ 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.Objects.CommandHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
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.adminVoteCommand);
|
||||
} else {
|
||||
cmdHandlers.addAll(plugin.voteCommand);
|
||||
}
|
||||
ConcurrentHashMap<String, ArrayList<String>> tabCompletes = TabCompleteHandler.getInstance()
|
||||
.getTabCompleteOptions();
|
||||
for (CommandHandler cmdHandle : cmdHandlers) {
|
||||
if (cmdHandle.getArgs().length >= argsIn.length) {
|
||||
for (String arg : cmdHandle.getArgs()[0].split("&")) {
|
||||
if (cmd.getName().equalsIgnoreCase("vote" + arg)
|
||||
|| cmd.getName()
|
||||
.equalsIgnoreCase("adminvote" + arg)) {
|
||||
// plugin.debug("Found cmd... attempting to get tab complete");
|
||||
|| 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 +79,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 +87,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 (StringUtils.getInstance().startsWithIgnoreCase(str, args[args.length - 1])) {
|
||||
tab.add(str);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(tab, String.CASE_INSENSITIVE_ORDER);
|
||||
|
||||
return tab;
|
||||
}
|
||||
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd) {
|
||||
public AliasesTabCompleter setCMDHandle(CommandHandler cmd, boolean adminCommand) {
|
||||
cmdHandle = cmd;
|
||||
this.adminCommand = adminCommand;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+28
-89
@@ -2,114 +2,53 @@ package com.Ben12345rocks.VotingPlugin.Commands.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.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.Objects.TabCompleteHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
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.voteCommand, 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 (StringUtils.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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,104 +7,160 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
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().getAutoCreateVoteSites()) {
|
||||
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, "Item.Material", "GRASS");
|
||||
set(siteName, "Item.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");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getCumulativeRewards(String siteName) {
|
||||
try {
|
||||
return (ArrayList<String>) getData(siteName).getList(
|
||||
"Cumulative.Rewards");
|
||||
} catch (Exception ex) {
|
||||
return new ArrayList<String>();
|
||||
plugin.loadVoteSites();
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
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");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 +168,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 +199,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 +216,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 +241,193 @@ 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");
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -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,148 @@
|
||||
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;
|
||||
|
||||
// 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),
|
||||
plugin.signs.add(new SignHandler("" + count, getSignLocation("" + 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 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 +151,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 +173,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);
|
||||
@@ -123,35 +197,33 @@ public class ServerData {
|
||||
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();
|
||||
}
|
||||
/**
|
||||
* Sets the sign.
|
||||
*
|
||||
* @param count
|
||||
* the count
|
||||
* @param location
|
||||
* the location
|
||||
* @param data
|
||||
* the data
|
||||
* @param position
|
||||
* the position
|
||||
*/
|
||||
public void setSign(String count, Location location, String data, int position) {
|
||||
|
||||
public void 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());
|
||||
getData().set("Signs." + count + ".World", location.getWorld().getName());
|
||||
int x = (int) location.getX();
|
||||
int z = (int) location.getZ();
|
||||
getData().set("Signs." + count + ".X", x);
|
||||
@@ -162,49 +234,23 @@ public class ServerData {
|
||||
saveData();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setup(Plugin p) {
|
||||
if (!p.getDataFolder().exists()) {
|
||||
p.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
dFile = new File(p.getDataFolder(), "ServerData.yml");
|
||||
|
||||
boolean genFile = false;
|
||||
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
dFile.createNewFile();
|
||||
genFile = true;
|
||||
} catch (IOException e) {
|
||||
Bukkit.getServer()
|
||||
.getLogger()
|
||||
.severe(ChatColor.RED
|
||||
+ "Could not create ServerData.yml!");
|
||||
}
|
||||
}
|
||||
|
||||
data = YamlConfiguration.loadConfiguration(dFile);
|
||||
data.options().header("DO NOT EDIT THIS FILE MANUALLY");
|
||||
if (genFile) {
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
setPrevMonth(c.getTime().getMonth());
|
||||
int day = c.getTime().getDay();
|
||||
ServerData.getInstance().setPrevDay(day);
|
||||
ServerData.getInstance().setPrevWeekDay(c.getTime().getDate());
|
||||
}
|
||||
saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,7 +1,7 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -9,32 +9,50 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class BlockBreak.
|
||||
*/
|
||||
public class BlockBreak implements Listener {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
/** 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();
|
||||
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);
|
||||
final Location loc = s.getLocation();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
if (sign.getLocation().equals(loc)) {
|
||||
sign.removeSign();
|
||||
sign.setValid(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,16 +10,33 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.SignHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
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();
|
||||
@@ -28,12 +45,10 @@ public class PlayerInteract implements Listener {
|
||||
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())) {
|
||||
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());
|
||||
UserManager.getInstance().getVotingPluginUser(player).sendMessage(sign.getRightClickMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,52 +6,67 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerJoinEvent.
|
||||
*/
|
||||
public class PlayerJoinEvent implements Listener {
|
||||
|
||||
/** The plugin. */
|
||||
private static Main plugin;
|
||||
|
||||
Data data = Data.getInstance();
|
||||
|
||||
/**
|
||||
* Instantiates a new player join event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlayerJoinEvent(Main plugin) {
|
||||
PlayerJoinEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On player login.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() {
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (event.getPlayer() == null) {
|
||||
|
||||
if (event.getPlayer() == null
|
||||
|| (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)
|
||||
&& AdvancedCoreHook.getInstance().getMysql() == null)) {
|
||||
return;
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
if (player != null) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
|
||||
User user = new User(player);
|
||||
// run remind
|
||||
user.loginMessage();
|
||||
|
||||
plugin.getServer().getScheduler()
|
||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
user.setPlayerName();
|
||||
if (user.getData().hasData()) {
|
||||
// give offline vote (if they voted
|
||||
// offline)
|
||||
|
||||
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,80 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlayerVoteEvent.
|
||||
*/
|
||||
public class PlayerVoteAllSitesEvent extends Event {
|
||||
|
||||
/** The Constant handlers. */
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Gets the handler list.
|
||||
*
|
||||
* @return the handler list
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
private User user;
|
||||
|
||||
/** The cancelled. */
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteAllSitesEvent(User user) {
|
||||
super();
|
||||
setUser(user);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the user
|
||||
*/
|
||||
public User getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* the user to set
|
||||
*/
|
||||
public void setUser(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,52 +3,98 @@ 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;
|
||||
|
||||
// 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;
|
||||
/** The player. */
|
||||
private String player;
|
||||
|
||||
/** The vote site. */
|
||||
private VoteSite voteSite;
|
||||
|
||||
/** The cancelled. */
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerVoteEvent(VoteSite voteSite, User player) {
|
||||
public PlayerVoteEvent(VoteSite voteSite, String voteUsername) {
|
||||
super();
|
||||
setPlayer(player);
|
||||
setPlayer(voteUsername);
|
||||
setVoteSite(voteSite);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public User getPlayer() {
|
||||
/**
|
||||
* Gets the player.
|
||||
*
|
||||
* @return the player
|
||||
*/
|
||||
public String getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote site.
|
||||
*
|
||||
* @return the vote site
|
||||
*/
|
||||
public VoteSite getVoteSite() {
|
||||
return voteSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
public void setPlayer(User player) {
|
||||
this.player = player;
|
||||
public void setPlayer(String voteUsername) {
|
||||
this.player = voteUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote site.
|
||||
*
|
||||
* @param voteSite
|
||||
* the new vote site
|
||||
*/
|
||||
public void setVoteSite(VoteSite voteSite) {
|
||||
this.voteSite = voteSite;
|
||||
}
|
||||
|
||||
@@ -5,48 +5,67 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
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 (Utils.getInstance().hasPermission(event.getPlayer(),
|
||||
"Sign.Create")) {
|
||||
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),
|
||||
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() {
|
||||
event.getPlayer().sendMessage(StringUtils.getInstance().colorize("&aAdded sign!"));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().updateSigns();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void run() {
|
||||
Signs.getInstance().updateSigns();
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
event.getPlayer().sendMessage(
|
||||
Utils.getInstance().colorize(
|
||||
"&cError on sign creation!"));
|
||||
event.getPlayer().sendMessage(StringUtils.getInstance().colorize("&cError on sign creation!"));
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
event.getPlayer().sendMessage(
|
||||
ConfigFormat.getInstance().getNoPerms());
|
||||
event.getPlayer()
|
||||
.sendMessage(StringUtils.getInstance().colorize(Config.getInstance().getFormatNoPerms()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
/** The cancelled. */
|
||||
private boolean cancelled;
|
||||
|
||||
public VotePartyEvent() {
|
||||
super();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.bukkit.event.Event#getHandlers()
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is cancelled.
|
||||
*
|
||||
* @return true, if is cancelled
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the cancelled.
|
||||
*
|
||||
* @param bln
|
||||
* the new cancelled
|
||||
*/
|
||||
public void setCancelled(boolean bln) {
|
||||
cancelled = bln;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -9,218 +7,198 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UserStorage;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.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.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
import com.vexsoftware.votifier.model.Vote;
|
||||
import com.vexsoftware.votifier.model.VotifierEvent;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VotiferEvent.
|
||||
*/
|
||||
public class VotiferEvent implements Listener {
|
||||
|
||||
static ConfigOtherRewards bonusReward = ConfigOtherRewards.getInstance();
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
/** The plugin. */
|
||||
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");
|
||||
private static Object object = new Object();
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL) {
|
||||
playerVote(playerName, voteSiteURL, true);
|
||||
}
|
||||
|
||||
public static void playerVote(final String playerName, final String voteSiteURL, final boolean realVote) {
|
||||
|
||||
if (!config.allowUnJoined() && !PlayerUtils.getInstance().isValidUser(playerName)) {
|
||||
plugin.getLogger().warning("Player " + playerName
|
||||
+ " has not joined before, disregarding vote, set AllowUnjoined to true to prevent this");
|
||||
return;
|
||||
}
|
||||
|
||||
String voteSiteName = Utils.getInstance().getVoteSiteName(voteSiteURL);
|
||||
User user = UserManager.getInstance().getVotingPluginUser(playerName);
|
||||
|
||||
if (voteSiteName == null) {
|
||||
plugin.getLogger().info("Error on votesite name");
|
||||
return;
|
||||
}
|
||||
|
||||
// ArrayList<String> sites = configVoteSites.getVoteSitesNames();
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(voteSiteName);
|
||||
VoteSite voteSite = plugin.getVoteSite(voteSiteURL);
|
||||
if (voteSite == null) {
|
||||
if (!Config.getInstance().getDisableNoServiceSiteMessage()) {
|
||||
plugin.getLogger().warning("No voting site with the service site: '" + voteSiteURL + "'");
|
||||
plugin.getLogger().warning(
|
||||
"Please read here on how to fix it: https://github.com/Ben12345rocks/VotingPlugin/wiki/Common-Problems");
|
||||
|
||||
plugin.debug("VoteSite is null");
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
VoteParty.getInstance().addTotal();
|
||||
VoteParty.getInstance().addVotePlayer(user);
|
||||
VoteParty.getInstance().check();
|
||||
synchronized (object) {
|
||||
|
||||
// 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);
|
||||
}
|
||||
// vote party
|
||||
VoteParty.getInstance().vote(user, realVote);
|
||||
|
||||
// broadcast vote if enabled in config
|
||||
if (config.getBroadCastVotesEnabled()) {
|
||||
if (!Config.getInstance().getFormatBroadcastWhenOnline() || user.isOnline()) {
|
||||
voteSite.broadcastVote(user);
|
||||
}
|
||||
|
||||
// update last vote time
|
||||
user.setTime(voteSite);
|
||||
|
||||
// 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();
|
||||
}
|
||||
});
|
||||
|
||||
// update last vote time
|
||||
user.setTime(voteSite);
|
||||
|
||||
OtherVoteReward.getInstance().checkFirstVote(user);
|
||||
|
||||
if (user.isReminded()) {
|
||||
user.setReminded(false);
|
||||
}
|
||||
|
||||
// check if player has voted on all sites in one day
|
||||
|
||||
if (user.isOnline() || voteSite.isGiveOffline()) {
|
||||
user.playerVote(voteSite, true, false);
|
||||
user.closeInv();
|
||||
} else {
|
||||
user.addOfflineVote(voteSite.getKey());
|
||||
// plugin.debug(ArrayUtils.getInstance().makeStringList(user.getOfflineVotes()));
|
||||
plugin.debug(
|
||||
"Offline vote set for " + playerName + " (" + user.getUUID() + ") on " + voteSite.getKey());
|
||||
}
|
||||
|
||||
// add to total votes
|
||||
if (Config.getInstance().getCountFakeVotes() || realVote) {
|
||||
if (Config.getInstance().getAddTotals()) {
|
||||
user.addTotal();
|
||||
user.addTotalDaily();
|
||||
user.addTotalWeekly();
|
||||
}
|
||||
user.addPoints();
|
||||
}
|
||||
|
||||
OtherVoteReward.getInstance().checkAllSites(user);
|
||||
OtherVoteReward.getInstance().checkCumualativeVotes(user);
|
||||
OtherVoteReward.getInstance().checkMilestone(user);
|
||||
|
||||
if (Config.getInstance().getClearCacheOnVote()) {
|
||||
if (AdvancedCoreHook.getInstance().getStorageType().equals(UserStorage.MYSQL)) {
|
||||
AdvancedCoreHook.getInstance().getMysql().removePlayer(user.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugin.setUpdate(true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new votifer event.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VotiferEvent(Main plugin) {
|
||||
VotiferEvent.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* On votifer event.
|
||||
*
|
||||
* @param event
|
||||
* the event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onVotiferEvent(VotifierEvent event) {
|
||||
|
||||
Vote vote = event.getVote();
|
||||
String voteSite = vote.getServiceName();
|
||||
String voteUsername = vote.getUsername();
|
||||
final String voteSite = vote.getServiceName();
|
||||
final String voteUsername = vote.getUsername().trim();
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ServerData.getInstance().addServiceSite(voteSite);
|
||||
}
|
||||
});
|
||||
|
||||
if (voteUsername.length() == 0) {
|
||||
plugin.getLogger().warning("No name from vote on " + voteSite);
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getLogger().info(
|
||||
"Recieved a vote from '" + voteSite + "' by player '"
|
||||
+ voteUsername + "'!");
|
||||
plugin.getLogger().info("Recieved a vote from '" + voteSite + "' by player '" + voteUsername + "'!");
|
||||
|
||||
plugin.debug("PlayerUsername: " + voteUsername);
|
||||
plugin.debug("VoteSite: " + voteSite);
|
||||
|
||||
String voteSiteName = Utils.getInstance().getVoteSiteName(voteSite);
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(
|
||||
plugin.getVoteSite(voteSiteName), new User(voteUsername));
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
@Override
|
||||
public void run() {
|
||||
String voteSiteName = plugin.getVoteSiteName(voteSite);
|
||||
|
||||
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);
|
||||
}
|
||||
} else if (Config.getInstance().getAutoCreateVoteSites()) {
|
||||
plugin.getLogger().warning("VoteSite " + voteSiteName + " doe not exist, generaterating one...");
|
||||
ConfigVoteSites.getInstance().generateVoteSite(voteSiteName);
|
||||
}
|
||||
|
||||
PlayerVoteEvent voteEvent = new PlayerVoteEvent(plugin.getVoteSite(voteSiteName), voteUsername);
|
||||
plugin.getServer().getPluginManager().callEvent(voteEvent);
|
||||
|
||||
if (voteEvent.isCancelled()) {
|
||||
plugin.debug("Vote cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
playerVote(voteUsername, voteSite, true);
|
||||
|
||||
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);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Events;
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -5,28 +5,63 @@ 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 com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
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;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class SignHandler.
|
||||
*/
|
||||
public class SignHandler {
|
||||
|
||||
/** The sign. */
|
||||
private String sign;
|
||||
|
||||
/** The location. */
|
||||
private Location location;
|
||||
|
||||
/** The data. */
|
||||
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;
|
||||
|
||||
/** The is valid. */
|
||||
private boolean isValid;
|
||||
|
||||
/**
|
||||
* Instantiates a new sign handler.
|
||||
*
|
||||
* @param sign
|
||||
* the sign
|
||||
* @param location
|
||||
* the location
|
||||
* @param data
|
||||
* the data
|
||||
* @param position
|
||||
* the position
|
||||
*/
|
||||
public SignHandler(String sign, Location location, String data, int position) {
|
||||
setSign(sign);
|
||||
setLocation(location);
|
||||
@@ -39,22 +74,32 @@ public class SignHandler {
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
private boolean checkSkull(Block block) {
|
||||
if (block.getState() instanceof Skull) {
|
||||
Skull skull = (Skull) block.getState();
|
||||
skull.setOwner(playerName);
|
||||
skull.update();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check skulls.
|
||||
*/
|
||||
public void checkSkulls() {
|
||||
if (playerName.equalsIgnoreCase("No Player") || playerName.equals("")) {
|
||||
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() {
|
||||
|
||||
@@ -70,17 +115,31 @@ public class SignHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the data.
|
||||
*
|
||||
* @return the data
|
||||
*/
|
||||
public String getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the location.
|
||||
*
|
||||
* @return the location
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the right click message.
|
||||
*
|
||||
* @return the right click message
|
||||
*/
|
||||
public String getRightClickMessage() {
|
||||
String msg = ConfigFormat.getInstance()
|
||||
.getSignTopVoterSignRightClickMessage();
|
||||
String msg = Config.getInstance().getFormatSignTopVoterSignRightClickMessage();
|
||||
msg = msg.replace("%player%", playerName);
|
||||
msg = msg.replace("%position%", "" + position);
|
||||
msg = msg.replace("%votes%", "" + votes);
|
||||
@@ -88,136 +147,158 @@ public class SignHandler {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sign.
|
||||
*
|
||||
* @return the sign
|
||||
*/
|
||||
public String getSign() {
|
||||
return sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is location same.
|
||||
*
|
||||
* @param loc
|
||||
* the loc
|
||||
* @return true, if is location same
|
||||
*/
|
||||
public boolean isLocationSame(Location loc) {
|
||||
return loc.equals(getLocation());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is valid.
|
||||
*
|
||||
* @return true, if is valid
|
||||
*/
|
||||
public boolean isValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the sign.
|
||||
*/
|
||||
public void removeSign() {
|
||||
ServerData.getInstance().removeSign(sign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data.
|
||||
*
|
||||
* @param data
|
||||
* the new data
|
||||
*/
|
||||
public void setData(String data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the location.
|
||||
*
|
||||
* @param location
|
||||
* the new location
|
||||
*/
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the sign.
|
||||
*
|
||||
* @param sign
|
||||
* the new sign
|
||||
*/
|
||||
public void setSign(String sign) {
|
||||
this.sign = sign;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the valid.
|
||||
*
|
||||
* @param isValid
|
||||
* the new valid
|
||||
*/
|
||||
public void setValid(boolean isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store sign.
|
||||
*/
|
||||
public void storeSign() {
|
||||
ServerData.getInstance().setSign(sign, location, data, position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update lines.
|
||||
*/
|
||||
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();
|
||||
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);
|
||||
|
||||
if (data.equalsIgnoreCase("All")) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterMonthly.keySet());
|
||||
ArrayList<User> users = null;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
users = plugin.convertSet(plugin.topVoterAllTime.keySet());
|
||||
} else if (data.equalsIgnoreCase("monthly")) {
|
||||
users = plugin.convertSet(plugin.topVoterMonthly.keySet());
|
||||
} else if (data.equalsIgnoreCase("weekly")) {
|
||||
users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
} else if (data.equalsIgnoreCase("daily")) {
|
||||
users = plugin.convertSet(plugin.topVoterDaily.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));
|
||||
}
|
||||
if (users != null && users.size() >= position) {
|
||||
User user = users.get(position - 1);
|
||||
playerName = user.getPlayerName();
|
||||
|
||||
votes = 0;
|
||||
if (data.equalsIgnoreCase("all")) {
|
||||
votes = plugin.topVoterAllTime.get(user);
|
||||
} else if (data.equalsIgnoreCase("monthly")) {
|
||||
votes = plugin.topVoterMonthly.get(user);
|
||||
} else if (data.equalsIgnoreCase("weekly")) {
|
||||
votes = plugin.topVoterWeekly.get(user);
|
||||
} else if (data.equalsIgnoreCase("daily")) {
|
||||
votes = plugin.topVoterDaily.get(user);
|
||||
}
|
||||
|
||||
for (int j = 0; j < lines.size(); j++) {
|
||||
lines.set(j, lines.get(j).replace("%SiteName%", data)
|
||||
.replace("%position%", "" + position));
|
||||
lines.set(j, lines.get(j).replace("%votes%", "" + votes).replace("%player%", playerName));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
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() {
|
||||
|
||||
@@ -232,14 +313,30 @@ public class SignHandler {
|
||||
s.setLine(j, lines.get(j));
|
||||
}
|
||||
s.update();
|
||||
checkSkulls();
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (Config.getInstance().getDebugEnabled()) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
public void updateSkulls(Location loc1, Location loc2) {
|
||||
BlockState state = getLocation().getBlock().getState();
|
||||
if (state instanceof Sign) {
|
||||
org.bukkit.material.Sign s = (org.bukkit.material.Sign) state.getData();
|
||||
Block b = location.getBlock().getRelative(s.getAttachedFace());
|
||||
Block above = b.getRelative(BlockFace.UP);
|
||||
if (checkSkull(above)) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (Block block : MiscUtils.getInstance().getRegionBlocks(location.getWorld(), loc1, loc2)) {
|
||||
checkSkull(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Objects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
|
||||
public enum TopVoter {
|
||||
AllTime, Monthly, Weekly, Daily;
|
||||
|
||||
public static TopVoter getDefault() {
|
||||
TopVoter top = getTopVoter(Config.getInstance().getVoteTopDefault());
|
||||
if (top != null) {
|
||||
return top;
|
||||
}
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public static TopVoter getTopVoter(String str) {
|
||||
for (TopVoter value : values()) {
|
||||
if (value.toString().equalsIgnoreCase(str)) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return AllTime;
|
||||
}
|
||||
|
||||
public TopVoter next() {
|
||||
ArrayList<TopVoter> list = new ArrayList<TopVoter>();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
list.add(TopVoter.AllTime);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
list.add(TopVoter.Monthly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
list.add(TopVoter.Weekly);
|
||||
}
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
list.add(TopVoter.Daily);
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).equals(this)) {
|
||||
int next = i + 1;
|
||||
if (next > list.size() - 1) {
|
||||
next = 0;
|
||||
}
|
||||
return TopVoter.values()[next];
|
||||
}
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
|
||||
public TopVoter prev() {
|
||||
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;
|
||||
}
|
||||
return TopVoter.values()[prev];
|
||||
}
|
||||
}
|
||||
return TopVoter.AllTime;
|
||||
}
|
||||
}
|
||||
@@ -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,178 +1,335 @@
|
||||
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.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.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.UserManager.UserManager;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/** The vote URL. */
|
||||
private String voteURL;
|
||||
|
||||
/** The service site. */
|
||||
private String serviceSite;
|
||||
private String siteName;
|
||||
private int voteDelay;
|
||||
|
||||
/** The site name. */
|
||||
private String key;
|
||||
|
||||
private String displayName;
|
||||
|
||||
/** The vote delay. */
|
||||
private double voteDelay;
|
||||
|
||||
/** The enabled. */
|
||||
private boolean enabled;
|
||||
|
||||
private ArrayList<String> rewards;
|
||||
private boolean voteDelayDaily;
|
||||
|
||||
private int cumulativeVotes;
|
||||
private ArrayList<String> cumulativeRewards;
|
||||
/** The priority. */
|
||||
private int priority;
|
||||
|
||||
private ConfigurationSection item;
|
||||
|
||||
private boolean giveOffline;
|
||||
|
||||
/**
|
||||
* Instantiates a new vote site.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VoteSite(Main plugin) {
|
||||
VoteSite.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast vote.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void broadcastVote(User user) {
|
||||
if (!user.isVanished()) {
|
||||
String playerName = user.getPlayerName();
|
||||
String bc = StringUtils.getInstance().colorize(config.getFormatBroadCastMsg());
|
||||
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());
|
||||
bc = StringUtils.getInstance().replacePlaceHolder(bc, placeholders);
|
||||
ArrayList<Player> players = new ArrayList<Player>();
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (!UserManager.getInstance().getVotingPluginUser(p).getDisableBroadcast()) {
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
init();
|
||||
plugin.loadVoteSites();
|
||||
} else {
|
||||
init();
|
||||
|
||||
MiscUtils.getInstance().broadcast(bc, players);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broad cast a vote
|
||||
*
|
||||
* @param user
|
||||
* User to broadcast with
|
||||
* @return the displayName
|
||||
*/
|
||||
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 String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public ArrayList<String> getCumulativeRewards() {
|
||||
return cumulativeRewards;
|
||||
/**
|
||||
* @return the item
|
||||
*/
|
||||
public ItemBuilder getItem() {
|
||||
if (item == null) {
|
||||
plugin.getLogger().warning("Invalid item section in site: " + key);
|
||||
return new ItemBuilder(Material.STONE, 1).setName("&cInvalid item for site: " + key)
|
||||
.setLore("&cInvalid item for site: " + key);
|
||||
} else {
|
||||
return new ItemBuilder(item);
|
||||
}
|
||||
}
|
||||
|
||||
public int getCumulativeVotes() {
|
||||
return cumulativeVotes;
|
||||
/**
|
||||
* @return the key
|
||||
*/
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public ArrayList<String> getRewards() {
|
||||
return rewards;
|
||||
/**
|
||||
* Gets the priority.
|
||||
*
|
||||
* @return the priority
|
||||
*/
|
||||
public int getPriority() {
|
||||
return priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the service site.
|
||||
*
|
||||
* @return the service site
|
||||
*/
|
||||
public String getServiceSite() {
|
||||
return serviceSite;
|
||||
}
|
||||
|
||||
public String getSiteName() {
|
||||
return siteName;
|
||||
}
|
||||
|
||||
public int getVoteDelay() {
|
||||
/**
|
||||
* Gets the vote delay.
|
||||
*
|
||||
* @return the vote delay
|
||||
*/
|
||||
public double getVoteDelay() {
|
||||
return voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vote URL.
|
||||
*
|
||||
* @return the vote URL
|
||||
*/
|
||||
public String getVoteURL() {
|
||||
return voteURL;
|
||||
}
|
||||
|
||||
public void giveCulumativeRewards(User user) {
|
||||
for (String reward : getCumulativeRewards()) {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
/**
|
||||
* Give rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveRewards(User user, boolean online) {
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getRewardsPath(key)).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
|
||||
new RewardBuilder(configVoteSites.getData(), configVoteSites.getEverySiteRewardPath()).setOnline(online)
|
||||
.withPlaceHolder("ServiceSite", getServiceSite()).withPlaceHolder("SiteName", getDisplayName())
|
||||
.withPlaceHolder("VoteDelay", "" + getVoteDelay()).withPlaceHolder("VoteURL", getVoteURL()).send(user);
|
||||
}
|
||||
|
||||
public void giveRewards(User user) {
|
||||
for (String reward : getRewards()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Give site reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveSiteReward(User user, boolean online) {
|
||||
giveRewards(user, online);
|
||||
}
|
||||
|
||||
public void giveSiteReward(User user) {
|
||||
giveRewards(user);
|
||||
|
||||
try {
|
||||
|
||||
user.addCumulativeReward(this);
|
||||
|
||||
if (configVoteSites.getCumulativeRewardVotesAmount(siteName) != 0) {
|
||||
user.addCumulativeReward(this);
|
||||
if ((user.getCumulativeReward(this) >= configVoteSites
|
||||
.getCumulativeRewardVotesAmount(siteName))) {
|
||||
|
||||
giveCulumativeRewards(user);
|
||||
|
||||
user.setCumulativeReward(this, 0);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
public 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));
|
||||
setEnabled(configVoteSites.getVoteSiteEnabled(key));
|
||||
setPriority(configVoteSites.getPriority(key));
|
||||
displayName = configVoteSites.getDisplayName(key);
|
||||
if (displayName == null || displayName.equals("")) {
|
||||
displayName = key;
|
||||
}
|
||||
item = configVoteSites.getItem(key);
|
||||
voteDelayDaily = configVoteSites.getVoteSiteResetVoteDelayDaily(key);
|
||||
giveOffline = configVoteSites.getVoteSiteGiveOffline(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is enabled.
|
||||
*
|
||||
* @return true, if is enabled
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setCumulativeRewards(ArrayList<String> cumulativeRewards) {
|
||||
this.cumulativeRewards = cumulativeRewards;
|
||||
/**
|
||||
* @return the giveOffline
|
||||
*/
|
||||
public boolean isGiveOffline() {
|
||||
return giveOffline;
|
||||
}
|
||||
|
||||
public void setCumulativeVotes(int cumulativeVotes) {
|
||||
this.cumulativeVotes = cumulativeVotes;
|
||||
/**
|
||||
* @return the voteDelayDaily
|
||||
*/
|
||||
public boolean isVoteDelayDaily() {
|
||||
return voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayName
|
||||
* the displayName to set
|
||||
*/
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the enabled.
|
||||
*
|
||||
* @param enabled
|
||||
* the new enabled
|
||||
*/
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setRewards(ArrayList<String> rewards) {
|
||||
this.rewards = rewards;
|
||||
/**
|
||||
* @param giveOffline
|
||||
* the giveOffline to set
|
||||
*/
|
||||
public void setGiveOffline(boolean giveOffline) {
|
||||
this.giveOffline = giveOffline;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item
|
||||
* the item to set
|
||||
*/
|
||||
public void setItem(ConfigurationSection item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param key
|
||||
* the key to set
|
||||
*/
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the priority.
|
||||
*
|
||||
* @param priority
|
||||
* the new priority
|
||||
*/
|
||||
public void setPriority(int priority) {
|
||||
this.priority = priority;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the service site.
|
||||
*
|
||||
* @param serviceSite
|
||||
* the new service site
|
||||
*/
|
||||
public void setServiceSite(String serviceSite) {
|
||||
this.serviceSite = serviceSite;
|
||||
}
|
||||
|
||||
public void setSiteName(String siteName) {
|
||||
this.siteName = siteName;
|
||||
}
|
||||
|
||||
public void setVoteDelay(int voteDelay) {
|
||||
/**
|
||||
* Sets the vote delay.
|
||||
*
|
||||
* @param voteDelay
|
||||
* the new vote delay
|
||||
*/
|
||||
public void setVoteDelay(double voteDelay) {
|
||||
this.voteDelay = voteDelay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param voteDelayDaily
|
||||
* the voteDelayDaily to set
|
||||
*/
|
||||
public void setVoteDelayDaily(boolean voteDelayDaily) {
|
||||
this.voteDelayDaily = voteDelayDaily;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the vote URL.
|
||||
*
|
||||
* @param voteURL
|
||||
* the new vote URL
|
||||
*/
|
||||
public void setVoteURL(String voteURL) {
|
||||
this.voteURL = voteURL;
|
||||
}
|
||||
|
||||
+233
-49
@@ -1,48 +1,131 @@
|
||||
package com.Ben12345rocks.VotingPlugin.OtherRewards;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.PlayerVoteAllSitesEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class OtherVoteReward.
|
||||
*/
|
||||
public class OtherVoteReward {
|
||||
|
||||
static ConfigOtherRewards bonusReward = ConfigOtherRewards.getInstance();
|
||||
|
||||
/** The config. */
|
||||
static Config config = Config.getInstance();
|
||||
|
||||
/** The config vote sites. */
|
||||
static ConfigVoteSites configVoteSites = ConfigVoteSites.getInstance();
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
/** The instance. */
|
||||
static OtherVoteReward instance = new OtherVoteReward();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of OtherVoteReward.
|
||||
*
|
||||
* @return single instance of OtherVoteReward
|
||||
*/
|
||||
public static OtherVoteReward getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new other vote reward.
|
||||
*/
|
||||
private OtherVoteReward() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new other vote reward.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public OtherVoteReward(Main plugin) {
|
||||
OtherVoteReward.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check all sites.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkAllSites(User user) {
|
||||
return user.checkAllVotes();
|
||||
|
||||
boolean checkAllVotes = user.checkAllVotes();
|
||||
if (checkAllVotes) {
|
||||
giveAllSitesRewards(user, user.isOnline());
|
||||
}
|
||||
return checkAllVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check cumualative votes.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkCumualativeVotes(User user) {
|
||||
boolean gotCumulative = false;
|
||||
Set<String> votes = Config.getInstance().getCumulativeVotes();
|
||||
for (String vote : votes) {
|
||||
if (StringUtils.getInstance().isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getCumulativeRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getCumulativeRewardsPath(votesRequired))) {
|
||||
int total = 0;
|
||||
if (Config.getInstance().getCumulativeVotesInSameDay(votesRequired)) {
|
||||
total = user.getDailyTotal();
|
||||
} else if (Config.getInstance().getCumulativeVotesInSameWeek(votesRequired)) {
|
||||
total = user.getWeeklyTotal();
|
||||
} else {
|
||||
total = user.getAllTimeTotal();
|
||||
}
|
||||
|
||||
if ((total % votesRequired) == 0 && total != 0) {
|
||||
giveCumulativeVoteReward(user, user.isOnline(), votesRequired);
|
||||
gotCumulative = true;
|
||||
}
|
||||
|
||||
if (gotCumulative) {
|
||||
plugin.debug(user.getPlayerName() + " got cumulative " + votesRequired);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid cumulative number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotCumulative;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check first vote.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkFirstVote(User user) {
|
||||
int userVotesTotal = user.getTotalVotes();
|
||||
if (ConfigOtherRewards.getInstance().getFirstVoteRewards().size() != 0) {
|
||||
if (userVotesTotal <= 1 && !user.hasGottenFirstVote()) {
|
||||
user.setHasGottenFirstVote(true);
|
||||
if (RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath())) {
|
||||
if (!user.hasGottenFirstVote()) {
|
||||
giveFirstVoteRewards(user, user.isOnline());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -50,54 +133,155 @@ public class OtherVoteReward {
|
||||
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 {
|
||||
/**
|
||||
* Check milestone.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @return true, if successful
|
||||
*/
|
||||
public boolean checkMilestone(User user) {
|
||||
boolean gotMilestone = false;
|
||||
Set<String> votes = Config.getInstance().getMilestoneVotes();
|
||||
for (String vote : votes) {
|
||||
if (StringUtils.getInstance().isInt(vote)) {
|
||||
int votesRequired = Integer.parseInt(vote);
|
||||
if (votesRequired != 0) {
|
||||
if (Config.getInstance().getMilestoneRewardEnabled(votesRequired)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getMilestoneRewardsPath(votesRequired))) {
|
||||
|
||||
int userVotesTotal = user.getTotalVotes();
|
||||
if ((userVotesTotal % votesRequired) == 0) {
|
||||
return true;
|
||||
int userVotesTotal = user.getMilestoneCount();
|
||||
if (userVotesTotal >= votesRequired && !user.hasGottenMilestone(votesRequired)) {
|
||||
giveMilestoneVoteReward(user, user.isOnline(), votesRequired);
|
||||
user.setHasGotteMilestone(votesRequired, true);
|
||||
plugin.debug(user.getPlayerName() + " got milestone " + votesRequired);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
plugin.debug("Invalid milestone number: " + vote);
|
||||
}
|
||||
}
|
||||
return gotMilestone;
|
||||
}
|
||||
|
||||
public boolean checkVoteStreak(User user, String type) {
|
||||
boolean gotReward = false;
|
||||
|
||||
Set<String> streaks = Config.getInstance().getVoteStreakVotes(type);
|
||||
for (String streak : streaks) {
|
||||
String s = streak.replaceAll("-", "");
|
||||
boolean multiple = false;
|
||||
if (streak.contains("-")) {
|
||||
// multiple
|
||||
multiple = true;
|
||||
}
|
||||
if (StringUtils.getInstance().isInt(s)) {
|
||||
int streakRequired = Integer.parseInt(s);
|
||||
if (streakRequired != 0) {
|
||||
if (Config.getInstance().getVoteStreakRewardEnabled(type, streak)
|
||||
&& RewardHandler.getInstance().hasRewards(Config.getInstance().getData(),
|
||||
Config.getInstance().getVoteStreakRewardsPath(type, "" + streak))) {
|
||||
int curStreak = 0;
|
||||
if (type.equalsIgnoreCase("day")) {
|
||||
curStreak = user.getDayVoteStreak();
|
||||
} else if (type.equalsIgnoreCase("week")) {
|
||||
curStreak = user.getWeekVoteStreak();
|
||||
} else if (type.equalsIgnoreCase("month")) {
|
||||
curStreak = user.getMonthVoteStreak();
|
||||
}
|
||||
if (!multiple) {
|
||||
if (curStreak == streakRequired) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, "" + streakRequired, curStreak);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + " for " + type);
|
||||
}
|
||||
} else {
|
||||
if (curStreak != 0 && curStreak % streakRequired == 0) {
|
||||
giveVoteStreakReward(user, user.isOnline(), type, streakRequired + "-", curStreak);
|
||||
gotReward = true;
|
||||
plugin.debug(
|
||||
user.getPlayerName() + " got VoteStreak " + streakRequired + "* for " + type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
return gotReward;
|
||||
|
||||
}
|
||||
|
||||
public void giveAllSitesRewards(User user) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getAllSitesReward()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
/**
|
||||
* Give all sites rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveAllSitesRewards(User user, boolean online) {
|
||||
PlayerVoteAllSitesEvent event = new PlayerVoteAllSitesEvent(user);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getAllSitesRewardPath(), online);
|
||||
}
|
||||
|
||||
public void giveFirstVoteRewards(User user) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getFirstVoteRewards()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Give cumulative vote reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
* @param cumulative
|
||||
* the cumulative
|
||||
*/
|
||||
public void giveCumulativeVoteReward(User user, boolean online, int cumulative) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getCumulativeRewardsPath(cumulative))
|
||||
.setOnline(online).withPlaceHolder("Cumulative", "" + cumulative).send(user);
|
||||
}
|
||||
|
||||
public void giveNumberOfVotesRewards(User user) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getNumberOfVotes()) {
|
||||
if (reward != "") {
|
||||
ConfigRewards.getInstance().getReward(reward).giveReward(user);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Give first vote rewards.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
*/
|
||||
public void giveFirstVoteRewards(User user, boolean online) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getFirstVoteRewardsPath(), online);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give milestone vote reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
* @param online
|
||||
* the online
|
||||
* @param milestone
|
||||
* the milestone
|
||||
*/
|
||||
public void giveMilestoneVoteReward(User user, boolean online, int milestone) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getMilestoneRewardsPath(milestone))
|
||||
.setOnline(online).withPlaceHolder("Milestone", "" + milestone).send(user);
|
||||
}
|
||||
|
||||
public void giveVoteStreakReward(User user, boolean online, String type, String string, int votes) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVoteStreakRewardsPath(type, string))
|
||||
.setOnline(online).withPlaceHolder("Type", type).withPlaceHolder("Streak", "" + votes).send(user);
|
||||
}
|
||||
|
||||
}
|
||||
-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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,29 +5,53 @@ 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,30 +62,36 @@ public class Signs {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load signs.
|
||||
*/
|
||||
public void loadSigns() {
|
||||
plugin.signs = new ArrayList<SignHandler>();
|
||||
for (String sign : ServerData.getInstance().getSigns()) {
|
||||
// plugin.getLogger().info("Loading sign " + sign);
|
||||
plugin.signs.add(new SignHandler(sign, ServerData.getInstance()
|
||||
.getSignLocation(sign), ServerData.getInstance()
|
||||
.getSignData(sign), ServerData.getInstance()
|
||||
.getSignPosition(sign)));
|
||||
plugin.signs.add(new SignHandler(sign, ServerData.getInstance().getSignLocation(sign),
|
||||
ServerData.getInstance().getSignData(sign), ServerData.getInstance().getSignPosition(sign)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store signs.
|
||||
*/
|
||||
public void storeSigns() {
|
||||
for (SignHandler sign : plugin.signs) {
|
||||
sign.storeSign();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update signs.
|
||||
*/
|
||||
public void updateSigns() {
|
||||
for (int i = plugin.signs.size() - 1; i >= 0; i--) {
|
||||
if (!plugin.signs.get(i).isValid()) {
|
||||
plugin.debug("Sign " + i + " invalid, removing from data.");
|
||||
plugin.signs.get(i).removeSign();
|
||||
plugin.signs.remove(i);
|
||||
plugin.debug("Sign " + plugin.signs.get(i).getSign()
|
||||
+ " invalid, removing from data.");
|
||||
} else {
|
||||
plugin.signs.get(i).updateLines();
|
||||
plugin.signs.get(i).updateSign(i * 3);
|
||||
|
||||
@@ -1,600 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.TopVoter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigTopVoterAwards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class TopVoter {
|
||||
|
||||
static ConfigFormat format = ConfigFormat.getInstance();
|
||||
|
||||
static TopVoter instance = new TopVoter();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static TopVoter getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private TopVoter() {
|
||||
}
|
||||
|
||||
public TopVoter(Main plugin) {
|
||||
TopVoter.plugin = plugin;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void checkTopVoterAward() {
|
||||
if (hasMonthChanged()) {
|
||||
plugin.getLogger().info("Month changed!");
|
||||
TopVoters.getInstance().storeMonthlyTopVoters(
|
||||
new Date().getYear() + 1900, new Date().getMonth(),
|
||||
topVoterNoColor());
|
||||
if (ConfigTopVoterAwards.getInstance().getMonthlyAwardsEnabled()) {
|
||||
Set<String> places = ConfigTopVoterAwards.getInstance()
|
||||
.getMonthlyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
for (User user : plugin.topVoterMonthly.keySet()) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(user
|
||||
.getPlayerName());
|
||||
if (!player.getPlayer().hasPermission(
|
||||
"VotingPlugin.TopVoter.Ignore")) {
|
||||
i++;
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.monthlyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetTotalsMonthly();
|
||||
|
||||
}
|
||||
|
||||
if (hasWeekChanged()) {
|
||||
plugin.getLogger().info("Week changed!");
|
||||
TopVoters.getInstance().storeWeeklyTopVoters(
|
||||
new Date().getYear() + 1900, new Date().getMonth(),
|
||||
new Date().getDate(), topVoterWeeklyNoColor());
|
||||
if (ConfigTopVoterAwards.getInstance().getWeeklyAwardsEnabled()) {
|
||||
Set<String> places = ConfigTopVoterAwards.getInstance()
|
||||
.getWeeklyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
for (User user : plugin.topVoterWeekly.keySet()) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(user
|
||||
.getPlayerName());
|
||||
if (!player.getPlayer().hasPermission(
|
||||
"VotingPlugin.TopVoter.Ignore")) {
|
||||
i++;
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.weeklyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetTotalsWeekly();
|
||||
|
||||
}
|
||||
|
||||
if (hasDayChanged()) {
|
||||
plugin.getLogger().info("Day changed!");
|
||||
TopVoters.getInstance().storeDailyTopVoters(
|
||||
new Date().getYear() + 1900, new Date().getMonth(),
|
||||
new Date().getDate(), topVoterDailyNoColor());
|
||||
if (ConfigTopVoterAwards.getInstance().getDailyAwardsEnabled()) {
|
||||
Set<String> places = ConfigTopVoterAwards.getInstance()
|
||||
.getDailyPossibleRewardPlaces();
|
||||
int i = 0;
|
||||
for (User user : plugin.topVoterDaily.keySet()) {
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(user
|
||||
.getPlayerName());
|
||||
if (!player.getPlayer().hasPermission(
|
||||
"VotingPlugin.TopVoter.Ignore")) {
|
||||
i++;
|
||||
if (places.contains(Integer.toString(i))) {
|
||||
user.dailyTopVoterAward(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetTotalsDaily();
|
||||
|
||||
}
|
||||
|
||||
plugin.debug("Checked Top Voter Awards");
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasDayChanged() {
|
||||
int prevDay = ServerData.getInstance().getPrevDay();
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
int day = c.getTime().getDay();
|
||||
ServerData.getInstance().setPrevDay(day);
|
||||
if (prevDay != day) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasMonthChanged() {
|
||||
int prevMonth = ServerData.getInstance().getPrevMonth();
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
int month = c.getTime().getMonth();
|
||||
ServerData.getInstance().setPrevMonth(month);
|
||||
if (prevMonth != month) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean hasWeekChanged() {
|
||||
int prevDate = ServerData.getInstance().getPrevWeekDay();
|
||||
java.util.TimeZone tz = java.util.TimeZone.getTimeZone(ConfigFormat
|
||||
.getInstance().getTimeZone());
|
||||
java.util.Calendar c = java.util.Calendar.getInstance(tz);
|
||||
ServerData.getInstance().setPrevWeekDay(c.getTime().getDate());
|
||||
if (ServerData.getInstance().getPrevDay() == 0
|
||||
&& c.getTime().getDate() != prevDate) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void resetTotalsDaily() {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance()
|
||||
.getVoteSites()) {
|
||||
user.setTotalDaily(voteSite, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTotalsMonthly() {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance()
|
||||
.getVoteSites()) {
|
||||
user.setTotal(voteSite, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTotalsPlayer(User user) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance().getVoteSites()) {
|
||||
user.setTotal(voteSite, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void resetTotalsWeekly() {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (VoteSite voteSite : ConfigVoteSites.getInstance()
|
||||
.getVoteSites()) {
|
||||
user.setTotalWeekly(voteSite, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String[] topVoterDaily(int page) {
|
||||
int pagesize = ConfigFormat.getInstance().getPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = Utils.getInstance().convertArray(
|
||||
topVotersDaily());
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = format.getCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page)
|
||||
.replace("%maxpages%", "" + pageSize).replace("%Top%", "Daily");
|
||||
msg.add(Utils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size())
|
||||
&& (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterDailyNoColor() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterDaily.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%"
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterDaily.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterMonthly(int page) {
|
||||
int pagesize = ConfigFormat.getInstance().getPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = Utils.getInstance().convertArray(
|
||||
topVoters());
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = format.getCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page)
|
||||
.replace("%maxpages%", "" + pageSize)
|
||||
.replace("%Top%", "Monthly");
|
||||
msg.add(Utils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size())
|
||||
&& (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterNoColor() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterMonthly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%"
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterMonthly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoters() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(
|
||||
plugin.topVoterMonthly.entrySet());
|
||||
int i = 0;
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
String line = format.getCommandVoteTopLine()
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", entry.getKey().getPlayerName())
|
||||
.replace("%votes%", "" + entry.getValue().intValue());
|
||||
|
||||
msg.add(line);
|
||||
i++;
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVotersDaily() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterDaily.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = format
|
||||
.getCommandVoteTopLine()
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterDaily.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public ArrayList<User> topVotersSortedAll() {
|
||||
ArrayList<String> blackList = (ArrayList<String>) ConfigTopVoterAwards
|
||||
.getInstance().getBlackList();
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
if (users1 != null) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalVotes() == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
if (blackList != null) {
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (blackList.contains(users.get(i).getPlayerName())) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(users, new Comparator<User>() {
|
||||
|
||||
@Override
|
||||
public int compare(User p1, User p2) {
|
||||
int p1Total = p1.getTotalVotes();
|
||||
int p2Total = p2.getTotalVotes();
|
||||
|
||||
return Integer.compare(p1Total, p2Total);
|
||||
}
|
||||
});
|
||||
|
||||
return users;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<User> topVotersSortedAllDaily() {
|
||||
ArrayList<String> blackList = (ArrayList<String>) ConfigTopVoterAwards
|
||||
.getInstance().getBlackList();
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
if (users1 != null) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalDailyAll() == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
if (blackList != null) {
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (blackList.contains(users.get(i).getPlayerName())) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(users, new Comparator<User>() {
|
||||
|
||||
@Override
|
||||
public int compare(User p1, User p2) {
|
||||
int p1Total = p1.getTotalDailyAll();
|
||||
int p2Total = p2.getTotalDailyAll();
|
||||
|
||||
return Integer.compare(p1Total, p2Total);
|
||||
}
|
||||
});
|
||||
|
||||
return users;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ArrayList<User> topVotersSortedAllWeekly() {
|
||||
ArrayList<String> blackList = (ArrayList<String>) ConfigTopVoterAwards
|
||||
.getInstance().getBlackList();
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
if (users1 != null) {
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalWeeklyAll() == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
if (blackList != null) {
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (blackList.contains(users.get(i).getPlayerName())) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Collections.sort(users, new Comparator<User>() {
|
||||
|
||||
@Override
|
||||
public int compare(User p1, User p2) {
|
||||
int p1Total = p1.getTotalWeeklyAll();
|
||||
int p2Total = p2.getTotalWeeklyAll();
|
||||
|
||||
return Integer.compare(p1Total, p2Total);
|
||||
}
|
||||
});
|
||||
|
||||
return users;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> topVotersSortedVoteSite(VoteSite voteSite) {
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalVotesSite(voteSite) == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
for (int j = users.size() - 1; j >= 0; j--) {
|
||||
if (i != j) {
|
||||
if (users.get(i).getPlayerName() == users.get(j)
|
||||
.getPlayerName()) {
|
||||
users.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HashMap<User, Integer> topVoter = new HashMap<User, Integer>();
|
||||
for (User user : users) {
|
||||
topVoter.put(user, user.getTotal(voteSite));
|
||||
}
|
||||
|
||||
return Utils.getInstance().sortByValues(topVoter, false);
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> topVotersSortedVoteSiteDaily(VoteSite voteSite) {
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalDaily(voteSite) == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
for (int j = users.size() - 1; j >= 0; j--) {
|
||||
if (i != j) {
|
||||
if (users.get(i).getPlayerName() == users.get(j)
|
||||
.getPlayerName()) {
|
||||
users.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
HashMap<User, Integer> topVoter = new HashMap<User, Integer>();
|
||||
for (User user : users) {
|
||||
topVoter.put(user, user.getTotalDaily(voteSite));
|
||||
}
|
||||
|
||||
return Utils.getInstance().sortByValues(topVoter, false);
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> topVotersSortedVoteSiteWeekly(
|
||||
VoteSite voteSite) {
|
||||
Set<User> users1 = Data.getInstance().getUsers();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(users1);
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
if (users.get(i).getTotalWeekly(voteSite) == 0) {
|
||||
users.remove(i);
|
||||
}
|
||||
}
|
||||
for (int i = users.size() - 1; i >= 0; i--) {
|
||||
for (int j = users.size() - 1; j >= 0; j--) {
|
||||
if (i != j) {
|
||||
if (users.get(i).getPlayerName() == users.get(j)
|
||||
.getPlayerName()) {
|
||||
users.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashMap<User, Integer> topVoter = new HashMap<User, Integer>();
|
||||
for (User user : users) {
|
||||
topVoter.put(user, user.getTotalWeekly(voteSite));
|
||||
}
|
||||
|
||||
return Utils.getInstance().sortByValues(topVoter, false);
|
||||
}
|
||||
|
||||
public String[] topVotersWeekly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterWeekly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = format
|
||||
.getCommandVoteTopLine()
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterWeekly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterWeekly(int page) {
|
||||
int pagesize = ConfigFormat.getInstance().getPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = Utils.getInstance().convertArray(
|
||||
topVotersWeekly());
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = format.getCommandVoteTopTitle()
|
||||
.replace("%page%", "" + page)
|
||||
.replace("%maxpages%", "" + pageSize)
|
||||
.replace("%Top%", "Weekly");
|
||||
msg.add(Utils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size())
|
||||
&& (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = Utils.getInstance().colorize(msg);
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public String[] topVoterWeeklyNoColor() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = Utils.getInstance().convertSet(
|
||||
plugin.topVoterWeekly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%"
|
||||
.replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%",
|
||||
"" + plugin.topVoterWeekly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
return Utils.getInstance().convertArray(msg);
|
||||
}
|
||||
|
||||
public void updateTopVoters() {
|
||||
plugin.topVoterMonthly.clear();
|
||||
ArrayList<User> users = topVotersSortedAll();
|
||||
if (users != null) {
|
||||
for (User user : users) {
|
||||
plugin.topVoterMonthly.put(user, user.getTotalVotes());
|
||||
}
|
||||
plugin.topVoterMonthly = Utils.getInstance().sortByValues(
|
||||
plugin.topVoterMonthly, false);
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly.clear();
|
||||
users = topVotersSortedAllWeekly();
|
||||
if (users != null) {
|
||||
for (User user : users) {
|
||||
plugin.topVoterWeekly.put(user, user.getTotalWeeklyAll());
|
||||
}
|
||||
plugin.topVoterWeekly = Utils.getInstance().sortByValues(
|
||||
plugin.topVoterWeekly, false);
|
||||
}
|
||||
|
||||
plugin.topVoterDaily.clear();
|
||||
users = topVotersSortedAllDaily();
|
||||
if (users != null) {
|
||||
for (User user : users) {
|
||||
plugin.topVoterDaily.put(user, user.getTotalDailyAll());
|
||||
}
|
||||
plugin.topVoterDaily = Utils.getInstance().sortByValues(
|
||||
plugin.topVoterDaily, false);
|
||||
}
|
||||
|
||||
plugin.debug("Updated TopVoter");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
package com.Ben12345rocks.VotingPlugin.TopVoter;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.AdvancedCoreHook;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.PreDateChangedEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.WeekChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.YML.YMLFileHandler;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.OtherRewards.OtherVoteReward;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class TopVoterHandler implements Listener {
|
||||
/** The instance. */
|
||||
static TopVoterHandler instance = new TopVoterHandler();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of TopVoter.
|
||||
*
|
||||
* @return single instance of TopVoter
|
||||
*/
|
||||
public static TopVoterHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new top voter.
|
||||
*/
|
||||
private TopVoterHandler() {
|
||||
}
|
||||
|
||||
public ArrayList<String> getTopVoterBlackList() {
|
||||
return Config.getInstance().getBlackList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters weekly.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
|
||||
public String[] getTopVotersWeekly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterWeekly.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine().replace("%num%", "" + (i + 1))
|
||||
.replace("%player%", users.get(i).getPlayerName())
|
||||
.replace("%votes%", "" + plugin.topVoterWeekly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
private HashMap<Integer, String> handlePlaces(Set<String> places) {
|
||||
HashMap<Integer, String> place = new HashMap<Integer, String>();
|
||||
for (String p : places) {
|
||||
String[] data = p.split("-");
|
||||
try {
|
||||
if (data.length > 1) {
|
||||
for (int i = Integer.parseInt(data[0]); i < Integer.parseInt(data[1]); i++) {
|
||||
place.put(i, p);
|
||||
}
|
||||
} else {
|
||||
place.put(Integer.parseInt(data[0]), p);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return place;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onDateChanged(DateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getDailyTotal() == 0 && user.getDayVoteStreak() != 0) {
|
||||
user.setDayVoteStreak(0);
|
||||
} else {
|
||||
user.addDayVoteStreak();
|
||||
}
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Day");
|
||||
|
||||
if (user.getHighestDailyTotal() < user.getDailyTotal()) {
|
||||
user.setHighestDailyTotal(user.getDailyTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersDaily()) {
|
||||
plugin.debug("Storing TopVoters Daily");
|
||||
storeDailyTopVoters();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getDailyAwardsEnabled()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getDailyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterDaily.keySet()) {
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getDailyTotal() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
user.giveDailyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getDailyTotal();
|
||||
}
|
||||
}
|
||||
resetDailyTotals();
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getMonthTotal() == 0 && user.getMonthVoteStreak() != 0) {
|
||||
user.setMonthVoteStreak(0);
|
||||
} else {
|
||||
user.addMonthVoteStreak();
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Month");
|
||||
}
|
||||
|
||||
if (user.getHighestMonthlyTotal() < user.getMonthTotal()) {
|
||||
user.setHighestMonthlyTotal(user.getMonthTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersMonthly()) {
|
||||
plugin.debug("Storing TopVoters Monthly");
|
||||
storeMonthlyTopVoters();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getMonthlyAwardsEnabled()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getMonthlyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterMonthly.keySet()) {
|
||||
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getMonthTotal() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
user.giveMonthlyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getMonthTotal();
|
||||
}
|
||||
}
|
||||
resetMonthlyTotals();
|
||||
|
||||
if (Config.getInstance().getResetMilestonesMonthly()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
user.setMilestoneCount(0);
|
||||
user.setHasGottenMilestone(new HashMap<String, Boolean>());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void onPreDateChanged(PreDateChangedEvent event) {
|
||||
plugin.setUpdate(true);
|
||||
plugin.update();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onWeekChange(WeekChangeEvent event) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getWeeklyTotal() == 0 && user.getWeekVoteStreak() != 0) {
|
||||
user.setWeekVoteStreak(0);
|
||||
} else {
|
||||
user.addWeekVoteStreak();
|
||||
OtherVoteReward.getInstance().checkVoteStreak(user, "Week");
|
||||
}
|
||||
|
||||
if (user.getHighestWeeklyTotal() < user.getWeeklyTotal()) {
|
||||
user.setHighestWeeklyTotal(user.getWeeklyTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getStoreTopVotersWeekly()) {
|
||||
plugin.debug("Storing TopVoters Weekly");
|
||||
storeWeeklyTopVoters();
|
||||
}
|
||||
|
||||
if (Config.getInstance().getWeeklyAwardsEnabled()) {
|
||||
HashMap<Integer, String> places = handlePlaces(Config.getInstance().getWeeklyPossibleRewardPlaces());
|
||||
int i = 0;
|
||||
int lastTotal = -1;
|
||||
for (User user : plugin.topVoterWeekly.keySet()) {
|
||||
if (!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore()) {
|
||||
if (Config.getInstance().getTopVoterAwardsTies()) {
|
||||
if (user.getWeeklyTotal() != lastTotal) {
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
if (places.containsKey(i)) {
|
||||
user.giveWeeklyTopVoterAward(i, places.get(i));
|
||||
}
|
||||
}
|
||||
lastTotal = user.getWeeklyTotal();
|
||||
}
|
||||
}
|
||||
resetWeeklyTotals();
|
||||
|
||||
}
|
||||
|
||||
public void register() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void resetDailyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getDailyTotal() != 0) {
|
||||
user.resetDailyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetMonthlyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getMonthTotal() != 0) {
|
||||
user.resetMonthlyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void resetWeeklyTotals() {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getWeeklyTotal() != 0) {
|
||||
user.resetWeeklyTotalVotes();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public LinkedHashMap<User, Integer> sortByValues(LinkedHashMap<User, Integer> topVoterAllTime,
|
||||
final boolean order) {
|
||||
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(topVoterAllTime.entrySet());
|
||||
|
||||
// Sorting the list based on values
|
||||
Collections.sort(list, new Comparator<Entry<User, Integer>>() {
|
||||
@Override
|
||||
public int compare(Entry<User, Integer> o1, Entry<User, Integer> o2) {
|
||||
if (order) {
|
||||
return o1.getValue().compareTo(o2.getValue());
|
||||
} else {
|
||||
return o2.getValue().compareTo(o1.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Maintaining insertion order with the help of LinkedList
|
||||
LinkedHashMap<User, Integer> sortedMap = new LinkedHashMap<User, Integer>();
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
public void storeDailyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(5);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
int day = time.getDayOfMonth();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Daily" + File.separator + year + "_" + month + "_" + day + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Day", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
public void storeMonthlyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(10);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Monthly" + File.separator + month + "_" + year + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Month", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
public void storeWeeklyTopVoters() {
|
||||
LocalDateTime time = LocalDateTime.now().minusHours(10);
|
||||
String month = time.getMonth().toString();
|
||||
int year = time.getYear();
|
||||
int week = time.getDayOfYear();
|
||||
YMLFileHandler file = new YMLFileHandler(new File(plugin.getDataFolder(),
|
||||
"TopVoter" + File.separator + "Weekly" + File.separator + year + "_" + month + "_" + week + ".yml"));
|
||||
file.setup();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
topVoters.add(count + ": " + entry.getKey().getPlayerName() + ": " + entry.getValue());
|
||||
count++;
|
||||
}
|
||||
file.getData().set("Week", topVoters);
|
||||
file.saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter all time
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterAllTime(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "All Time");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter weekly.
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterDaily(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "Daily");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter monthly
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterMonthly(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "Monthly");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters all time
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVotersAllTime() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(plugin.topVoterAllTime.entrySet());
|
||||
int i = 0;
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
} catch (Exception ex) {
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
|
||||
msg.add(line);
|
||||
i++;
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters daily.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
|
||||
public String[] topVotersDaily() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<User> users = plugin.convertSet(plugin.topVoterDaily.keySet());
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
line = line.replace("%player%", users.get(i).getPlayerName());
|
||||
} catch (Exception ex) {
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
line = line.replace("%votes%", "" + plugin.topVoterMonthly.get(users.get(i)));
|
||||
msg.add(line);
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voters.
|
||||
*
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVotersMonthly() {
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(plugin.topVoterMonthly.entrySet());
|
||||
int i = 0;
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
String line = "%num%: %player%, %votes%";
|
||||
line = line.replace("%num%", "" + (i + 1));
|
||||
try {
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
} catch (Exception ex) {
|
||||
AdvancedCoreHook.getInstance().debug(ex);
|
||||
}
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
|
||||
msg.add(line);
|
||||
i++;
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Top voter weekly.
|
||||
*
|
||||
* @param page
|
||||
* the page
|
||||
* @return the string[]
|
||||
*/
|
||||
public String[] topVoterWeekly(int page) {
|
||||
int pagesize = Config.getInstance().getFormatPageSize();
|
||||
ArrayList<String> msg = new ArrayList<String>();
|
||||
ArrayList<String> topVoters = new ArrayList<String>();
|
||||
int count = 1;
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
String line = Config.getInstance().getFormatCommandVoteTopLine();
|
||||
line = line.replace("%num%", "" + count);
|
||||
line = line.replace("%player%", entry.getKey().getPlayerName());
|
||||
line = line.replace("%votes%", "" + entry.getValue());
|
||||
topVoters.add(line);
|
||||
count++;
|
||||
}
|
||||
|
||||
int pageSize = (topVoters.size() / pagesize);
|
||||
if ((topVoters.size() % pagesize) != 0) {
|
||||
pageSize++;
|
||||
}
|
||||
|
||||
String title = Config.getInstance().getFormatCommandVoteTopTitle();
|
||||
title = title.replace("%page%", "" + page);
|
||||
title = title.replace("%maxpages%", "" + pageSize);
|
||||
title = title.replace("%Top%", "Weekly");
|
||||
msg.add(StringUtils.getInstance().colorize(title));
|
||||
|
||||
for (int i = (page - 1) * pagesize; (i < topVoters.size()) && (i < (((page - 1) * pagesize) + 10)); i++) {
|
||||
msg.add(topVoters.get(i));
|
||||
}
|
||||
|
||||
msg = ArrayUtils.getInstance().colorize(msg);
|
||||
return ArrayUtils.getInstance().convert(msg);
|
||||
}
|
||||
|
||||
public synchronized void updateTopVoters(ArrayList<User> users1) {
|
||||
ArrayList<User> users = new ArrayList<User>();
|
||||
ArrayList<String> blackList = getTopVoterBlackList();
|
||||
for (User user : users1) {
|
||||
if (!blackList.contains(user.getPlayerName())) {
|
||||
if ((!Config.getInstance().getTopVoterIgnorePermission() || !user.isTopVoterIgnore())
|
||||
&& !user.isBanned()) {
|
||||
users.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.topVoterAllTime.clear();
|
||||
if (Config.getInstance().getLoadTopVoterAllTime()) {
|
||||
for (User user : users) {
|
||||
int total = user.getAllTimeTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterAllTime.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterAllTime = sortByValues(plugin.topVoterAllTime, false);
|
||||
plugin.debug("All Time TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterMonthly.clear();
|
||||
if (Config.getInstance().getLoadTopVoterMonthly()) {
|
||||
for (User user : users) {
|
||||
int total = user.getMonthTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterMonthly.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterMonthly = sortByValues(plugin.topVoterMonthly, false);
|
||||
plugin.debug("Monthly TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly.clear();
|
||||
if (Config.getInstance().getLoadTopVoterWeekly()) {
|
||||
for (User user : users) {
|
||||
int total = user.getWeeklyTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterWeekly.put(user, total);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.topVoterWeekly = sortByValues(plugin.topVoterWeekly, false);
|
||||
plugin.debug("Weekly TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.topVoterDaily.clear();
|
||||
if (Config.getInstance().getLoadTopVoterDaily()) {
|
||||
for (User user : users) {
|
||||
int total = user.getDailyTotal();
|
||||
if (total > 0) {
|
||||
plugin.topVoterDaily.put(user, total);
|
||||
}
|
||||
}
|
||||
plugin.topVoterDaily = sortByValues(plugin.topVoterDaily, false);
|
||||
plugin.debug("Daily TopVoter loaded");
|
||||
}
|
||||
|
||||
plugin.debug("Updated TopVoter");
|
||||
}
|
||||
}
|
||||
@@ -1,176 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.TopVoter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
|
||||
public class TopVoters {
|
||||
|
||||
static TopVoters instance = new TopVoters();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static TopVoters getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private TopVoters() {
|
||||
}
|
||||
|
||||
public TopVoters(Main plugin) {
|
||||
TopVoters.plugin = plugin;
|
||||
}
|
||||
|
||||
public void storeDailyTopVoters(int year, int month, int date,
|
||||
String[] topVoters) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "TopVoters" + File.separator + "Daily", "TopVoters." + year
|
||||
+ "." + month + "." + date + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
|
||||
plugin.debug("Created file: " + "TopVoters." + year + "."
|
||||
+ month + "." + date + ".yml");
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create: " + "TopVoters."
|
||||
+ year + "." + month + "." + date + ".yml");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data.set("All", topVoters);
|
||||
for (VoteSite voteSite : plugin.voteSites) {
|
||||
ArrayList<String> voteSiteTop = new ArrayList<String>();
|
||||
int i = 1;
|
||||
HashMap<User, Integer> topVoterSite = TopVoter.getInstance()
|
||||
.topVotersSortedVoteSiteDaily(voteSite);
|
||||
for (Entry<User, Integer> entry : topVoterSite.entrySet()) {
|
||||
voteSiteTop.add(i + ": " + entry.getKey().getPlayerName()
|
||||
+ ", " + entry.getValue().intValue());
|
||||
i++;
|
||||
}
|
||||
data.set(voteSite.getSiteName(), voteSiteTop);
|
||||
}
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info(
|
||||
"Could not save: " + "TopVoters." + year + "." + month
|
||||
+ "." + date + ".yml");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void storeMonthlyTopVoters(int year, int month, String[] topVoters) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "TopVoters" + File.separator + "Monthly", "TopVoters." + year
|
||||
+ "." + month + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
|
||||
plugin.debug("Created file: " + "TopVoters." + year + "."
|
||||
+ month + ".yml");
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create: " + "TopVoters."
|
||||
+ year + "." + month + ".yml");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data.set("All", topVoters);
|
||||
for (VoteSite voteSite : plugin.voteSites) {
|
||||
ArrayList<String> voteSiteTop = new ArrayList<String>();
|
||||
int i = 1;
|
||||
HashMap<User, Integer> topVoterSite = TopVoter.getInstance()
|
||||
.topVotersSortedVoteSite(voteSite);
|
||||
for (Entry<User, Integer> entry : topVoterSite.entrySet()) {
|
||||
voteSiteTop.add(i + ": " + entry.getKey().getPlayerName()
|
||||
+ ", " + entry.getValue().intValue());
|
||||
i++;
|
||||
}
|
||||
data.set(voteSite.getSiteName(), voteSiteTop);
|
||||
}
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info(
|
||||
"Could not save: " + "TopVoters." + year + "." + month
|
||||
+ ".yml");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void storeWeeklyTopVoters(int year, int month, int day,
|
||||
String[] topVoters) {
|
||||
if (!plugin.getDataFolder().exists()) {
|
||||
plugin.getDataFolder().mkdir();
|
||||
}
|
||||
|
||||
File dFile = new File(plugin.getDataFolder() + File.separator
|
||||
+ "TopVoters" + File.separator + "Weekly", "TopVoters." + year
|
||||
+ "." + month + "." + day + ".yml");
|
||||
FileConfiguration data = YamlConfiguration.loadConfiguration(dFile);
|
||||
if (!dFile.exists()) {
|
||||
try {
|
||||
data.save(dFile);
|
||||
|
||||
plugin.debug("Created file: " + "TopVoters." + year + "."
|
||||
+ month + "." + day + ".yml");
|
||||
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().severe(
|
||||
ChatColor.RED + "Could not create: " + "TopVoters."
|
||||
+ year + "." + month + "." + day + ".yml");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
data.set("All", topVoters);
|
||||
for (VoteSite voteSite : plugin.voteSites) {
|
||||
ArrayList<String> voteSiteTop = new ArrayList<String>();
|
||||
int i = 1;
|
||||
HashMap<User, Integer> topVoterSite = TopVoter.getInstance()
|
||||
.topVotersSortedVoteSiteWeekly(voteSite);
|
||||
for (Entry<User, Integer> entry : topVoterSite.entrySet()) {
|
||||
voteSiteTop.add(i + ": " + entry.getKey().getPlayerName()
|
||||
+ ", " + entry.getValue().intValue());
|
||||
i++;
|
||||
}
|
||||
data.set(voteSite.getSiteName(), voteSiteTop);
|
||||
}
|
||||
try {
|
||||
data.save(dFile);
|
||||
} catch (IOException e) {
|
||||
plugin.getLogger().info(
|
||||
"Could not save: " + "TopVoters." + year + "." + month
|
||||
+ "." + day + ".yml");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Updater;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
public class CheckUpdate {
|
||||
|
||||
static CheckUpdate instance = new CheckUpdate();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static CheckUpdate getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private CheckUpdate() {
|
||||
}
|
||||
|
||||
public CheckUpdate(Main plugin) {
|
||||
CheckUpdate.plugin = plugin;
|
||||
}
|
||||
|
||||
public void checkUpdate() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case FAIL_SPIGOT: {
|
||||
plugin.getLogger().info(
|
||||
"Failed to check for update for " + plugin.getName() + "!");
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
plugin.getLogger().info(
|
||||
plugin.getName() + " is up to date! Version: "
|
||||
+ plugin.updater.getVersion());
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger().info(
|
||||
plugin.getName()
|
||||
+ " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion()
|
||||
+ " New Version: " + plugin.updater.getVersion());
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startUp() {
|
||||
Bukkit.getServer().getScheduler()
|
||||
.runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdate();
|
||||
}
|
||||
}, 20L);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Updater;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.ProtocolException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Updater {
|
||||
|
||||
public enum UpdateResult {
|
||||
BAD_RESOURCEID, DISABLED, FAIL_NOVERSION, FAIL_SPIGOT, NO_UPDATE, UPDATE_AVAILABLE
|
||||
}
|
||||
|
||||
private final String API_KEY = "98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4";
|
||||
private HttpURLConnection connection;
|
||||
private final String HOST = "http://www.spigotmc.org";
|
||||
private String oldVersion;
|
||||
private JavaPlugin plugin;
|
||||
private final String QUERY = "/api/general.php";
|
||||
|
||||
private final String REQUEST_METHOD = "POST";
|
||||
private String RESOURCE_ID = "";
|
||||
|
||||
private Updater.UpdateResult result = Updater.UpdateResult.DISABLED;
|
||||
|
||||
private String version;
|
||||
|
||||
private String WRITE_STRING;
|
||||
|
||||
public Updater(JavaPlugin plugin, Integer resourceId, boolean disabled) {
|
||||
RESOURCE_ID = resourceId + "";
|
||||
this.plugin = plugin;
|
||||
oldVersion = this.plugin.getDescription().getVersion();
|
||||
|
||||
if (disabled) {
|
||||
result = UpdateResult.DISABLED;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
connection = (HttpURLConnection) new URL(HOST + QUERY)
|
||||
.openConnection();
|
||||
} catch (IOException e) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
return;
|
||||
}
|
||||
|
||||
WRITE_STRING = "key=" + API_KEY + "&resource=" + RESOURCE_ID;
|
||||
run();
|
||||
}
|
||||
|
||||
public UpdateResult getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
private void run() {
|
||||
connection.setDoOutput(true);
|
||||
try {
|
||||
connection.setRequestMethod(REQUEST_METHOD);
|
||||
connection.getOutputStream().write(WRITE_STRING.getBytes("UTF-8"));
|
||||
} catch (ProtocolException e1) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
} catch (IOException e) {
|
||||
result = UpdateResult.FAIL_SPIGOT;
|
||||
}
|
||||
String version;
|
||||
try {
|
||||
version = new BufferedReader(new InputStreamReader(
|
||||
connection.getInputStream())).readLine();
|
||||
} catch (Exception e) {
|
||||
result = UpdateResult.BAD_RESOURCEID;
|
||||
return;
|
||||
}
|
||||
if (version.length() <= 7) {
|
||||
this.version = version;
|
||||
version.replace("[^A-Za-z]", "").replace("|", "");
|
||||
versionCheck();
|
||||
return;
|
||||
}
|
||||
result = UpdateResult.BAD_RESOURCEID;
|
||||
}
|
||||
|
||||
public boolean shouldUpdate(String localVersion, String remoteVersion) {
|
||||
return !localVersion.equalsIgnoreCase(remoteVersion);
|
||||
}
|
||||
|
||||
private void versionCheck() {
|
||||
if (shouldUpdate(oldVersion, version)) {
|
||||
result = UpdateResult.UPDATE_AVAILABLE;
|
||||
} else {
|
||||
result = UpdateResult.NO_UPDATE;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.Ben12345rocks.VotingPlugin.UserManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class UserManager {
|
||||
/** The instance. */
|
||||
static UserManager instance = new UserManager();
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of UserManager.
|
||||
*
|
||||
* @return single instance of UserManager
|
||||
*/
|
||||
public static UserManager getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public UserManager() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ArrayList<String> getAllUUIDs() {
|
||||
return com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().getAllUUIDs();
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(java.util.UUID uuid) {
|
||||
return getVotingPluginUser(new UUID(uuid.toString()));
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(OfflinePlayer player) {
|
||||
return getVotingPluginUser(player.getName());
|
||||
}
|
||||
|
||||
public User getVotingPluginUser(Player player) {
|
||||
return getVotingPluginUser(player.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public User getVotingPluginUser(String playerName) {
|
||||
return new User(com.Ben12345rocks.AdvancedCore.UserManager.UserManager.getInstance().getProperName(playerName));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public User getVotingPluginUser(UUID uuid) {
|
||||
return new User(uuid);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.PlaceHolders;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.Commands;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.VoteSite;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
import com.Ben12345rocks.VotingPlugin.VoteParty.VoteParty;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class PlaceHolders.
|
||||
*/
|
||||
public class PlaceHolders {
|
||||
|
||||
/** The instance. */
|
||||
static PlaceHolders instance = new PlaceHolders();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of PlaceHolders.
|
||||
*
|
||||
* @return single instance of PlaceHolders
|
||||
*/
|
||||
public static PlaceHolders getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*/
|
||||
private PlaceHolders() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new place holders.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public PlaceHolders(Main plugin) {
|
||||
PlaceHolders.plugin = plugin;
|
||||
}
|
||||
|
||||
public String getPlaceHolder(OfflinePlayer p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
|
||||
// %VotingPlugin_VotePartyVotesNeeded - Number of votes needed until
|
||||
// vote party rewards
|
||||
if (identifier.equalsIgnoreCase("VotePartyVotesNeeded")) {
|
||||
return Integer.toString(VoteParty.getInstance().getNeededVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesCurrent")) {
|
||||
return Integer.toString(VoteParty.getInstance().getTotalVotes());
|
||||
} else if (identifier.equalsIgnoreCase("VotePartyVotesRequired")) {
|
||||
return Integer.toString(VoteParty.getInstance().getVotesRequired());
|
||||
}
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(p);
|
||||
|
||||
// %VotingPlugin_total% - Total votes of all vote sites
|
||||
if (identifier.equalsIgnoreCase("total")) {
|
||||
return Integer.toString(user.getMonthTotal());
|
||||
} else if (identifier.equalsIgnoreCase("alltimetotal")) {
|
||||
return Integer.toString(user.getAllTimeTotal());
|
||||
} else if (identifier.equalsIgnoreCase("lastmonthtotal")) {
|
||||
return Integer.toString(user.getLastMonthTotal());
|
||||
}
|
||||
|
||||
String[] args = identifier.split("_");
|
||||
if (args.length > 1 && args[0].equalsIgnoreCase("total")) {
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
return Integer.toString(user.getAllTimeTotal());
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
return Integer.toString(user.getMonthTotal());
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
return Integer.toString(user.getWeeklyTotal());
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
return Integer.toString(user.getDailyTotal());
|
||||
}
|
||||
}
|
||||
|
||||
if (identifier.equalsIgnoreCase("BestDailyTotal")) {
|
||||
return "" + user.getHighestDailyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("BestWeeklyTotal")) {
|
||||
return "" + user.getHighestWeeklyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("BestMonthlyTotal")) {
|
||||
return "" + user.getHighestMonthlyTotal();
|
||||
} else if (identifier.equalsIgnoreCase("DailyVoteStreak")) {
|
||||
return "" + user.getDayVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("WeeklyVoteStreak")) {
|
||||
return "" + user.getWeekVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("MonthlyVoteStreak")) {
|
||||
return "" + user.getMonthVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestDailyVoteStreak")) {
|
||||
return "" + user.getBestDayVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestWeeklyVoteStreak")) {
|
||||
return "" + user.getBestWeekVoteStreak();
|
||||
} else if (identifier.equalsIgnoreCase("BestMonthlyVoteStreak")) {
|
||||
return "" + user.getBestMonthVoteStreak();
|
||||
}
|
||||
|
||||
// %VotingPlugin_points% - Total votes of all vote sites
|
||||
if (identifier.equalsIgnoreCase("points")) {
|
||||
return Integer.toString(user.getPoints());
|
||||
}
|
||||
|
||||
// %VotingPlugin_canvote% - Whether or not a player can vote on all
|
||||
// sites
|
||||
if (identifier.equalsIgnoreCase("canvote")) {
|
||||
return Boolean.toString(user.canVoteAll());
|
||||
}
|
||||
|
||||
// %VotingPlugin_next_SITENAME% - Next time you can vote for voteSite
|
||||
if (startsWithIgnoreCase(identifier, "next")) {
|
||||
if (args.length > 1) {
|
||||
String str = args[1];
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
str += "_" + args[i];
|
||||
}
|
||||
return playerNextVote(user, str);
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// %VotingPlugin_last_SITENAME% - Next time you can vote for voteSite
|
||||
if (startsWithIgnoreCase(identifier, "last")) {
|
||||
if (args.length > 1) {
|
||||
String str = args[1];
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
str += "_" + args[i];
|
||||
}
|
||||
return playerLastVote(user, str);
|
||||
}
|
||||
}
|
||||
if (args.length > 2) {
|
||||
if (args[0].equalsIgnoreCase("top")) {
|
||||
if (StringUtils.getInstance().isInt(args[2])) {
|
||||
int number = Integer.parseInt(args[2]);
|
||||
int num = 1;
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
if (num == number) {
|
||||
if (args.length > 3 && args[3].equalsIgnoreCase("votes")) {
|
||||
return "" + entry.getValue().intValue();
|
||||
} else {
|
||||
return entry.getKey().getPlayerName();
|
||||
}
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
} else if (args[2].equalsIgnoreCase("Position")) {
|
||||
int num = 1;
|
||||
if (args[1].equalsIgnoreCase("all")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterAllTime.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("month")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterMonthly.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("week")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterWeekly.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
} else if (args[1].equalsIgnoreCase("daily")) {
|
||||
for (Entry<User, Integer> entry : plugin.topVoterDaily.entrySet()) {
|
||||
if (entry.getKey().getUUID().equals(p.getUniqueId().toString())) {
|
||||
return "" + num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return identifier;
|
||||
}
|
||||
|
||||
public String getPlaceHolder(Player p, String identifier) {
|
||||
identifier = StringUtils.getInstance().replaceJavascript(p, identifier);
|
||||
return getPlaceHolder((OfflinePlayer) p, identifier);
|
||||
}
|
||||
|
||||
public String playerLastVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
return Commands.getInstance().voteCommandLastDuration(user, voteSite);
|
||||
}
|
||||
|
||||
public String playerNextVote(User user, String siteName) {
|
||||
if (!ConfigVoteSites.getInstance().getVoteSitesNames().contains(siteName)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
VoteSite voteSite = plugin.getVoteSite(siteName);
|
||||
return Commands.getInstance().voteCommandNextInfo(user, voteSite);
|
||||
}
|
||||
|
||||
public boolean startsWithIgnoreCase(String str1, String str2) {
|
||||
return str1.toLowerCase().startsWith(str2.toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.Ben12345rocks.VotingPlugin.Util.Updater;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Updater.Updater;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class CheckUpdate.
|
||||
*/
|
||||
public class CheckUpdate {
|
||||
|
||||
/** The instance. */
|
||||
static CheckUpdate instance = new CheckUpdate();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of CheckUpdate.
|
||||
*
|
||||
* @return single instance of CheckUpdate
|
||||
*/
|
||||
public static CheckUpdate getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new check update.
|
||||
*/
|
||||
private CheckUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new check update.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public CheckUpdate(Main plugin) {
|
||||
CheckUpdate.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check update.
|
||||
*/
|
||||
public void checkUpdate() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case FAIL_SPIGOT: {
|
||||
plugin.getLogger().info("Failed to check for update for " + plugin.getName() + "!");
|
||||
break;
|
||||
}
|
||||
case NO_UPDATE: {
|
||||
plugin.getLogger().info(plugin.getName() + " is up to date! Version: " + plugin.updater.getVersion());
|
||||
break;
|
||||
}
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkUpdateBasic() {
|
||||
plugin.updater = new Updater(plugin, 15358, false);
|
||||
final Updater.UpdateResult result = plugin.updater.getResult();
|
||||
switch (result) {
|
||||
case UPDATE_AVAILABLE: {
|
||||
plugin.getLogger()
|
||||
.info(plugin.getName() + " has an update available! Your Version: "
|
||||
+ plugin.getDescription().getVersion() + " New Version: " + plugin.updater.getVersion()
|
||||
+ " Use /av download to get the latest update!");
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Start up.
|
||||
*/
|
||||
public void startUp() {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdate();
|
||||
new Timer().schedule(new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
checkUpdateBasic();
|
||||
}
|
||||
}, 1000 * 60 * 1200, 1000 * 60 * 1200);
|
||||
|
||||
}
|
||||
}, 10l);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,754 +0,0 @@
|
||||
package com.Ben12345rocks.VotingPlugin;
|
||||
|
||||
import gyurix.api.TitleAPI;
|
||||
|
||||
import java.text.DateFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteSites;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
|
||||
public class Utils {
|
||||
|
||||
static Utils instance = new Utils();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static Utils getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private Utils() {
|
||||
}
|
||||
|
||||
public Utils(Main plugin) {
|
||||
Utils.plugin = plugin;
|
||||
}
|
||||
|
||||
public ItemStack addEnchants(ItemStack item,
|
||||
HashMap<String, Integer> enchants) {
|
||||
if ((enchants == null) || (enchants.size() == 0)) {
|
||||
return item;
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
for (String enchant : enchants.keySet()) {
|
||||
meta.addEnchant(Enchantment.getByName(enchant),
|
||||
enchants.get(enchant), false);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public ItemStack addLore(ItemStack item, List<String> lore) {
|
||||
if (lore == null) {
|
||||
return item;
|
||||
}
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setLore(colorize(lore));
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public ArrayList<String> colorize(ArrayList<String> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, colorize(list.get(i)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<String> colorize(List<String> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, colorize(list.get(i)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public String colorize(String format) {
|
||||
if (format == null) {
|
||||
return null;
|
||||
}
|
||||
return ChatColor.translateAlternateColorCodes('&', format);
|
||||
}
|
||||
|
||||
public String[] colorize(String[] list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = colorize(list[i]);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<String> comptoString(ArrayList<TextComponent> comps) {
|
||||
ArrayList<String> txt = new ArrayList<String>();
|
||||
for (TextComponent comp : comps) {
|
||||
txt.add(compToString(comp));
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
|
||||
public String compToString(TextComponent comp) {
|
||||
return colorize(comp.toPlainText());
|
||||
}
|
||||
|
||||
public User[] convert(ArrayList<User> array) {
|
||||
if (array == null) {
|
||||
return null;
|
||||
}
|
||||
User[] list = new User[array.size()];
|
||||
for (int i = 0; i < array.size(); i++) {
|
||||
list[i] = array.get(i);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<String> convert(Set<String> set) {
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
for (String st : set) {
|
||||
list.add(st);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String[] convertArray(ArrayList<String> list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
String[] string = new String[list.size()];
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
string[i] = list.get(i);
|
||||
}
|
||||
if (string == null) {
|
||||
return null;
|
||||
} else {
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public ArrayList<String> convertArray(String[] list) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<String> newlist = new ArrayList<String>();
|
||||
for (String element : list) {
|
||||
newlist.add(element);
|
||||
}
|
||||
if (newlist == null) {
|
||||
return null;
|
||||
} else {
|
||||
return newlist;
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<User> convertSet(Set<User> set) {
|
||||
if (set == null) {
|
||||
return null;
|
||||
}
|
||||
ArrayList<User> list = new ArrayList<User>();
|
||||
for (User user : set) {
|
||||
list.add(user);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getDayFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getDate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getHourFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getHours();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getMinutesFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getMinutes();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getMonthFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getMonth();
|
||||
}
|
||||
|
||||
public String getMonthString(int month) {
|
||||
if (month == 0) {
|
||||
month++;
|
||||
}
|
||||
return new DateFormatSymbols().getMonths()[month - 1];
|
||||
}
|
||||
|
||||
public String getPlayerName(String uuid) {
|
||||
if ((uuid == null) || uuid.equalsIgnoreCase("null")) {
|
||||
|
||||
plugin.debug("Null UUID");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
User user = new User(new com.Ben12345rocks.VotingPlugin.Objects.UUID(
|
||||
uuid), false);
|
||||
String playerName = Data.getInstance().getName(user);
|
||||
|
||||
if (playerName != null) {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(UUID.fromString(uuid));
|
||||
if (player == null) {
|
||||
playerName = Bukkit.getOfflinePlayer(UUID.fromString(uuid))
|
||||
.getName();
|
||||
return playerName;
|
||||
} else {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Block> getRegionBlocks(World world, Location loc1, Location loc2) {
|
||||
List<Block> blocks = new ArrayList<Block>();
|
||||
|
||||
for (double x = loc1.getX(); x <= loc2.getX(); x++) {
|
||||
for (double y = loc1.getY(); y <= loc2.getY(); y++) {
|
||||
for (double z = loc1.getZ(); z <= loc2.getZ(); z++) {
|
||||
Location loc = new Location(world, x, y, z);
|
||||
blocks.add(loc.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getUUID(String playerName) {
|
||||
if (playerName == null) {
|
||||
return null;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player == null) {
|
||||
return Bukkit.getOfflinePlayer(playerName).getUniqueId().toString();
|
||||
} else {
|
||||
return player.getUniqueId().toString();
|
||||
}
|
||||
}
|
||||
|
||||
public String getVoteSiteName(String url) {
|
||||
ArrayList<String> sites = ConfigVoteSites.getInstance()
|
||||
.getVoteSitesNames();
|
||||
if (url == null) {
|
||||
return null;
|
||||
}
|
||||
if (sites != null) {
|
||||
for (String siteName : sites) {
|
||||
String URL = ConfigVoteSites.getInstance().getServiceSite(
|
||||
siteName);
|
||||
if (URL != null) {
|
||||
if (URL.equals(url)) {
|
||||
return siteName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return url;
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public int getYearFromMili(long time) {
|
||||
Date date = new Date(time);
|
||||
return date.getYear();
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender, String perm) {
|
||||
return sender.hasPermission(plugin.getName() + "." + perm);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player, String perm) {
|
||||
return player.hasPermission(plugin.getName() + "." + perm);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String playerName, String perm) {
|
||||
if (playerName == null) {
|
||||
return false;
|
||||
}
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
return player.hasPermission(plugin.getName() + "." + perm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInt(String st) {
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
int num = Integer.parseInt(st);
|
||||
return true;
|
||||
|
||||
} catch (NumberFormatException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isPlayer(CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPlayerOnline(String playerName) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String makeString(int startIndex, String[] strs) {
|
||||
String str = new String();
|
||||
for (int i = startIndex; i < strs.length; i++) {
|
||||
if (i == startIndex) {
|
||||
str += strs[i];
|
||||
} else {
|
||||
str += " " + strs[i];
|
||||
}
|
||||
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public String makeStringList(ArrayList<String> list) {
|
||||
if (list == null) {
|
||||
return "";
|
||||
}
|
||||
String string = new String();
|
||||
if (list.size() > 1) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (i == 0) {
|
||||
string += list.get(i);
|
||||
} else {
|
||||
string += ", " + list.get(i);
|
||||
}
|
||||
}
|
||||
} else if (list.size() == 1) {
|
||||
string = list.get(0);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public ItemStack nameItem(ItemStack item, String name) {
|
||||
if (name == null) {
|
||||
return item;
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(name);
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
|
||||
}
|
||||
|
||||
public void printMap(HashMap<User, Integer> topVoterMonthly) {
|
||||
for (Entry<User, Integer> entry : topVoterMonthly.entrySet()) {
|
||||
plugin.debug("Key : " + entry.getKey().getPlayerName()
|
||||
+ " Value : " + entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<User> removeDoubleUsers(ArrayList<User> list) {
|
||||
Set<User> hs = new HashSet<User>();
|
||||
ArrayList<User> al = new ArrayList<User>();
|
||||
hs.addAll(list);
|
||||
al.clear();
|
||||
al.addAll(hs);
|
||||
|
||||
return al;
|
||||
}
|
||||
|
||||
public ArrayList<String> removeDuplicates(ArrayList<String> list) {
|
||||
Set<String> set = new HashSet<String>(list);
|
||||
return new ArrayList<String>(set);
|
||||
}
|
||||
|
||||
public List<String> replace(List<String> list, String toReplace,
|
||||
String replaceWith) {
|
||||
if (list == null) {
|
||||
return null;
|
||||
}
|
||||
if (replaceWith == null || toReplace == null) {
|
||||
return list;
|
||||
}
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
list.set(i, list.get(i).replace(toReplace, replaceWith));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public ArrayList<String> replaceIgnoreCase(ArrayList<String> list,
|
||||
String toReplace, String replaceWith) {
|
||||
ArrayList<String> newList = new ArrayList<String>();
|
||||
for (String msg : list) {
|
||||
newList.add(replaceIgnoreCase(msg, toReplace, replaceWith));
|
||||
}
|
||||
return newList;
|
||||
}
|
||||
|
||||
public String replaceIgnoreCase(String str, String toReplace,
|
||||
String replaceWith) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
}
|
||||
if ((toReplace == null) || (replaceWith == null)) {
|
||||
return str;
|
||||
}
|
||||
return str.replaceAll("(?i)" + toReplace, replaceWith);
|
||||
}
|
||||
|
||||
public String replacePlaceHolders(Player player, String text) {
|
||||
if (plugin.placeHolderAPIEnabled) {
|
||||
return PlaceholderAPI.setBracketPlaceholders(player, text);
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public void sendTitle(Player player, String title, String subTitle,
|
||||
int fadeIn, int showTime, int fadeOut) {
|
||||
if (plugin.spigotLibEnabled) {
|
||||
|
||||
if (title == null) {
|
||||
title = "";
|
||||
}
|
||||
if (subTitle == null) {
|
||||
subTitle = "";
|
||||
}
|
||||
TitleAPI.set(colorize(title), colorize(subTitle), fadeIn, showTime,
|
||||
fadeOut, player);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack setDurabilty(ItemStack item, int durability) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
if (durability > 0) {
|
||||
item.setDurability((short) durability);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
public ItemStack setSkullOwner(ItemStack item, String playerName) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
if (playerName == null || playerName.equalsIgnoreCase("")) {
|
||||
return item;
|
||||
}
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
((SkullMeta) meta).setOwner(playerName);
|
||||
return item;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public String[] setToArray(Set<String> set) {
|
||||
String[] array = new String[set.size()];
|
||||
int i = 0;
|
||||
for (String item : set) {
|
||||
array[i] = item;
|
||||
i++;
|
||||
}
|
||||
if (array == null) {
|
||||
return null;
|
||||
} else {
|
||||
return array;
|
||||
}
|
||||
}
|
||||
|
||||
public HashMap<User, Integer> sortByValues(
|
||||
HashMap<User, Integer> unsortMap, final boolean order) {
|
||||
|
||||
List<Entry<User, Integer>> list = new LinkedList<Entry<User, Integer>>(
|
||||
unsortMap.entrySet());
|
||||
|
||||
// Sorting the list based on values
|
||||
Collections.sort(list, new Comparator<Entry<User, Integer>>() {
|
||||
@Override
|
||||
public int compare(Entry<User, Integer> o1, Entry<User, Integer> o2) {
|
||||
if (order) {
|
||||
return o1.getValue().compareTo(o2.getValue());
|
||||
} else {
|
||||
return o2.getValue().compareTo(o1.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Maintaining insertion order with the help of LinkedList
|
||||
HashMap<User, Integer> sortedMap = new LinkedHashMap<User, Integer>();
|
||||
for (Entry<User, Integer> entry : list) {
|
||||
sortedMap.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
return sortedMap;
|
||||
}
|
||||
|
||||
public boolean startsWithIgnoreCase(String str1, String str2) {
|
||||
return str1.toLowerCase().startsWith(str2.toLowerCase());
|
||||
}
|
||||
|
||||
public TextComponent stringToComp(String string) {
|
||||
TextComponent base = new TextComponent("");
|
||||
boolean previousLetter = false;
|
||||
ChatColor currentColor = null;
|
||||
boolean bold = false;
|
||||
boolean italic = false;
|
||||
boolean underline = false;
|
||||
boolean strike = false;
|
||||
boolean magic = false;
|
||||
String currentstring = "";
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
char c = string.charAt(i);
|
||||
if (c == '&') {
|
||||
if (string.charAt(i + 1) == 'l') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
bold = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'k') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
magic = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'm') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
strike = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'n') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
underline = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'o') {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
italic = true;
|
||||
i++;
|
||||
}
|
||||
} else if (string.charAt(i + 1) == 'r') {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentstring = "";
|
||||
currentColor = null;
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else if (ChatColor.getByChar(string.charAt(i + 1)) != null) {
|
||||
if (previousLetter) {
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
bold = false;
|
||||
italic = false;
|
||||
underline = false;
|
||||
strike = false;
|
||||
magic = false;
|
||||
currentColor = ChatColor
|
||||
.getByChar(string.charAt(i + 1));
|
||||
currentstring = "";
|
||||
i++;
|
||||
previousLetter = false;
|
||||
} else {
|
||||
currentColor = ChatColor
|
||||
.getByChar(string.charAt(i + 1));
|
||||
i++;
|
||||
}
|
||||
} else {
|
||||
previousLetter = true;
|
||||
currentstring = currentstring + c;
|
||||
}
|
||||
} else {
|
||||
previousLetter = true;
|
||||
currentstring = currentstring + c;
|
||||
}
|
||||
}
|
||||
TextComponent newTC = new TextComponent(currentstring);
|
||||
if (currentColor != null) {
|
||||
newTC.setColor(currentColor);
|
||||
}
|
||||
newTC.setBold(bold);
|
||||
newTC.setItalic(italic);
|
||||
newTC.setUnderlined(underline);
|
||||
newTC.setStrikethrough(strike);
|
||||
newTC.setObfuscated(magic);
|
||||
base.addExtra(newTC);
|
||||
return base;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +1,75 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteParty;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.DayChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Listeners.MonthChangeEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.UUID;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.ArrayUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.MiscUtils;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigFormat;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigOtherRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.Data;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Data.ServerData;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.UUID;
|
||||
import com.Ben12345rocks.VotingPlugin.Events.VotePartyEvent;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class VoteParty {
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteParty.
|
||||
*/
|
||||
public class VoteParty implements Listener {
|
||||
|
||||
/** The instance. */
|
||||
static VoteParty instance = new VoteParty();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of VoteParty.
|
||||
*
|
||||
* @return single instance of VoteParty
|
||||
*/
|
||||
public static VoteParty getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote party.
|
||||
*/
|
||||
private VoteParty() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote party.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VoteParty(Main plugin) {
|
||||
VoteParty.plugin = plugin;
|
||||
}
|
||||
|
||||
public void addTotal() {
|
||||
public void addTotal(User user) {
|
||||
setTotalVotes(getTotalVotes() + 1);
|
||||
user.setVotePartyVotes(user.getVotePartyVotes() + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the vote player.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void addVotePlayer(User user) {
|
||||
String uuid = user.getUUID();
|
||||
ArrayList<String> voted = getVotedUsers();
|
||||
@@ -46,89 +82,204 @@ public class VoteParty {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check.
|
||||
*/
|
||||
public void check() {
|
||||
if (ConfigOtherRewards.getInstance().getVotePartyEnabled()) {
|
||||
if (getTotalVotes() >= ConfigOtherRewards.getInstance()
|
||||
.getVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes()
|
||||
- ConfigOtherRewards.getInstance().getVotesRequired());
|
||||
giveRewards();
|
||||
if (getTotalVotes() >= getVotesRequired()) {
|
||||
setTotalVotes(getTotalVotes() - getVotesRequired());
|
||||
|
||||
VotePartyEvent event = new VotePartyEvent();
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
giveRewards();
|
||||
MiscUtils.getInstance().broadcast(Config.getInstance().getVotePartyBroadcast());
|
||||
|
||||
if (Config.getInstance().getVotePartyIncreaseVotesRquired() > 0) {
|
||||
ServerData.getInstance().setVotePartyExtraRequired(ServerData.getInstance().getVotePartyExtraRequired()
|
||||
+ Config.getInstance().getVotePartyIncreaseVotesRquired());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Command vote party.
|
||||
*
|
||||
* @param sender
|
||||
* the sender
|
||||
*/
|
||||
public void commandVoteParty(CommandSender sender) {
|
||||
ArrayList<String> msg = ConfigFormat.getInstance()
|
||||
.getCommandsVoteParty();
|
||||
ArrayList<String> lines = new ArrayList<String>();
|
||||
int votesRequired = ConfigOtherRewards.getInstance().getVotesRequired();
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
ArrayList<String> msg = Config.getInstance().getFormatCommandsVoteParty();
|
||||
int votesRequired = Config.getInstance().getVotePartyVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
HashMap<String, String> placeholders = new HashMap<String, String>();
|
||||
placeholders.put("votesrequired", "" + votesRequired);
|
||||
placeholders.put("neededvotes", "" + neededVotes);
|
||||
placeholders.put("votes", "" + votes);
|
||||
msg = ArrayUtils.getInstance().colorize(ArrayUtils.getInstance().replacePlaceHolder(msg, placeholders));
|
||||
sender.sendMessage(ArrayUtils.getInstance().convert(msg));
|
||||
} else {
|
||||
sender.sendMessage(StringUtils.getInstance().colorize("&cVoteParty not enabled"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the needed votes.
|
||||
*
|
||||
* @return the needed votes
|
||||
*/
|
||||
public int getNeededVotes() {
|
||||
int votesRequired = getVotesRequired();
|
||||
int votes = getTotalVotes();
|
||||
int neededVotes = votesRequired - votes;
|
||||
for (String line : msg) {
|
||||
line = line.replace("%VotesRequired%", "" + votesRequired)
|
||||
.replace("%NeededVotes%", "" + neededVotes)
|
||||
.replace("%Votes%", "" + votes);
|
||||
lines.add(Utils.getInstance().colorize(line));
|
||||
}
|
||||
sender.sendMessage(Utils.getInstance().convertArray(lines));
|
||||
}
|
||||
|
||||
public int getOfflineVotePartyVotes(User user) {
|
||||
return Data.getInstance().getData(user)
|
||||
.getInt("VoteParty.OfflineVotes");
|
||||
return neededVotes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the total votes.
|
||||
*
|
||||
* @return the total votes
|
||||
*/
|
||||
public int getTotalVotes() {
|
||||
return ServerData.getInstance().getData().getInt("VoteParty.Total");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the voted users.
|
||||
*
|
||||
* @return the voted users
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArrayList<String> getVotedUsers() {
|
||||
ArrayList<String> list = (ArrayList<String>) ServerData.getInstance()
|
||||
.getData().getList("VoteParty.Voted");
|
||||
ArrayList<String> list = (ArrayList<String>) ServerData.getInstance().getData().getList("VoteParty.Voted");
|
||||
if (list != null) {
|
||||
return list;
|
||||
}
|
||||
return new ArrayList<String>();
|
||||
}
|
||||
|
||||
public void giveReward(User user) {
|
||||
if (Utils.getInstance().isPlayerOnline(user.getPlayerName())) {
|
||||
for (String reward : ConfigOtherRewards.getInstance()
|
||||
.getVotePartyRewards()) {
|
||||
user.giveReward(ConfigRewards.getInstance().getReward(reward));
|
||||
}
|
||||
} else {
|
||||
setOfflineVotePartyVotes(user, getOfflineVotePartyVotes(user) + 1);
|
||||
public int getVotesRequired() {
|
||||
int required = Config.getInstance().getVotePartyVotesRequired();
|
||||
int extra = ServerData.getInstance().getVotePartyExtraRequired();
|
||||
if (extra > 0) {
|
||||
return required + extra;
|
||||
}
|
||||
return required;
|
||||
}
|
||||
|
||||
/**
|
||||
* Give reward.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void giveReward(User user) {
|
||||
/*
|
||||
* if (PlayerUtils.getInstance().isPlayerOnline(user.getPlayerName())) { if
|
||||
* (user.getVotePartyVotes() >= Config.getInstance().getUserVotesRequired()) {
|
||||
* RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
* Config.getInstance().getVotePartyRewardsPath()); } } else {
|
||||
* user.addOfflineOtherReward("VoteParty"); }
|
||||
*/
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVotePartyRewardsPath())
|
||||
.setOnline(user.isOnline())
|
||||
.withPlaceHolder("VotesRequired", "" + Config.getInstance().getVotePartyVotesRequired()).send(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Give rewards.
|
||||
*/
|
||||
public void giveRewards() {
|
||||
if (ConfigOtherRewards.getInstance().getVotePartyGiveAllPlayers()) {
|
||||
for (User user : Data.getInstance().getUsers()) {
|
||||
for (final String cmd : Config.getInstance().getVotePartyCommands()) {
|
||||
Bukkit.getScheduler().runTask(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVotePartyGiveAllPlayers()) {
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
giveReward(user);
|
||||
}
|
||||
} else {
|
||||
for (String uuid : getVotedUsers()) {
|
||||
User user = new User(new UUID(uuid));
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
giveReward(user);
|
||||
}
|
||||
}
|
||||
reset();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDayChange(DayChangeEvent event) {
|
||||
if (Config.getInstance().getVotePartyResetEachDay()) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMonthChange(MonthChangeEvent event) {
|
||||
if (Config.getInstance().getVotePartyResetMontly()) {
|
||||
reset();
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
setVotedUsers(new ArrayList<String>());
|
||||
setTotalVotes(0);
|
||||
for (String uuid : UserManager.getInstance().getAllUUIDs()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(new UUID(uuid));
|
||||
if (user.getVotePartyVotes() != 0) {
|
||||
user.setVotePartyVotes(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void setOfflineVotePartyVotes(User user, int value) {
|
||||
Data.getInstance().getData(user).set("VoteParty.OfflineVotes", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the total votes.
|
||||
*
|
||||
* @param value
|
||||
* the new total votes
|
||||
*/
|
||||
public void setTotalVotes(int value) {
|
||||
ServerData.getInstance().getData().set("VoteParty.Total", value);
|
||||
ServerData.getInstance().saveData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the voted users.
|
||||
*
|
||||
* @param value
|
||||
* the new voted users
|
||||
*/
|
||||
public void setVotedUsers(ArrayList<String> value) {
|
||||
ServerData.getInstance().getData().set("VoteParty.Voted", value);
|
||||
ServerData.getInstance().saveData();
|
||||
}
|
||||
|
||||
public synchronized void vote(User user, boolean realVote) {
|
||||
if (Config.getInstance().getVotePartyEnabled()) {
|
||||
if (Config.getInstance().getVotePartyCountFakeVotes() || realVote) {
|
||||
addTotal(user);
|
||||
addVotePlayer(user);
|
||||
check();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,44 +3,68 @@ package com.Ben12345rocks.VotingPlugin.VoteReminding;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.PlayerUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Utils;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigRewards;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.ConfigVoteReminding;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.Reward;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* The Class VoteReminding.
|
||||
*/
|
||||
public class VoteReminding {
|
||||
|
||||
/** The instance. */
|
||||
static VoteReminding instance = new VoteReminding();
|
||||
|
||||
/** The plugin. */
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
/**
|
||||
* Gets the single instance of VoteReminding.
|
||||
*
|
||||
* @return single instance of VoteReminding
|
||||
*/
|
||||
public static VoteReminding getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*/
|
||||
private VoteReminding() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new vote reminding.
|
||||
*
|
||||
* @param plugin
|
||||
* the plugin
|
||||
*/
|
||||
public VoteReminding(Main plugin) {
|
||||
VoteReminding.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check remind.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void checkRemind(User user) {
|
||||
String playerName = user.getPlayerName();
|
||||
|
||||
if (Utils.getInstance().hasPermission(playerName,
|
||||
"VotingPlugin.Login.RemindVotes")
|
||||
|| Utils.getInstance().hasPermission(playerName,
|
||||
"VotingPlugin.Player")) {
|
||||
if (PlayerUtils.getInstance().hasServerPermission(playerName, "VotingPlugin.Login.RemindVotes")
|
||||
|| PlayerUtils.getInstance().hasServerPermission(playerName, "VotingPlugin.Player")) {
|
||||
if (user.canVoteAll()) {
|
||||
Player player = Bukkit.getPlayer(playerName);
|
||||
if (player != null) {
|
||||
if (!ConfigVoteReminding.getInstance().getRemindOnlyOnce()) {
|
||||
if (!Config.getInstance().getVoteRemindingRemindOnlyOnce()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
} else if (!user.getReminded()) {
|
||||
} else if (!user.isReminded()) {
|
||||
runRemind(user);
|
||||
user.setReminded(true);
|
||||
}
|
||||
@@ -51,42 +75,53 @@ public class VoteReminding {
|
||||
}
|
||||
}
|
||||
|
||||
public void loadRemindChecking() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(
|
||||
plugin,
|
||||
new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getServer()
|
||||
.getOnlinePlayers()) {
|
||||
User user = new User(player);
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
}, 10,
|
||||
ConfigVoteReminding.getInstance().getRemindDelay() * 20 * 60);
|
||||
private void giveReward(User user) {
|
||||
new RewardBuilder(Config.getInstance().getData(), Config.getInstance().getVoteRemindingRewardsPath())
|
||||
.setGiveOffline(false).send(user);
|
||||
}
|
||||
|
||||
public void runRemind(User user) {
|
||||
if (ConfigVoteReminding.getInstance().getEnabled() && user.canVoteAll()) {
|
||||
user.setReminded(true);
|
||||
for (String reward : ConfigVoteReminding.getInstance().getRewards()) {
|
||||
if (!reward.equalsIgnoreCase("")) {
|
||||
if (ConfigRewards.getInstance().getRewardFile(reward)
|
||||
.exists()) {
|
||||
/**
|
||||
* Load remind checking.
|
||||
*/
|
||||
public void loadRemindChecking() {
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(plugin, new Runnable() {
|
||||
|
||||
}
|
||||
Reward rewardFile = ConfigRewards.getInstance().getReward(
|
||||
reward);
|
||||
|
||||
rewardFile.giveReward(user);
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
checkRemind(user);
|
||||
}
|
||||
}
|
||||
}, 10, Config.getInstance().getVoteRemindingRemindDelay() * 20 * 60);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run remind.
|
||||
*
|
||||
* @param user
|
||||
* the user
|
||||
*/
|
||||
public void runRemind(User user) {
|
||||
if (Config.getInstance().getVoteRemindingEnabled() && user.canVoteAll() && user.shouldBeReminded()) {
|
||||
user.setReminded(true);
|
||||
giveReward(user);
|
||||
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void runRemindLogin(User user) {
|
||||
if (Config.getInstance().getVoteRemindingEnabled()
|
||||
&& (!UserManager.getInstance().getAllUUIDs().contains(user.getUUID()) || user.canVoteAll())
|
||||
&& user.shouldBeReminded()) {
|
||||
giveReward(user);
|
||||
if (user.getData().hasData()) {
|
||||
user.setReminded(true);
|
||||
}
|
||||
plugin.debug(user.getPlayerName() + " was reminded!");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.Ben12345rocks.VotingPlugin.VoteShop;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.Ben12345rocks.AdvancedCore.Objects.RewardHandler;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventory.ClickEvent;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Inventory.BInventoryButton;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Item.ItemBuilder;
|
||||
import com.Ben12345rocks.AdvancedCore.Util.Misc.StringUtils;
|
||||
import com.Ben12345rocks.VotingPlugin.Main;
|
||||
import com.Ben12345rocks.VotingPlugin.Commands.GUI.PlayerGUIs;
|
||||
import com.Ben12345rocks.VotingPlugin.Config.Config;
|
||||
import com.Ben12345rocks.VotingPlugin.Objects.User;
|
||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||
|
||||
public class VoteShop {
|
||||
static VoteShop instance = new VoteShop();
|
||||
|
||||
static Main plugin = Main.plugin;
|
||||
|
||||
public static VoteShop getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private VoteShop() {
|
||||
}
|
||||
|
||||
public VoteShop(Main plugin) {
|
||||
VoteShop.plugin = plugin;
|
||||
}
|
||||
|
||||
public void voteShop(Player player) {
|
||||
if (!Config.getInstance().getVoteShopEnabled()) {
|
||||
player.sendMessage(StringUtils.getInstance().colorize("&cVote shop disabled"));
|
||||
return;
|
||||
}
|
||||
BInventory inv = new BInventory(Config.getInstance().getVoteShopName());
|
||||
|
||||
for (String identifier : Config.getInstance().getIdentifiers()) {
|
||||
|
||||
String perm = Config.getInstance().getVoteShopPermission(identifier);
|
||||
boolean hasPerm = false;
|
||||
if (perm.isEmpty()) {
|
||||
hasPerm = true;
|
||||
} else {
|
||||
hasPerm = player.hasPermission(perm);
|
||||
}
|
||||
|
||||
if (hasPerm) {
|
||||
ItemBuilder builder = new ItemBuilder(Config.getInstance().getIdentifierSection(identifier));
|
||||
|
||||
inv.addButton(Config.getInstance().getIdentifierSlot(identifier), new BInventoryButton(builder) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
Player player = event.getWhoClicked();
|
||||
|
||||
User user = UserManager.getInstance().getVotingPluginUser(player);
|
||||
int points = Config.getInstance().getIdentifierCost(identifier);
|
||||
String identifier = Config.getInstance().getIdentifierFromSlot(event.getSlot());
|
||||
if (identifier != null) {
|
||||
if (user.removePoints(points)) {
|
||||
RewardHandler.getInstance().giveReward(user, Config.getInstance().getData(),
|
||||
Config.getInstance().getIdentifierRewardsPath(identifier));
|
||||
user.sendMessage(Config.getInstance().getFormatShopPurchaseMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
} else {
|
||||
user.sendMessage(Config.getInstance().getFormatShopFailedMsg()
|
||||
.replace("%Identifier%", identifier).replace("%Points%", "" + points));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.getInstance().getVoteShopBackButton()) {
|
||||
inv.addButton(new BInventoryButton(PlayerGUIs.getInstance().getBackButton()) {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
PlayerGUIs.getInstance().openVoteGUI(event.getPlayer(),
|
||||
UserManager.getInstance().getVotingPluginUser(player));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
inv.openInventory(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user