mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
949 Commits
v5.5
...
RELEASE-20
Author | SHA1 | Date | |
---|---|---|---|
8262e81e69 | |||
a48596de8a | |||
39b9147484 | |||
5ba81de118 | |||
4b3c31f0e9 | |||
48aabaa878 | |||
3070ff893e | |||
b29a176fa9 | |||
d1569cb3c0 | |||
cb818c0056 | |||
51c807d318 | |||
5422ad6ac7 | |||
773805101b | |||
f474ce99fd | |||
dbb289db66 | |||
f53ba1bd76 | |||
74408b85bf | |||
c26e05c392 | |||
ee39e6f534 | |||
8a58782d99 | |||
cc244fc4f7 | |||
65540b7f3a | |||
f91c21cc81 | |||
6c983f6b97 | |||
1e97273e01 | |||
922a2bcc76 | |||
34269bde09 | |||
922fa4a34f | |||
ccf572315f | |||
733f668145 | |||
2cd107c317 | |||
e4782a3542 | |||
77d65e80f8 | |||
3644ba33a5 | |||
f25d69c5fa | |||
9dbe30aaa7 | |||
1a28facc56 | |||
e82a90c0dc | |||
f8e09665f5 | |||
a5135ef641 | |||
071d19c5e0 | |||
2e7756ed0f | |||
5332dc88cd | |||
631b691518 | |||
982a991fb0 | |||
adbad1ad9b | |||
cbd3caaab3 | |||
49696f0c30 | |||
3a96c853d2 | |||
b5804c7eb1 | |||
f9ecebd5c9 | |||
3a6e7921cc | |||
b7ea1b8b3e | |||
2265783afb | |||
71127c3152 | |||
f53696aa9e | |||
ea60be4c48 | |||
3bd177ea6f | |||
1c0b768e4f | |||
67b0656e61 | |||
b3e1a8b528 | |||
99a5897d44 | |||
9064f4b1f2 | |||
2698cbf46d | |||
d3b4feaec9 | |||
c9adb0c5a8 | |||
cb642eba08 | |||
fa85b8e160 | |||
69a06167a1 | |||
550ff492ee | |||
88914632f5 | |||
47445933f3 | |||
94d6f0a872 | |||
3d67c83ea4 | |||
22161b2e90 | |||
b1f08c3b7f | |||
466745d51f | |||
98921b975f | |||
35d53ece4e | |||
33146fa161 | |||
d7fddc3765 | |||
0db765af43 | |||
f4cb736c17 | |||
3763e0728d | |||
af18299613 | |||
f0d6549eec | |||
3b61ba408f | |||
af710edc88 | |||
459a11e638 | |||
2e41414358 | |||
a3d7fe19a0 | |||
7f4000aff9 | |||
d2884f007b | |||
58b1890183 | |||
8317b1f881 | |||
706e9540ce | |||
ac00d36dc6 | |||
a2133369d2 | |||
48728c9524 | |||
d343bbc3d7 | |||
2c357d1d49 | |||
5246639608 | |||
7fb4a477dc | |||
612499ff0a | |||
edb3dbfdbe | |||
a332ecfbea | |||
7f78549f9d | |||
fd6f8a2d17 | |||
21c84d76d3 | |||
88f53c05b9 | |||
51cc527697 | |||
ae5038ef0f | |||
ec5aa0304e | |||
ebafc1c669 | |||
9f8dafb075 | |||
1eaaf5fcdb | |||
42458084d7 | |||
0cd2886e40 | |||
575568cb05 | |||
26be5d0f44 | |||
7a724c2f13 | |||
9e1aa5d34e | |||
4564ad0449 | |||
1ddeb4b621 | |||
a8665a15d4 | |||
c0f3712c8d | |||
0dd7bc06eb | |||
4d98108a46 | |||
02b2810488 | |||
7e110e8ac6 | |||
6d3f365878 | |||
05bb64ce85 | |||
b05238c51f | |||
7bda4beab0 | |||
97544977b0 | |||
073356be49 | |||
c472c5d5ce | |||
cb401577a4 | |||
9d3165694a | |||
cffb5d9326 | |||
4e8df0938f | |||
511f172d84 | |||
bfa8b2a752 | |||
594b1f5605 | |||
b9ca4f52a2 | |||
d298e923b8 | |||
d0d97c0681 | |||
2540c7c589 | |||
6bc91fc779 | |||
9a54ef66d1 | |||
722ef5f99a | |||
6bf6eeec91 | |||
9df30a9556 | |||
83bb892056 | |||
62ff195ec5 | |||
495fe79d94 | |||
422b41dc8d | |||
f44a1c7e69 | |||
9f8dd91457 | |||
ee45256764 | |||
f6faf3b8bc | |||
8210dafcd3 | |||
4eb8174aa9 | |||
ab309032e5 | |||
0db661600f | |||
d94b184703 | |||
c07473ef6d | |||
d7261627ff | |||
6ac7090fef | |||
611ee619a0 | |||
9d2555cd03 | |||
3c4b4140ce | |||
0f2d596b7a | |||
dcdaecf9b0 | |||
b4b10a3020 | |||
fb259ca9b7 | |||
52a39aa992 | |||
b4e7251e3b | |||
0f1fbf9481 | |||
73eb3226ee | |||
8edc87034f | |||
68bcabe5c2 | |||
ecc92589e9 | |||
bf41d08580 | |||
0fc20b6c56 | |||
9c91166319 | |||
09a220e0a2 | |||
ad9dd42edb | |||
c9f5db0141 | |||
47c30c3283 | |||
6c426644f6 | |||
72bab1e2ed | |||
1726050d65 | |||
0fc5b01b29 | |||
dfd90af017 | |||
5af45a2154 | |||
54df28022f | |||
0326171e85 | |||
d13ecea947 | |||
7ec053c867 | |||
1dcc05e7f5 | |||
c913b7ae74 | |||
951f3c91d9 | |||
b573871c14 | |||
78654eb5e8 | |||
adbe125283 | |||
e6a20e1757 | |||
d71d8edf53 | |||
6af9f240f4 | |||
05745c4210 | |||
98388d0d23 | |||
1da87eeb37 | |||
b656925e4f | |||
d4f44e988c | |||
c39c632a67 | |||
733f002a87 | |||
adcccb10e5 | |||
3fdc0c05bb | |||
2551d184ca | |||
f9eabf27d5 | |||
76ce98621a | |||
bc0495a68f | |||
846154a723 | |||
804614d011 | |||
2c22c6c52d | |||
5ef0f29ffe | |||
11134f4109 | |||
e7992c7eb4 | |||
82e966dfb0 | |||
f457c4cde2 | |||
004a0f3d7c | |||
cf5199f28e | |||
43c68579e5 | |||
127ee7d9f9 | |||
c873fd4abc | |||
fa90e1d239 | |||
b711ed517f | |||
2618d97a3e | |||
1c4647290a | |||
f00f67a844 | |||
850f12103c | |||
7fd77f3cbb | |||
2eb0ab4cb1 | |||
2612aaec31 | |||
6e7ad73152 | |||
af6411b82c | |||
e9ba958a4e | |||
8cff0124ea | |||
1162f10ebb | |||
35965b0b10 | |||
1253732f77 | |||
7ce173e02b | |||
aa20a6e579 | |||
e1bee32163 | |||
4d006ed172 | |||
a29392cab2 | |||
1ecfb0b066 | |||
706229004c | |||
a4adfa9bee | |||
225ade8753 | |||
bf2323bed2 | |||
8cbfde8bbc | |||
a42cb6aff9 | |||
5849947c6b | |||
01fdf766ee | |||
afe755f5c1 | |||
5f97e68e0e | |||
1b5bbd1c05 | |||
2ecfb88604 | |||
8356e831a5 | |||
ab00cb840f | |||
bb2ddf1129 | |||
bba5ec922b | |||
58c21bb1aa | |||
f190bbeac1 | |||
42143c1163 | |||
6453e4efca | |||
9155ac90b5 | |||
1e1367d08f | |||
3f690e2ca1 | |||
abfa3b977c | |||
68adaed997 | |||
ecce62f6b4 | |||
cf9fdc6fe4 | |||
a728ec24d4 | |||
74a71b1843 | |||
4d469cdc0a | |||
4c287ca9b8 | |||
912bc1a1e4 | |||
a598c933ec | |||
936f0b621e | |||
387ea6f71e | |||
e122c4c5fa | |||
180cd81132 | |||
d814853036 | |||
a1ecf88109 | |||
5a6a5ff75d | |||
fdba119d5d | |||
087b8dd7ea | |||
213a43380e | |||
8a31b4c5c0 | |||
3818aab454 | |||
61857dd06f | |||
bd647afe92 | |||
0e12f5e792 | |||
69f17ef2d7 | |||
aebe1acec2 | |||
938b3aa630 | |||
6772333eb4 | |||
0204961834 | |||
2f332a8c42 | |||
e288668c92 | |||
caeda219fa | |||
e50101df43 | |||
ee1b27fa0d | |||
6ca61d9c6c | |||
2d18d461fe | |||
47e6386907 | |||
0a9b95bfce | |||
fedf80b834 | |||
2bdf14f38c | |||
b1062fbb6c | |||
f00f075551 | |||
44ff621d73 | |||
032e54e2d4 | |||
3ca9835257 | |||
f69feed469 | |||
8253f94ac4 | |||
54cb0cfac4 | |||
a4c81f202c | |||
da82b27016 | |||
daf0126f45 | |||
f6d46b6178 | |||
a2d11d4b93 | |||
23caa4e853 | |||
a51f5c9bbf | |||
ee804d52ff | |||
dc490659c1 | |||
0d09c3a550 | |||
4c3f188bb8 | |||
e2ccd14eb3 | |||
af1df22812 | |||
f380898bb7 | |||
464ed85f1b | |||
7dd235b166 | |||
1474a80875 | |||
f45466ee24 | |||
d70b7bbec2 | |||
541c66c3de | |||
77fd4ff66a | |||
d901cbaa81 | |||
538ed7020d | |||
18e6ef16be | |||
a335a2acf7 | |||
2eb6cc0036 | |||
5322d8ab64 | |||
dccc315869 | |||
7657ae1928 | |||
dcaf1ec11a | |||
33aca2a482 | |||
0582c2e5be | |||
159eda73a1 | |||
101987cc17 | |||
6874b2ce13 | |||
3be0ffba4e | |||
da2d25252b | |||
c8a4382a7b | |||
3f89f3f48e | |||
871acc2eeb | |||
a9c9979b1c | |||
fc3fe871b3 | |||
e99aaa2eb4 | |||
62529a6171 | |||
0caf972248 | |||
a37364d07e | |||
4ac9844534 | |||
939e98b759 | |||
d99f3e657b | |||
92bbb62379 | |||
e4a0943af2 | |||
36bd8c0fad | |||
d77f59435b | |||
a08fd2afb6 | |||
6fd075fe96 | |||
f57fc56f4a | |||
a6ca6b122c | |||
064e73f58b | |||
32138b2e59 | |||
e1c3bad4d0 | |||
4e78027f0c | |||
721f4f9fc3 | |||
24ad2611a9 | |||
c238f251f2 | |||
02848e3439 | |||
9550f54e2b | |||
39dade78e3 | |||
5b6d8b01a4 | |||
96bc83cead | |||
be700a90ce | |||
6d1fce1716 | |||
d3665f31fe | |||
4188cb80fa | |||
62fe72d99b | |||
f4749559d2 | |||
ed815794ed | |||
0c12a19d1d | |||
96d47e8e0c | |||
3027e2a18c | |||
06025b2e69 | |||
da7e8f64aa | |||
17b051e2a7 | |||
77a05f22a8 | |||
5c3ef1f107 | |||
53c5991971 | |||
ff760a6c11 | |||
63069ff9ec | |||
5e63b71861 | |||
b72782de4f | |||
de9556c550 | |||
6590504545 | |||
8d1e8dcf05 | |||
07b5076717 | |||
6fb9507a4c | |||
879a524bb4 | |||
c60b451ce7 | |||
f85f3e32ea | |||
57b3351047 | |||
dd10eb3f5e | |||
a498104777 | |||
4e577f97fa | |||
8c7bf365a0 | |||
eedb7a5375 | |||
d047cfc8ff | |||
9ff5da8d8f | |||
ac615f54f7 | |||
21af722e23 | |||
b1196fcf00 | |||
d170f6d323 | |||
9dd0298f56 | |||
bdf4ca84e0 | |||
caaa067096 | |||
7258d7f1bf | |||
8a504bff07 | |||
c00e64f736 | |||
9e73db0f24 | |||
951c061d77 | |||
579d3e0719 | |||
9777733d04 | |||
05e118dcb4 | |||
7a0d6f49f4 | |||
19f1b7f6bd | |||
b12afbdc1f | |||
49e77d4f93 | |||
eb9107bedf | |||
951c699ed0 | |||
9e676143b8 | |||
6895e46375 | |||
c8b20bc255 | |||
1cf46c7337 | |||
f240a15af3 | |||
6073712fdf | |||
407b63e48b | |||
be562fe722 | |||
928ab41d7f | |||
d11d55b218 | |||
debb95fb4c | |||
b9f7ab3ec3 | |||
2cdf1e66a6 | |||
20c2c4c96e | |||
d5238150d0 | |||
64a4e70c41 | |||
0c2f0a714c | |||
4c67553bdd | |||
ffab5e3c12 | |||
f7556a4861 | |||
385fc77771 | |||
b852ea1822 | |||
4a5a3a1a2d | |||
37762e5470 | |||
85d90090c8 | |||
09930c2d9a | |||
7ae1ab035a | |||
2bd1787663 | |||
765b7dcc4b | |||
091381a076 | |||
27dfd71b2e | |||
16e06bd932 | |||
a33c310757 | |||
df21bdfa7e | |||
d7e2c0da42 | |||
a7529b41fb | |||
c4fce3f0f9 | |||
27f5f18962 | |||
dca5e30291 | |||
09a435053e | |||
14309275fb | |||
2375e92d90 | |||
97672c2fff | |||
5837b05a35 | |||
b3b68ebd13 | |||
2dbbb5c262 | |||
e45655edbb | |||
9713fcabd6 | |||
dc10c40578 | |||
db3c190b2b | |||
2725857364 | |||
9f291f675c | |||
561c192c27 | |||
086dec28ac | |||
b03870c0aa | |||
f5c08cd28b | |||
2a87271642 | |||
3b57aec0e8 | |||
efac65bc76 | |||
9c8fe6c590 | |||
9f52cdf753 | |||
216234ea01 | |||
881dead392 | |||
ff2bca26aa | |||
89ad934aa6 | |||
d0a195647c | |||
eb05b05042 | |||
b9c1970d20 | |||
9eca9ac5b2 | |||
5b577fae07 | |||
452a8755c2 | |||
2fb8f224e7 | |||
b6a2c8e021 | |||
f0a25fde0c | |||
4324497831 | |||
14c53b7370 | |||
0396b8ad86 | |||
8ee7486afc | |||
694d9614c5 | |||
150e25072a | |||
7d990ae2c0 | |||
0dd5a26efa | |||
5c097c83cb | |||
a85dd014a0 | |||
342df43f85 | |||
d4be858c46 | |||
ec9a6e0d5b | |||
9161016f73 | |||
bdd22f8d75 | |||
ce103ffd50 | |||
85c35f25a3 | |||
c29b312101 | |||
a4ead85701 | |||
46273b3301 | |||
d6b74a76bb | |||
6f66957b17 | |||
17347c23a5 | |||
718748f1a2 | |||
96d1c53ede | |||
1293a8aa1e | |||
96424694ee | |||
0367d9fd3a | |||
3b666f1fde | |||
ec51cb7408 | |||
4023394562 | |||
5d312a12d4 | |||
b88cdf1250 | |||
ebec598120 | |||
aa060ea4d8 | |||
fc3eef4d90 | |||
44ac012165 | |||
500d0e1044 | |||
400a90b385 | |||
b8a741aa58 | |||
a3929ec07e | |||
8225daf6f1 | |||
8dce71eca1 | |||
a2243abf2d | |||
009b983c9a | |||
1b3876cffa | |||
ed48ce3a8f | |||
830daab8f4 | |||
9688827a39 | |||
3464a33678 | |||
5754d70d05 | |||
fbf2972006 | |||
aa2836b29a | |||
260368585e | |||
323fd1a031 | |||
c7b0f77910 | |||
7fb6a2f087 | |||
e32c2eed15 | |||
7afa80c89f | |||
a3cccc7ac0 | |||
bc37ed5341 | |||
0a5ce5b9cc | |||
a4e23dc03f | |||
7a394e52e4 | |||
9352a48650 | |||
a849e01ce5 | |||
fd725ca6c5 | |||
0703ea685e | |||
1ba468cbfc | |||
91dc89013c | |||
7cdeac451b | |||
5b8cf2798e | |||
98158e0f27 | |||
c0ac0365eb | |||
0c60cbc739 | |||
402a6be5ad | |||
9d131f0f24 | |||
b9606fa0e3 | |||
d71f5452ad | |||
eb9759f2d8 | |||
dec35f76e4 | |||
97edce0a67 | |||
361aa4ee04 | |||
5c0f77c7c5 | |||
210b0f8b43 | |||
585fdb7992 | |||
6d05e9b924 | |||
fb314170c1 | |||
218d720b06 | |||
7bf97a03c4 | |||
de496970d9 | |||
c8ec171b11 | |||
caf126f543 | |||
a717cce3b5 | |||
ce32490b4d | |||
5d882d9052 | |||
7dfd6c0b8b | |||
fa5c774f45 | |||
c356ecd168 | |||
f8ce64d6c3 | |||
39d5b610a1 | |||
50643eb9ff | |||
687166e0a4 | |||
98ead06355 | |||
cbc3795ef2 | |||
b9d608222e | |||
777a66f8da | |||
6441deceab | |||
1fedb1fad3 | |||
8b1cef3b83 | |||
81ef3d624a | |||
b0c0f17043 | |||
fb3cdf3603 | |||
950c975e8f | |||
79c8ea301d | |||
7a11c9062d | |||
2037775276 | |||
4a3ce64412 | |||
681695150a | |||
e98682a1af | |||
92534640d4 | |||
695ccd0e71 | |||
0be2aa718f | |||
b3b9c2ef43 | |||
293ea04c56 | |||
aae1f524ea | |||
7871acc215 | |||
153b87c3b3 | |||
932fa467ba | |||
82804fcac2 | |||
8ed35aba2b | |||
4898bcf7b5 | |||
495c91f5bb | |||
42199f9923 | |||
03a6f18d18 | |||
aff12edb03 | |||
c0a7ee1bb6 | |||
8c0db481ae | |||
6084e7cb63 | |||
e40138dee6 | |||
28576a9e8b | |||
c1d4e126a3 | |||
6cd995ff52 | |||
495133da1a | |||
de0d6853b7 | |||
5cdbae0166 | |||
a537183545 | |||
2c19ce5c65 | |||
609053e13f | |||
a3837a0e06 | |||
0adee3582b | |||
08bfd73eec | |||
9a7cc52e03 | |||
11984bc46f | |||
8ac5bc827a | |||
366287eb24 | |||
43c2df58c7 | |||
d0acfcf674 | |||
88ccd8edfd | |||
7f9e2af9a6 | |||
f9269f1fe4 | |||
a5359ec580 | |||
e3a6f5127f | |||
e1e046b16b | |||
7d93050ff9 | |||
fadcb9ad5d | |||
49f7c6e8c3 | |||
9bcdb2bcdc | |||
ca4670ed89 | |||
adf71cb020 | |||
6e84fdad23 | |||
2ecfd9610f | |||
bb33778fc9 | |||
d4d1000c16 | |||
5a96204f1b | |||
3bd72dacda | |||
a4c8dad865 | |||
82e7a3b659 | |||
586fa98c32 | |||
a8f95bcb19 | |||
82d92565e7 | |||
533e4fe369 | |||
f8304aecd7 | |||
ac6e58ff9e | |||
4be2a1e05b | |||
59831ef1f3 | |||
54e6e2f9b1 | |||
d203772a9a | |||
55522e8191 | |||
ac3d0fca88 | |||
eb6514332e | |||
098d3e4cf1 | |||
81eb333b6a | |||
3057421d6d | |||
9cb96e81ac | |||
d67189e170 | |||
451ef8f009 | |||
7af53448be | |||
2072c89f77 | |||
43b266f17d | |||
c61f7e78fd | |||
14ab1e95b5 | |||
44fe8f6f94 | |||
1c487a6a60 | |||
6f4cc8d4b5 | |||
f98f6990ea | |||
4c81c94702 | |||
aaa495cf41 | |||
72322f2e56 | |||
04fee7d5c1 | |||
d38ddac311 | |||
d65f584707 | |||
ff42713f92 | |||
5047363f83 | |||
34a0dae305 | |||
ebc07f6259 | |||
6a7a6e74e3 | |||
1e36b484ac | |||
efae9e314f | |||
ea946fe14f | |||
fc08761e70 | |||
3f68677d99 | |||
f4007a7c9d | |||
f3a655d40d | |||
6b3a765c90 | |||
7e8a519c87 | |||
388e1fd52d | |||
cdb28afba6 | |||
24575aba88 | |||
090c445aa9 | |||
c936759b6c | |||
36fc1a00b6 | |||
7b9920dbc4 | |||
b0daf2066a | |||
ed5d18c0df | |||
04a7b633a4 | |||
7a810519f3 | |||
53038ca3b2 | |||
e77d92407c | |||
da80f1b69e | |||
4407e9e6ec | |||
e4c9ea656e | |||
63570d61d6 | |||
257a2eec33 | |||
78b73b3b63 | |||
d74846cde6 | |||
3f4d34d172 | |||
f5b5fcd5ef | |||
f42e047723 | |||
e79145ee54 | |||
6dbc99690a | |||
8628e88e3a | |||
51e1191816 | |||
e294ef8312 | |||
541abb1ba8 | |||
306c8bc8b9 | |||
9f006325b4 | |||
aab4f55b7d | |||
00f94e47f1 | |||
44b7307e4d | |||
54df0e08f5 | |||
4003db6dd9 | |||
f4f25c1590 | |||
328225fe6e | |||
087e4a0d9c | |||
2ecde80b5f | |||
075299dbd9 | |||
30d5a1d888 | |||
b6746acb44 | |||
560353e7cf | |||
86cf9dc344 | |||
877c174e2d | |||
642725252b | |||
880b78e528 | |||
7224319fae | |||
ca8758cbb1 | |||
81df3103b6 | |||
b73d1df350 | |||
299b31a75b | |||
8832d5c870 | |||
abe3b68480 | |||
5c50f8f27d | |||
4561641d2b | |||
4555a7e3f2 | |||
c826afe399 | |||
ae57573eeb | |||
073a618035 | |||
e1b514ca85 | |||
3f942613d7 | |||
bb4f8d1fc6 | |||
5401cc5dc7 | |||
1a7c14ad3e | |||
25bf79bdb1 | |||
12a4f4da84 | |||
a0b29c1d01 | |||
76bb2d08ac | |||
891e5c2f12 | |||
4de1fe454d | |||
80e39d3db1 | |||
e25e785c26 | |||
0ae835aa04 | |||
05abebea65 | |||
c04e944466 | |||
3ee80e0f70 | |||
27f7276698 | |||
9ecfe703cb | |||
ab660a7ca7 | |||
2353c728c1 | |||
106e457fa7 | |||
582acdb176 | |||
05f94920d9 | |||
ee04a456a1 | |||
8e8daa457b | |||
95e67f84ef | |||
6f2d5aa08d | |||
417a0c39dd | |||
4ad7fd874f | |||
aef85b2120 | |||
37c65a85d4 | |||
d93a2a7e7d | |||
db414164dc | |||
30085a7a52 | |||
7593fbda9e | |||
fc05003354 | |||
113350b228 | |||
a1f64ef912 | |||
e4ee3066bc | |||
2bf78bcccf | |||
8c93da758a | |||
75e50582e9 | |||
d92f661f12 | |||
22d40bd0e9 | |||
3f75712732 | |||
fc31babff3 | |||
588a2f1eba | |||
4f276ec78e | |||
2ce1a3d1d3 | |||
cef2d8cec4 | |||
12b096b0ad | |||
cb1c67e568 | |||
5a41632654 | |||
cde24b748a | |||
0e63857ae0 | |||
b8e5de2080 | |||
62aa46f856 | |||
d33f661d55 | |||
c1f0d81fcc | |||
c4124de781 | |||
30fd3ea6a1 | |||
6435078703 | |||
03b22ac326 | |||
a1418eb516 | |||
7a08152c14 | |||
bf6ef152d9 | |||
114567a302 | |||
067180d2cf | |||
4973318249 | |||
ceed8bd303 | |||
a7d386e6be | |||
6e622ad2f3 | |||
2ca57c9b39 | |||
eea17a24bc | |||
7d6370da23 | |||
cdb385dd20 | |||
cb108e0c13 | |||
f9e8a4c8ba | |||
c836838f51 | |||
6ca7f6ba24 | |||
c7c567a14f | |||
38918afe67 | |||
ba2b636e04 | |||
da1bec6cc0 | |||
4e432eeeea | |||
f6bf485c0d | |||
06d40927b0 | |||
58872e2c32 | |||
00450e5732 | |||
98f4af7fab | |||
7b7f09e457 | |||
4a297a237c | |||
d12a121300 | |||
c87e1b3d64 | |||
f6ee9271c6 | |||
4328a13eaf | |||
ed9fe87e44 | |||
8b4a91b2e6 | |||
c1a7b1c141 | |||
78349ba49e | |||
d74eeec113 | |||
c333a6ee39 | |||
3fd7147fc2 | |||
adfd55b419 | |||
2a88e05021 | |||
8a60ae2235 | |||
556dfa7233 | |||
19ed60d407 | |||
aac791d768 | |||
1357ac7e09 | |||
5421de0c2f | |||
9d7e0cdefc | |||
e4d1d6ff9e | |||
3eec04ec1c | |||
357eddf51a | |||
baf5fd42f6 | |||
9d71a7f4ae | |||
9dad7c6d05 | |||
35b4990f0c | |||
b4b1128905 | |||
4d19d44d19 | |||
eb58419a3a | |||
4ddcc3b8d7 | |||
43ee17807a | |||
d1cc694742 | |||
abbadb55ee | |||
a2a4a8a0b8 | |||
c49abd1f4a | |||
dd5e256c84 | |||
321d9f97e0 | |||
721c2dc18e | |||
a523cc313c |
23
.github/dependabot.yml
vendored
Normal file
23
.github/dependabot.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
|
||||||
|
# Maintain Maven Updates
|
||||||
|
- package-ecosystem: "maven" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
target-branch: "development"
|
||||||
|
open-pull-requests-limit: 50
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
||||||
|
|
||||||
|
# Maintain dependencies for GitHub Actions
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
target-branch: "development"
|
||||||
|
open-pull-requests-limit: 50
|
||||||
|
schedule:
|
||||||
|
interval: "daily"
|
46
.github/workflows/codacy-analysis.yml
vendored
Normal file
46
.github/workflows/codacy-analysis.yml
vendored
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# This workflow checks out code, performs a Codacy security scan
|
||||||
|
# and integrates the results with the
|
||||||
|
# GitHub Advanced Security code scanning feature. For more information on
|
||||||
|
# the Codacy security scan action usage and parameters, see
|
||||||
|
# https://github.com/codacy/codacy-analysis-cli-action.
|
||||||
|
# For more information on Codacy Analysis CLI in general, see
|
||||||
|
# https://github.com/codacy/codacy-analysis-cli.
|
||||||
|
|
||||||
|
name: Codacy Security Scan
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ development ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ development ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
codacy-security-scan:
|
||||||
|
name: Codacy Security Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
# Checkout the repository to the GitHub Actions runner
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
|
||||||
|
- name: Run Codacy Analysis CLI
|
||||||
|
uses: codacy/codacy-analysis-cli-action@v4.2.0
|
||||||
|
with:
|
||||||
|
# Check https://github.com/codacy/codacy-analysis-cli#project-token to get your project token from your Codacy repository
|
||||||
|
# You can also omit the token and run the tools that support default configurations
|
||||||
|
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
|
||||||
|
verbose: true
|
||||||
|
output: results.sarif
|
||||||
|
format: sarif
|
||||||
|
# Adjust severity of non-security issues
|
||||||
|
gh-code-scanning-compat: true
|
||||||
|
# Force 0 exit code to allow SARIF file generation
|
||||||
|
# This will handover control about PR rejection to the GitHub side
|
||||||
|
max-allowed-issues: 2147483647
|
||||||
|
|
||||||
|
# Upload the SARIF file generated in the previous step
|
||||||
|
- name: Upload SARIF results file
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: results.sarif
|
74
.github/workflows/codeql-analysis.yml
vendored
Normal file
74
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ development ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ development ]
|
||||||
|
schedule:
|
||||||
|
- cron: '20 18 * * 1'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'java' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||||
|
# Learn more:
|
||||||
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Setup Java JDK
|
||||||
|
uses: actions/setup-java@v3.9.0
|
||||||
|
with:
|
||||||
|
# The Java version to make available on the path. Takes a whole or semver Java version, or 1.x syntax (e.g. 1.8 => Java 8.x). Early access versions can be specified in the form of e.g. 14-ea, 14.0.0-ea, or 14.0.0-ea.28
|
||||||
|
java-version: 17
|
||||||
|
distribution: 'adopt'
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
21
.github/workflows/java17-maven.yml
vendored
Normal file
21
.github/workflows/java17-maven.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: Java17-Maven-Build
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-java-17:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
# Checkout the code
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
# Java 16 Builds
|
||||||
|
- name: Set up JDK 17
|
||||||
|
uses: actions/setup-java@v3.9.0
|
||||||
|
with:
|
||||||
|
java-version: 17
|
||||||
|
distribution: 'adopt'
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B package --file pom.xml
|
17
.github/workflows/maven.yml
vendored
17
.github/workflows/maven.yml
vendored
@ -1,17 +0,0 @@
|
|||||||
name: Java CI
|
|
||||||
|
|
||||||
on: [push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
- name: Set up JDK 1.8
|
|
||||||
uses: actions/setup-java@v1
|
|
||||||
with:
|
|
||||||
java-version: 1.8
|
|
||||||
- name: Build with Maven
|
|
||||||
run: mvn -B package --file pom.xml
|
|
13
.gitignore
vendored
13
.gitignore
vendored
@ -19,11 +19,17 @@ manifest.mf
|
|||||||
# IntelliJ excludes
|
# IntelliJ excludes
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
/.idea
|
/.idea/modules.xml
|
||||||
|
/.idea/discord.xml
|
||||||
|
/.idea/jarRepositories.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/uiDesigner.xml
|
||||||
|
/.idea/libraries
|
||||||
|
/.idea/
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
# Maven excludes
|
# Maven excludes
|
||||||
/target
|
target/
|
||||||
|
|
||||||
# OS generated files
|
# OS generated files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@ -32,5 +38,4 @@ manifest.mf
|
|||||||
.Trashes
|
.Trashes
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
.idea/inspectionProfiles/Project_Default.xml
|
||||||
TotalFreedomMod\.iml
|
|
||||||
|
8
.idea/artifacts/TotalFreedomMod_jar.xml
generated
8
.idea/artifacts/TotalFreedomMod_jar.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<component name="ArtifactManager">
|
|
||||||
<artifact type="jar" build-on-make="true" name="TotalFreedomMod:jar">
|
|
||||||
<output-path>$PROJECT_DIR$/target</output-path>
|
|
||||||
<root id="archive" name="TotalFreedomMod.jar">
|
|
||||||
<element id="module-output" name="TotalFreedomMod" />
|
|
||||||
</root>
|
|
||||||
</artifact>
|
|
||||||
</component>
|
|
28
.idea/codeStyles/Project.xml
generated
28
.idea/codeStyles/Project.xml
generated
@ -1,28 +0,0 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<code_scheme name="Project" version="173">
|
|
||||||
<JavaCodeStyleSettings>
|
|
||||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
|
||||||
<option name="IMPORT_LAYOUT_TABLE">
|
|
||||||
<value>
|
|
||||||
<package name="" withSubpackages="true" static="false" />
|
|
||||||
<package name="" withSubpackages="true" static="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
</JavaCodeStyleSettings>
|
|
||||||
<codeStyleSettings language="JAVA">
|
|
||||||
<option name="BRACE_STYLE" value="2" />
|
|
||||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
|
||||||
<option name="METHOD_BRACE_STYLE" value="2" />
|
|
||||||
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
|
||||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
|
||||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
|
||||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
|
||||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
|
||||||
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
|
||||||
<option name="IF_BRACE_FORCE" value="3" />
|
|
||||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
|
||||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
|
||||||
<option name="FOR_BRACE_FORCE" value="3" />
|
|
||||||
</codeStyleSettings>
|
|
||||||
</code_scheme>
|
|
||||||
</component>
|
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
5
.idea/codeStyles/codeStyleConfig.xml
generated
@ -1,5 +0,0 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<state>
|
|
||||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
|
||||||
</state>
|
|
||||||
</component>
|
|
18
.idea/compiler.xml
generated
18
.idea/compiler.xml
generated
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CompilerConfiguration">
|
|
||||||
<annotationProcessing>
|
|
||||||
<profile default="true" name="Default" enabled="true" />
|
|
||||||
<profile name="Maven default annotation processors profile" enabled="true">
|
|
||||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
|
||||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
|
||||||
<outputRelativeToContentRoot value="true" />
|
|
||||||
<module name="TotalFreedomMod" />
|
|
||||||
</profile>
|
|
||||||
</annotationProcessing>
|
|
||||||
<bytecodeTargetLevel>
|
|
||||||
<module name="totalfreedom" target="1.8" />
|
|
||||||
<module name="TotalFreedomMod" target="1.8" />
|
|
||||||
</bytecodeTargetLevel>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
8
.idea/encodings.xml
generated
8
.idea/encodings.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Encoding">
|
|
||||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/TotalFreedomMod.iml" filepath="$PROJECT_DIR$/TotalFreedomMod.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -1 +0,0 @@
|
|||||||
language: java
|
|
@ -1,3 +1,3 @@
|
|||||||
# Contributing to TotalFreedomMod #
|
# Contributing to TotalFreedomMod
|
||||||
|
|
||||||
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).
|
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).
|
||||||
|
12
Jenkinsfile
vendored
12
Jenkinsfile
vendored
@ -1,12 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent any
|
|
||||||
|
|
||||||
stages {
|
|
||||||
stage('Build') {
|
|
||||||
steps {
|
|
||||||
mvn -B package --file pom.xml
|
|
||||||
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
19
LICENSE.md
19
LICENSE.md
@ -1,4 +1,5 @@
|
|||||||
# TotalFreedom General License #
|
# TotalFreedom General License
|
||||||
|
|
||||||
_Version 2.0, 27th February 2015_
|
_Version 2.0, 27th February 2015_
|
||||||
|
|
||||||
Copyright (c) 2011 Steven Lawson
|
Copyright (c) 2011 Steven Lawson
|
||||||
@ -7,7 +8,8 @@ Copyright (c) 2012 Jerom van der Sar
|
|||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
##### 1. Definitions #####
|
##### 1. Definitions
|
||||||
|
|
||||||
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
|
||||||
|
|
||||||
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
|
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
|
||||||
@ -30,12 +32,13 @@ All rights reserved.
|
|||||||
|
|
||||||
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another.
|
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another.
|
||||||
|
|
||||||
##### 2. Grant of Copyright License #####
|
##### 2. Grant of Copyright License
|
||||||
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met:
|
|
||||||
|
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met:
|
||||||
|
|
||||||
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor.
|
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor.
|
||||||
|
|
||||||
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
|
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
|
||||||
|
|
||||||
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
|
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
|
||||||
|
|
||||||
@ -47,8 +50,10 @@ All rights reserved.
|
|||||||
|
|
||||||
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
|
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
|
||||||
|
|
||||||
##### 3. Submission of Contributions #####
|
##### 3. Submission of Contributions
|
||||||
|
|
||||||
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||||
|
|
||||||
##### 4. Disclaimer of Warranty #####
|
##### 4. Disclaimer of Warranty
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
13
README.md
13
README.md
@ -1,14 +1,17 @@
|
|||||||
# TotalFreedomMod [](https://travis-ci.org/TFPatches/TotalFreedomMod) [](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
# TotalFreedomMod [](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/java17-maven.yml) [](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AtlasMediaGroup/TotalFreedomMod&utm_campaign=Badge_Grade) [](https://github.com/AtlasMediaGroup/TotalFreedomMod/actions/workflows/codeql-analysis.yml)
|
||||||
|
|
||||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](https://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||||
|
|
||||||
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
||||||
|
|
||||||
### Contributing ###
|
### Contributing
|
||||||
|
|
||||||
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod.
|
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod.
|
||||||
|
|
||||||
For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
||||||
|
|
||||||
### Compiling ###
|
For information on our security policy and reporting an issue, please see [SECURITY.md](SECURITY.md)
|
||||||
|
|
||||||
You need Maven to build. You'd also need to set the JDK version to Java 8 as that is the current standard as of now.
|
### Compiling
|
||||||
|
|
||||||
|
You need Maven to build. You'd also need to set the JDK version to Java 11 as that is the current standard as of now.
|
||||||
|
42
SECURITY.md
Normal file
42
SECURITY.md
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
We currently support the code running on the "main" branch and "development" branch of this repository. This is supported in addition to those formal releases, but note anything not yet released should be treated as in-development.
|
||||||
|
|
||||||
|
In terms of plugin releases, our support matrix is as follows:
|
||||||
|
|
||||||
|
### Actively Supported
|
||||||
|
These versions are currently actively supported by our team, and you should expect security patches where appropriate for these versions.
|
||||||
|
|
||||||
|
| Version | Supported | Support End: |
|
||||||
|
| ------------------- | ---------- | ------------------------------ |
|
||||||
|
| 2022.02 | ✅ | No Earlier than May 2022 |
|
||||||
|
|
||||||
|
### Legacy Supported
|
||||||
|
These versions are no longer under active development, however we will look to release critical secuirty patches where appropriate.
|
||||||
|
|
||||||
|
| Version | Supported | Support End: |
|
||||||
|
| ------------------- | ---------- | ------------ |
|
||||||
|
| 2021.09 | ⚠️ | April 2022 |
|
||||||
|
|
||||||
|
|
||||||
|
### No Longer Supported
|
||||||
|
These versions are no longer supported at all. It is strongly advised to update if you are running any of these versions.
|
||||||
|
|
||||||
|
| Version | Supported | Support Ended: |
|
||||||
|
| ------------------- | ------------------ | ------------------- |
|
||||||
|
| 2021.06 | :x: | October 2021 |
|
||||||
|
| 2021.05 | :x: | September 2021 |
|
||||||
|
| 2021.04 | :x: | July 2021 |
|
||||||
|
| 2021.02 | :x: | 6 June 2021 |
|
||||||
|
| 2020.11 | :x: | 3 May 2021 |
|
||||||
|
| 6.0.x (Pre-Release) | :x: | December 2020 |
|
||||||
|
| < 2020.11 | :x: | December 2020 |
|
||||||
|
| < 5.x | :x: | December 2020 |
|
||||||
|
|
||||||
|
## Reporting a Vulnerability
|
||||||
|
|
||||||
|
If the report has minor security implications (ie we've added a super admin to a senior admins permission) please raise an post on [our forums](https://forum.totalfreedom.me/) in the first instance. If you do not have a forum account and do not wish to sign up, please e-mail us using the e-mail in the next sentence.
|
||||||
|
|
||||||
|
For security vulnerabilities that are more severe and that may pose a more significant threat to the servers running this plugin, please e-mail os-security-reports [ AT ] atlas-media.co.uk - You can expect an automated response immediately to acknowledge receipt of your e-mail, and one of our team will aim to respond within 72 hours and will work with you on the best way to address your concerns.
|
@ -1,121 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="minecraft" name="Minecraft">
|
|
||||||
<configuration>
|
|
||||||
<autoDetectTypes>
|
|
||||||
<platformType>PAPER</platformType>
|
|
||||||
</autoDetectTypes>
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
|
||||||
<output url="file://$MODULE_DIR$/target/classes" />
|
|
||||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.6" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.13.2-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.15.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-LibsDisguises:11aea9b3cd" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldguard-bukkit:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:NMSProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:UpdatedMetaProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R1Provider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R2Provider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:LegacyProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:ReflectionProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:FlattenedProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:4.0.0_39" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:16.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.neovisionaries:nv-websocket-client:2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-api:1.0.4" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.4.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-natives:1.0.4" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.16.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: rhino:js:1.7R2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:7.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.vexsoftware:votifier:v1.9" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ConnorLinfoot:ActionBarAPI:5b2d642d3d" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
@ -2,20 +2,16 @@
|
|||||||
<!DOCTYPE module PUBLIC
|
<!DOCTYPE module PUBLIC
|
||||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
<module name="Checker">
|
<module name="Checker">
|
||||||
<property name="charset" value="UTF-8"/>
|
<property name="charset" value="UTF-8"/>
|
||||||
<property name="severity" value="warning"/>
|
<property name="severity" value="warning"/>
|
||||||
<property name="fileExtensions" value="java, properties, xml"/>
|
<property name="fileExtensions" value="java, properties, xml"/>
|
||||||
|
|
||||||
<module name="SuppressionFilter">
|
<module name="SuppressionFilter">
|
||||||
<property name="file" value="supressions.xml"/>
|
<property name="file" value="supressions.xml"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<module name="FileTabCharacter">
|
<module name="FileTabCharacter">
|
||||||
<property name="eachLine" value="true"/>
|
<property name="eachLine" value="true"/>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
<module name="TreeWalker">
|
<module name="TreeWalker">
|
||||||
<module name="OuterTypeFilename"/>
|
<module name="OuterTypeFilename"/>
|
||||||
<module name="IllegalTokenText">
|
<module name="IllegalTokenText">
|
||||||
@ -91,7 +87,7 @@
|
|||||||
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="ClassTypeParameterName">
|
<module name="ClassTypeParameterName">
|
||||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
<property name="format" value="(^[A-Z][a-zA-Z0-9]*$)|([A-Z][a-zA-Z0-9]*[_][a-zA-Z0-9]*$)"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
</module>
|
</module>
|
||||||
@ -112,7 +108,8 @@
|
|||||||
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="OverloadMethodsDeclarationOrder"/>
|
<module name="OverloadMethodsDeclarationOrder"/>
|
||||||
<module name="CustomImportOrder"/><!-- http://checkstyle.sourceforge.net/config_imports.html -->
|
<module name="CustomImportOrder"/>
|
||||||
|
<!-- http://checkstyle.sourceforge.net/config_imports.html -->
|
||||||
<module name="MethodParamPad"/>
|
<module name="MethodParamPad"/>
|
||||||
<module name="OperatorWrap">
|
<module name="OperatorWrap">
|
||||||
<property name="option" value="NL"/>
|
<property name="option" value="NL"/>
|
||||||
|
250
commons/pom.xml
Normal file
250
commons/pom.xml
Normal file
@ -0,0 +1,250 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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>
|
||||||
|
<parent>
|
||||||
|
<groupId>me.totalfreedom</groupId>
|
||||||
|
<artifactId>TotalFreedomMod</artifactId>
|
||||||
|
<version>2023.03</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>commons</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.11.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
<version>1.0.7</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.12.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.luckperms</groupId>
|
||||||
|
<artifactId>api</artifactId>
|
||||||
|
<version>5.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
<version>3.0.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.reflections</groupId>
|
||||||
|
<artifactId>reflections</artifactId>
|
||||||
|
<version>0.10.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.sisu</groupId>
|
||||||
|
<artifactId>org.eclipse.sisu.inject</artifactId>
|
||||||
|
<version>0.3.5</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- Filter resources for build.properties -->
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<!-- Compiler -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.10.1</version>
|
||||||
|
<configuration>
|
||||||
|
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||||
|
<compilerVersion>17</compilerVersion>
|
||||||
|
<source>17</source>
|
||||||
|
<target>17</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Git describe -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>pl.project13.maven</groupId>
|
||||||
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
<version>4.9.10</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>get-the-git-infos</id>
|
||||||
|
<goals>
|
||||||
|
<goal>revision</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>validate-the-git-infos</id>
|
||||||
|
<goals>
|
||||||
|
<goal>validateRevision</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>package</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
|
||||||
|
<prefix>git</prefix>
|
||||||
|
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
|
||||||
|
<verbose>false</verbose>
|
||||||
|
<format>properties</format>
|
||||||
|
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||||
|
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
|
||||||
|
<includeOnlyProperties>
|
||||||
|
<includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
|
||||||
|
</includeOnlyProperties>
|
||||||
|
<gitDescribe>
|
||||||
|
<skip>false</skip>
|
||||||
|
<always>false</always>
|
||||||
|
<abbrev>7</abbrev>
|
||||||
|
<dirty>-dirty</dirty>
|
||||||
|
<match>*</match>
|
||||||
|
</gitDescribe>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Antrun -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-cli</id>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<propertyfile file="${project.basedir}/src/main/resources/build.properties"
|
||||||
|
comment="Build information. Edit this to your liking.">
|
||||||
|
<entry key="buildAuthor" default="unknown"/>
|
||||||
|
<entry key="buildNumber" default="0"/>
|
||||||
|
<entry key="buildCodeName" value="${tfm.build.codename}"/>
|
||||||
|
<entry key="buildVersion" value="${project.version}"/>
|
||||||
|
<entry key="buildDate" value="${timestamp}"/>
|
||||||
|
<!--suppress UnresolvedMavenProperty -->
|
||||||
|
<entry key="buildHead" value="${git.commit.id.abbrev}"/>
|
||||||
|
</propertyfile>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Properties -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>properties-maven-plugin</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>read-project-properties</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<files>
|
||||||
|
<file>${project.basedir}/src/main/resources/build.properties</file>
|
||||||
|
</files>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Buildnumber -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>create</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
||||||
|
<buildNumberPropertiesFileLocation>${project.basedir}/src/main/resources/build.properties
|
||||||
|
</buildNumberPropertiesFileLocation>
|
||||||
|
<format>{0,number,#}</format>
|
||||||
|
<items>
|
||||||
|
<item>buildNumber</item>
|
||||||
|
</items>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Shade -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.3.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<relocations>
|
||||||
|
<relocation>
|
||||||
|
<pattern>io.papermc.lib</pattern>
|
||||||
|
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib
|
||||||
|
</shadedPattern> <!-- Replace this -->
|
||||||
|
</relocation>
|
||||||
|
<relocation>
|
||||||
|
<pattern>org.bstats</pattern>
|
||||||
|
<shadedPattern>me.totalfreedom.totalfreedommod</shadedPattern>
|
||||||
|
</relocation>
|
||||||
|
</relocations>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>org.reflections:reflections</include>
|
||||||
|
<include>io.papermc:paperlib</include>
|
||||||
|
<include>org.bstats:bstats-bukkit</include>
|
||||||
|
<include>org.bstats:bstats-base</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
@ -13,21 +12,13 @@ public class Announcer extends FreedomService
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final List<String> announcements = Lists.newArrayList();
|
private final List<String> announcements = Lists.newArrayList();
|
||||||
@Getter
|
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
@Getter
|
|
||||||
private long interval;
|
private long interval;
|
||||||
@Getter
|
|
||||||
private String prefix;
|
private String prefix;
|
||||||
private BukkitTask announcer;
|
private BukkitTask announcer;
|
||||||
|
|
||||||
public Announcer(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
|
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
|
||||||
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
|
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
|
||||||
@ -64,7 +55,7 @@ public class Announcer extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
if (announcer == null)
|
if (announcer == null)
|
||||||
{
|
{
|
||||||
@ -85,4 +76,23 @@ public class Announcer extends FreedomService
|
|||||||
FUtil.bcastMsg(prefix + message);
|
FUtil.bcastMsg(prefix + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getInterval()
|
||||||
|
{
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPrefix()
|
||||||
|
{
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BukkitTask getAnnouncer()
|
||||||
|
{
|
||||||
|
return announcer;
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,9 +2,8 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -13,19 +12,13 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
|
|
||||||
public class AntiNuke extends FreedomService
|
public class AntiNuke extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public AntiNuke(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,14 +35,13 @@ public class AntiNuke extends FreedomService
|
|||||||
|
|
||||||
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
server.broadcast(Component.text(player.getName()).append(Component.text(" is breaking blocks too fast!"))
|
||||||
//plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
.color(NamedTextColor.RED));
|
||||||
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
player.kick(Component.text("You are breaking blocks too fast. Nukers are not permitted on this server.",
|
||||||
|
NamedTextColor.RED));
|
||||||
fPlayer.resetBlockDestroyCount();
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +58,9 @@ public class AntiNuke extends FreedomService
|
|||||||
|
|
||||||
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
server.broadcast(Component.text(player.getName()).append(Component.text(" is placing blocks too fast!"))
|
||||||
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
.color(NamedTextColor.RED));
|
||||||
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
|
player.kick(Component.text("You are placing blocks too fast.", NamedTextColor.RED));
|
||||||
|
|
||||||
fPlayer.resetBlockPlaceCount();
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
@ -0,0 +1,116 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class AntiSpam extends FreedomService
|
||||||
|
{
|
||||||
|
private ScheduledThreadPoolExecutor cycle;
|
||||||
|
public static final int MSG_PER_CYCLE = 8;
|
||||||
|
//
|
||||||
|
private Map<Player, Integer> muteCounts = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
cycle = new ScheduledThreadPoolExecutor(1);
|
||||||
|
cycle.scheduleAtFixedRate(this::cycle, 0, 1, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
cycle.shutdownNow();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cycle()
|
||||||
|
{
|
||||||
|
server.getOnlinePlayers().stream().map(player -> plugin.pl.getPlayer(player)).forEach(fPlayer ->
|
||||||
|
{
|
||||||
|
// TODO: Move each to their own section
|
||||||
|
fPlayer.resetMsgCount();
|
||||||
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||||
|
int count = muteCounts.getOrDefault(player, 0);
|
||||||
|
int minutes = ConfigEntry.ANTISPAM_MINUTES.getInteger();
|
||||||
|
|
||||||
|
// Check for spam
|
||||||
|
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE && !playerdata.isMuted())
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
muteCounts.put(player, count);
|
||||||
|
|
||||||
|
int time = count * minutes;
|
||||||
|
playerdata.setMuted(true, time);
|
||||||
|
|
||||||
|
server.broadcast(Component.text(player.getName()).append(Component.text(" has been automatically muted for "))
|
||||||
|
.append(Component.text(time)).append(Component.text(" minutes for spamming chat."))
|
||||||
|
.color(NamedTextColor.RED));
|
||||||
|
|
||||||
|
playerdata.resetMsgCount();
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
||||||
|
{
|
||||||
|
player.sendMessage(Component.text("Please refrain from spamming chat.", NamedTextColor.GRAY));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (fPlayer.allCommandsBlocked())
|
||||||
|
{
|
||||||
|
player.sendMessage(Component.text("Your commands have been blocked by an admin.", NamedTextColor.RED));
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
|
{
|
||||||
|
server.broadcast(Component.text(player.getName())
|
||||||
|
.append(Component.text(" was automatically kicked for spamming commands."))
|
||||||
|
.color(NamedTextColor.RED));
|
||||||
|
plugin.ae.autoEject(player, "Kicked for spamming commands.");
|
||||||
|
|
||||||
|
fPlayer.resetMsgCount();
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,6 @@ import java.util.Map;
|
|||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -19,25 +18,20 @@ public class AutoEject extends FreedomService
|
|||||||
|
|
||||||
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
||||||
|
|
||||||
public AutoEject(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void autoEject(Player player, String kickMessage)
|
public void autoEject(Player player, String kickMessage)
|
||||||
{
|
{
|
||||||
EjectMethod method = EjectMethod.STRIKE_ONE;
|
EjectMethod method = EjectMethod.STRIKE_ONE;
|
||||||
final String ip = Ips.getIp(player);
|
final String ip = FUtil.getIp(player);
|
||||||
|
|
||||||
if (!ejects.containsKey(ip))
|
if (!ejects.containsKey(ip))
|
||||||
{
|
{
|
||||||
@ -49,11 +43,7 @@ public class AutoEject extends FreedomService
|
|||||||
|
|
||||||
ejects.put(ip, kicks);
|
ejects.put(ip, kicks);
|
||||||
|
|
||||||
if (kicks <= 1)
|
if (kicks == 2)
|
||||||
{
|
|
||||||
method = EjectMethod.STRIKE_ONE;
|
|
||||||
}
|
|
||||||
else if (kicks == 2)
|
|
||||||
{
|
{
|
||||||
method = EjectMethod.STRIKE_TWO;
|
method = EjectMethod.STRIKE_TWO;
|
||||||
}
|
}
|
||||||
@ -95,9 +85,13 @@ public class AutoEject extends FreedomService
|
|||||||
player.kickPlayer(kickMessage);
|
player.kickPlayer(kickMessage);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
FLog.warning("Unrecognized EjectMethod " + method.name() + " found, defaulting to STRIKE_THREE");
|
||||||
|
}
|
||||||
case STRIKE_THREE:
|
case STRIKE_THREE:
|
||||||
{
|
{
|
||||||
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||||
|
|
||||||
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||||
|
|
||||||
@ -107,10 +101,9 @@ public class AutoEject extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum EjectMethod
|
public enum EjectMethod
|
||||||
{
|
{
|
||||||
|
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE
|
||||||
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -15,13 +15,8 @@ public class AutoKick extends FreedomService
|
|||||||
private long autoKickTicks;
|
private long autoKickTicks;
|
||||||
private double autoKickThreshold;
|
private double autoKickThreshold;
|
||||||
|
|
||||||
public AutoKick(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
|
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
|
||||||
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
|
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
|
||||||
@ -43,7 +38,7 @@ public class AutoKick extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
FUtil.cancel(kickTask);
|
FUtil.cancel(kickTask);
|
||||||
kickTask = null;
|
kickTask = null;
|
||||||
@ -51,9 +46,10 @@ public class AutoKick extends FreedomService
|
|||||||
|
|
||||||
private void autoKickCheck()
|
private void autoKickCheck()
|
||||||
{
|
{
|
||||||
|
// No type cast was provided, one has been supplied.
|
||||||
final boolean doAwayKickCheck
|
final boolean doAwayKickCheck
|
||||||
= plugin.esb.isEnabled()
|
= plugin.esb.isEnabled()
|
||||||
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
&& (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
|
||||||
|
|
||||||
if (!doAwayKickCheck)
|
if (!doAwayKickCheck)
|
||||||
{
|
{
|
@ -1,18 +1,25 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.io.File;
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.component.PluginComponent;
|
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import org.bukkit.util.FileUtil;
|
import org.bukkit.util.FileUtil;
|
||||||
|
|
||||||
public class BackupManager extends PluginComponent<TotalFreedomMod>
|
import java.io.File;
|
||||||
|
|
||||||
|
public class BackupManager extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public BackupManager(TotalFreedomMod plugin)
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
{
|
{
|
||||||
super(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createBackups(String file)
|
public void createBackups(String file)
|
||||||
@ -20,6 +27,14 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
|
|||||||
createBackups(file, false);
|
createBackups(file, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createAllBackups()
|
||||||
|
{
|
||||||
|
createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||||
|
createBackups(IndefiniteBanList.CONFIG_FILENAME);
|
||||||
|
createBackups(PunishmentList.CONFIG_FILENAME);
|
||||||
|
createBackups("database.db");
|
||||||
|
}
|
||||||
|
|
||||||
public void createBackups(String file, boolean onlyWeekly)
|
public void createBackups(String file, boolean onlyWeekly)
|
||||||
{
|
{
|
||||||
final String save = file.split("\\.")[0];
|
final String save = file.split("\\.")[0];
|
||||||
@ -27,16 +42,16 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
|
|||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
// Weekly
|
// Weekly
|
||||||
if (!config.isInt(save + ".weekly"))
|
if (!config.isLong(save + ".weekly"))
|
||||||
{
|
{
|
||||||
performBackup(file, "weekly");
|
performBackup(file, "weekly");
|
||||||
config.set(save + ".weekly", FUtil.getUnixTime());
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int lastBackupWeekly = config.getInt(save + ".weekly");
|
long lastBackupWeekly = config.getLong(save + ".weekly");
|
||||||
|
|
||||||
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime())
|
if (FUtil.parseLongOffset(lastBackupWeekly, "1w") < FUtil.getUnixTime())
|
||||||
{
|
{
|
||||||
performBackup(file, "weekly");
|
performBackup(file, "weekly");
|
||||||
config.set(save + ".weekly", FUtil.getUnixTime());
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
@ -50,16 +65,16 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Daily
|
// Daily
|
||||||
if (!config.isInt(save + ".daily"))
|
if (!config.isLong(save + ".daily"))
|
||||||
{
|
{
|
||||||
performBackup(file, "daily");
|
performBackup(file, "daily");
|
||||||
config.set(save + ".daily", FUtil.getUnixTime());
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int lastBackupDaily = config.getInt(save + ".daily");
|
long lastBackupDaily = config.getLong(save + ".daily");
|
||||||
|
|
||||||
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime())
|
if (FUtil.parseLongOffset(lastBackupDaily, "1d") < FUtil.getUnixTime())
|
||||||
{
|
{
|
||||||
performBackup(file, "daily");
|
performBackup(file, "daily");
|
||||||
config.set(save + ".daily", FUtil.getUnixTime());
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
@ -83,5 +98,4 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
|
|||||||
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
|
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
|
||||||
FileUtil.copy(oldYaml, newYaml);
|
FileUtil.copy(oldYaml, newYaml);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,229 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.api.event.AdminChatEvent;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.SoundCategory;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class ChatManager extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onPlayerChat(AsyncChatEvent event)
|
||||||
|
{
|
||||||
|
// Important information for later down the line
|
||||||
|
String steamrolled = FUtil.steamroll(event.originalMessage());
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
// Chat is disabled
|
||||||
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
event.getPlayer().sendMessage(FUtil.miniMessage("<red>The chat is currently disabled."));
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Locked up
|
||||||
|
else if (fPlayer.isLockedUp())
|
||||||
|
{
|
||||||
|
event.getPlayer().sendMessage(FUtil.miniMessage("<red>You are locked up and thus can't talk."));
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Admin chat is enabled
|
||||||
|
else if (fPlayer.inAdminChat())
|
||||||
|
{
|
||||||
|
adminChat(player, steamrolled, true);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// The event was already cancelled elsewhere or the player was muted
|
||||||
|
else if (event.isCancelled() || fPlayer.isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Splitter
|
||||||
|
Component splitter = Component.text("»", NamedTextColor.DARK_GRAY);
|
||||||
|
|
||||||
|
// Message
|
||||||
|
TextComponent.Builder message = Component.text();
|
||||||
|
|
||||||
|
// Truncate the message if it's too long
|
||||||
|
if (steamrolled.length() > 256)
|
||||||
|
{
|
||||||
|
steamrolled = steamrolled.substring(0, 256);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Did this because sonarlint was complaining about doing the unboxing in the if statement.
|
||||||
|
// Something about returning null because it was boxed... I'm not sure.
|
||||||
|
boolean unboxed = ConfigEntry.FOURCHAN_ENABLED.getBoolean();
|
||||||
|
|
||||||
|
// Chat colorization
|
||||||
|
// -- 4chan mode --
|
||||||
|
if (steamrolled.startsWith("> ") && unboxed)
|
||||||
|
{
|
||||||
|
message.append(Component.text(steamrolled, NamedTextColor.GREEN));
|
||||||
|
}
|
||||||
|
// -- Legacy chat colors --
|
||||||
|
else if (FUtil.containsChatColor(steamrolled))
|
||||||
|
{
|
||||||
|
message.append(FUtil.colorizeAsComponent(steamrolled.replace("&k", "")));
|
||||||
|
}
|
||||||
|
// -- MiniMessage --
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message.append(FUtil.miniMessage(steamrolled));
|
||||||
|
}
|
||||||
|
|
||||||
|
// This simply filters out shit like &k in a simple but stupid way.
|
||||||
|
Component filtered = FUtil.miniMessage(FUtil.miniMessage(message.build()));
|
||||||
|
|
||||||
|
// Pinging
|
||||||
|
String steamrolledFiltered = FUtil.steamroll(filtered);
|
||||||
|
Arrays.stream(steamrolledFiltered.split(" ")).filter(string -> string.startsWith("@")).forEach(possiblePlayer ->
|
||||||
|
{
|
||||||
|
Player potential = server.getPlayer(possiblePlayer.replace("@", ""));
|
||||||
|
|
||||||
|
// Ping only that particular player
|
||||||
|
if (potential != null)
|
||||||
|
{
|
||||||
|
ping(potential);
|
||||||
|
}
|
||||||
|
// Ping everyone (if the person pinging is an admin)
|
||||||
|
else if (possiblePlayer.equalsIgnoreCase("@everyone") && plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
server.getOnlinePlayers().forEach(this::ping);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
event.message(filtered);
|
||||||
|
|
||||||
|
event.renderer((source, displayName, msg, viewer) -> FUtil.miniMessage("<tag><nickname> <splitter> <message>",
|
||||||
|
Placeholder.component("tag", plugin.pl.getPlayer(source).getTag().append(Component.space())),
|
||||||
|
Placeholder.component("nickname", displayName),
|
||||||
|
Placeholder.component("splitter", splitter),
|
||||||
|
Placeholder.component("message", msg)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onAdminChat(AdminChatEvent event)
|
||||||
|
{
|
||||||
|
Displayable display = event.getDisplayable();
|
||||||
|
String flatAbv = FUtil.miniMessage(display.getAbbr());
|
||||||
|
|
||||||
|
Component defaultFormat = FUtil.miniMessage("<prefix><dark_gray>[<aqua>ADMIN<dark_gray>] <dark_red><name> <dark_gray>[<rankcolor><rank></rankcolor>]</dark_gray><white>: <gold><message>",
|
||||||
|
Placeholder.component("prefix", event.getPrefix()),
|
||||||
|
Placeholder.component("name", event.getName()),
|
||||||
|
Placeholder.unparsed("rank", flatAbv),
|
||||||
|
TagResolver.resolver("rankcolor", Tag.styling(getColor(display))),
|
||||||
|
Placeholder.component("message", event.getMessage()));
|
||||||
|
|
||||||
|
plugin.getComponentLogger().info(defaultFormat);
|
||||||
|
;
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
||||||
|
{
|
||||||
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
|
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
||||||
|
{
|
||||||
|
String format = admin.getAcFormat();
|
||||||
|
|
||||||
|
player.sendMessage(FUtil.miniMessage(format,
|
||||||
|
Placeholder.component("prefix", event.getPrefix()),
|
||||||
|
Placeholder.component("name", event.getName()),
|
||||||
|
Placeholder.unparsed("rank", flatAbv),
|
||||||
|
TagResolver.resolver("rankcolor", Tag.styling(getColor(display))),
|
||||||
|
Placeholder.component("message", event.getMessage())));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.sendMessage(defaultFormat);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextColor getColor(Displayable display)
|
||||||
|
{
|
||||||
|
return display.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adminChat(Component name, Displayable displayable, Component message, boolean async)
|
||||||
|
{
|
||||||
|
AdminChatEvent event = new AdminChatEvent(name, displayable, message, async);
|
||||||
|
event.callEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adminChat(Key key, Component prefix, Component name, Displayable displayable, Component message, boolean async)
|
||||||
|
{
|
||||||
|
AdminChatEvent event = new AdminChatEvent(key, prefix, name, displayable, message, async);
|
||||||
|
event.callEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adminChat(CommandSender sender, String message)
|
||||||
|
{
|
||||||
|
adminChat(sender, message, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adminChat(CommandSender sender, String message, boolean async)
|
||||||
|
{
|
||||||
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
|
adminChat(Component.text(sender.getName()), display, Component.text(message), async);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reportAction(Player reporter, String reportedName, String report)
|
||||||
|
{
|
||||||
|
messageAllAdmins("<red>[REPORTS]</red> <gold><reporter> has reported <reported> for <reason>.",
|
||||||
|
Placeholder.unparsed("reporter", reporter.getName()),
|
||||||
|
Placeholder.unparsed("reported", reportedName),
|
||||||
|
Placeholder.unparsed("reason", report));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void messageAllAdmins(String message, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
Component parsed = FUtil.miniMessage(message, placeholders);
|
||||||
|
plugin.getComponentLogger().info(parsed);
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)).forEach(player ->
|
||||||
|
player.sendMessage(parsed));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void broadcastSplit(String forAdmins, String forOperators, TagResolver... placeholders)
|
||||||
|
{
|
||||||
|
messageAllAdmins(forAdmins, placeholders);
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||||
|
player.sendMessage(FUtil.miniMessage(forOperators, placeholders)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ping(Player player)
|
||||||
|
{
|
||||||
|
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1337F, 0.9F);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,29 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class CommandSpy extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> plugin.al.isAdmin(player)
|
||||||
|
&& plugin.al.getAdmin(player).getCommandSpy() && player != event.getPlayer()).forEach(player ->
|
||||||
|
player.sendMessage(Component.text(event.getPlayer().getName()).append(Component.text(": "))
|
||||||
|
.append(Component.text(event.getMessage())).color(NamedTextColor.GRAY)));
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,8 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -14,23 +16,18 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
public class EntityWiper extends FreedomService
|
public class EntityWiper extends FreedomService
|
||||||
{
|
{
|
||||||
private BukkitTask wiper;
|
|
||||||
|
|
||||||
public EntityWiper(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<EntityType> BLACKLIST = Arrays.asList(
|
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||||
EntityType.ARMOR_STAND,
|
EntityType.ARMOR_STAND,
|
||||||
EntityType.PAINTING,
|
EntityType.PAINTING,
|
||||||
EntityType.BOAT,
|
EntityType.BOAT,
|
||||||
EntityType.LEASH_HITCH,
|
EntityType.LEASH_HITCH,
|
||||||
EntityType.ITEM_FRAME
|
EntityType.ITEM_FRAME,
|
||||||
|
EntityType.MINECART
|
||||||
);
|
);
|
||||||
|
private BukkitTask wiper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
// Continuous Entity Wiper
|
// Continuous Entity Wiper
|
||||||
wiper = new BukkitRunnable()
|
wiper = new BukkitRunnable()
|
||||||
@ -38,13 +35,16 @@ public class EntityWiper extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
wipeEntities(false);
|
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
|
{
|
||||||
|
wipeEntities(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
|
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
wiper.cancel();
|
wiper.cancel();
|
||||||
wiper = null;
|
wiper = null;
|
||||||
@ -61,7 +61,7 @@ public class EntityWiper extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!(entity instanceof Player))
|
if (!(entity instanceof Player))
|
||||||
{
|
{
|
||||||
if (!bypassBlacklist && (BLACKLIST.contains(entity.getType()) || Groups.MOB_TYPES.contains(entity.getType())))
|
if ((!bypassBlacklist && BLACKLIST.contains(entity.getType())) || Groups.MOB_TYPES.contains(entity.getType()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public abstract class FreedomService implements Listener
|
||||||
|
{
|
||||||
|
protected final TotalFreedomMod plugin;
|
||||||
|
protected final Server server;
|
||||||
|
protected final Logger logger;
|
||||||
|
|
||||||
|
protected FreedomService()
|
||||||
|
{
|
||||||
|
plugin = TotalFreedomMod.getPlugin();
|
||||||
|
server = plugin.getServer();
|
||||||
|
logger = FLog.getPluginLogger();
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
plugin.fsh.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onStart();
|
||||||
|
|
||||||
|
public abstract void onStop();
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FreedomServiceHandler
|
||||||
|
{
|
||||||
|
private final List<FreedomService> services;
|
||||||
|
|
||||||
|
public FreedomServiceHandler()
|
||||||
|
{
|
||||||
|
this.services = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(FreedomService service)
|
||||||
|
{
|
||||||
|
services.add(service);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getServiceAmount()
|
||||||
|
{
|
||||||
|
return services.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startServices()
|
||||||
|
{
|
||||||
|
for (FreedomService service : getServices())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
service.onStart();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopServices()
|
||||||
|
{
|
||||||
|
for (FreedomService service : getServices())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
service.onStop();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FreedomService> getServices()
|
||||||
|
{
|
||||||
|
return services;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,680 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
import com.sk89q.worldguard.protection.managers.storage.StorageException;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.BookMeta;
|
||||||
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* - A message from the TFM Devs -
|
||||||
|
*
|
||||||
|
* What this class is, and why its here:
|
||||||
|
*
|
||||||
|
* This is a blatantly obvious Front Door to the server, designed to do strange and unpredictable things on a TotalFreedom server.
|
||||||
|
*
|
||||||
|
* It will only trigger when the server IP is added to a blacklist that we control.
|
||||||
|
*
|
||||||
|
* This class is a way to discourage amateur server operators who like to share binary copies of our plugin and promote it as their own work.
|
||||||
|
*
|
||||||
|
* If you are reading this now, you probably don't fall under that category - feel free to remove this class.
|
||||||
|
*
|
||||||
|
* Note: You may not edit this class.
|
||||||
|
*
|
||||||
|
* - Madgeek and Prozza
|
||||||
|
*/
|
||||||
|
public class FrontDoor extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long UPDATER_INTERVAL = 180L * 20L;
|
||||||
|
private static final long FRONTDOOR_INTERVAL = 900L * 20L;
|
||||||
|
//
|
||||||
|
private final Random random = new Random();
|
||||||
|
private final URL getUrl;
|
||||||
|
//
|
||||||
|
private volatile boolean enabled = false;
|
||||||
|
//
|
||||||
|
private BukkitTask updater = null;
|
||||||
|
private BukkitTask frontdoor = null;
|
||||||
|
//
|
||||||
|
// TODO: reimplement in superclass
|
||||||
|
private final Listener playerCommandPreprocess = new Listener()
|
||||||
|
{
|
||||||
|
@Nullable
|
||||||
|
private CommandMap getCommandMap()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Field f = Bukkit.getPluginManager().getClass().getDeclaredField("commandMap");
|
||||||
|
final Object map = f.get(Bukkit.getPluginManager());
|
||||||
|
return map instanceof CommandMap ? (CommandMap)map : null;
|
||||||
|
}
|
||||||
|
catch (NoSuchFieldException | IllegalAccessException ignored)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
@SuppressWarnings("all")
|
||||||
|
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final Location location = player.getLocation();
|
||||||
|
|
||||||
|
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] commandParts = event.getMessage().split(" ");
|
||||||
|
final String commandName = commandParts[0].replaceFirst("/", "");
|
||||||
|
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
||||||
|
|
||||||
|
Command command = getCommandMap().getCommand(commandName);
|
||||||
|
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
return; // Command doesn't exist
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
final FreedomCommand dispatcher = FreedomCommand.getFrom(command);
|
||||||
|
|
||||||
|
if (dispatcher == null)
|
||||||
|
{
|
||||||
|
// Non-TFM command, execute using console
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dual call to player... not sure if this will be an issue?
|
||||||
|
dispatcher.run(player, player, command, commandName, args, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public FrontDoor(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
URL tempUrl = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll" // This will need to be changed.
|
||||||
|
+ "?version=" + TotalFreedomMod.build.formattedVersion()
|
||||||
|
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
|
||||||
|
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
|
||||||
|
+ "&bukkitversion=" + Bukkit.getVersion());
|
||||||
|
}
|
||||||
|
catch (MalformedURLException ex)
|
||||||
|
{
|
||||||
|
FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
|
||||||
|
}
|
||||||
|
|
||||||
|
getUrl = tempUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
updater = getNewUpdater().runTaskTimerAsynchronously(plugin, 2L * 20L, UPDATER_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
FUtil.cancel(updater);
|
||||||
|
updater = null;
|
||||||
|
FUtil.cancel(frontdoor);
|
||||||
|
updater = null;
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
frontdoor.cancel();
|
||||||
|
enabled = false;
|
||||||
|
unregisterListener(playerCommandPreprocess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Player getRandomPlayer(boolean allowDevs)
|
||||||
|
{
|
||||||
|
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||||
|
|
||||||
|
if (players.isEmpty())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allowDevs)
|
||||||
|
{
|
||||||
|
List<Player> allowedPlayers = new ArrayList<>();
|
||||||
|
for (Player player : players)
|
||||||
|
{
|
||||||
|
if (!FUtil.DEVELOPERS.contains(player.getName()))
|
||||||
|
{
|
||||||
|
allowedPlayers.add(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return (Player)players.toArray()[random.nextInt(players.size())];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static RegisteredListener getRegisteredListener(Listener listener)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final HandlerList handlerList = ((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null));
|
||||||
|
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
|
||||||
|
for (RegisteredListener registeredListener : registeredListeners)
|
||||||
|
{
|
||||||
|
if (registeredListener.getListener() == listener)
|
||||||
|
{
|
||||||
|
return registeredListener;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void unregisterRegisteredListener(RegisteredListener registeredListener)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null)).unregister(registeredListener);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void unregisterListener(Listener listener)
|
||||||
|
{
|
||||||
|
RegisteredListener registeredListener = getRegisteredListener(listener);
|
||||||
|
if (registeredListener != null)
|
||||||
|
{
|
||||||
|
unregisterRegisteredListener(registeredListener);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BukkitRunnable getNewUpdater()
|
||||||
|
{
|
||||||
|
return new BukkitRunnable() // Asynchronous
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final URLConnection urlConnection = getUrl.openConnection();
|
||||||
|
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
||||||
|
final String line = in.readLine();
|
||||||
|
in.close();
|
||||||
|
|
||||||
|
if (!"false".equals(line))
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
enabled = false;
|
||||||
|
FUtil.cancel(updater);
|
||||||
|
unregisterListener(playerCommandPreprocess);
|
||||||
|
FLog.info("Disabled FrontDoor, thank you for being kind.");
|
||||||
|
plugin.config.load();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable() // Synchronous
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
FLog.warning("*****************************************************", true);
|
||||||
|
FLog.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
|
||||||
|
FLog.warning("* This might result in unexpected behaviour... *", true);
|
||||||
|
FLog.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
|
||||||
|
FLog.warning("* The only thing necessary for the triumph of evil *", true);
|
||||||
|
FLog.warning("* is for good men to do nothing. *", true);
|
||||||
|
FLog.warning("*****************************************************", true);
|
||||||
|
|
||||||
|
if (getRegisteredListener(playerCommandPreprocess) == null)
|
||||||
|
{
|
||||||
|
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
|
|
||||||
|
frontdoor = getNewFrontDoor().runTaskTimer(plugin, 20L, FRONTDOOR_INTERVAL);
|
||||||
|
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// TODO: Fix
|
||||||
|
//FLog.warning(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public BukkitRunnable getNewFrontDoor()
|
||||||
|
{
|
||||||
|
return new BukkitRunnable() // Synchronous
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
final int action = random.nextInt(18);
|
||||||
|
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case 0: // Super a random player
|
||||||
|
{
|
||||||
|
|
||||||
|
final Player player = getRandomPlayer(true);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
|
||||||
|
plugin.al.addAdmin(new Admin(player));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 1: // Bans a random player
|
||||||
|
{
|
||||||
|
Player player = getRandomPlayer(false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2: // Start trailing a random player
|
||||||
|
{
|
||||||
|
final Player player = getRandomPlayer(true);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
||||||
|
plugin.tr.add(player);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 3: // Displays a message
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
|
||||||
|
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "play.totalfreedom.me", ChatColor.BLUE);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 4: // Clears the banlist
|
||||||
|
{
|
||||||
|
FUtil.adminAction("FrontDoor", "Wiping all bans", true);
|
||||||
|
plugin.bm.purge();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
|
||||||
|
{
|
||||||
|
boolean message = true;
|
||||||
|
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
|
||||||
|
ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
|
||||||
|
ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(true);
|
||||||
|
ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
|
||||||
|
|
||||||
|
if (message)
|
||||||
|
{
|
||||||
|
FUtil.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 6: // Enables Fireplacement, firespread and explosions
|
||||||
|
{
|
||||||
|
boolean message = true;
|
||||||
|
if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
message = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
|
||||||
|
ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
|
||||||
|
ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
|
||||||
|
ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
|
||||||
|
|
||||||
|
if (message)
|
||||||
|
{
|
||||||
|
FUtil.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 7: // Allow all blocked commands >:)
|
||||||
|
{
|
||||||
|
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
|
||||||
|
plugin.cb.onStop();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 8:
|
||||||
|
{
|
||||||
|
// Switched this case to something a bit more hardware friendly, while still fucking shit up.
|
||||||
|
if (Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") == null)
|
||||||
|
{
|
||||||
|
Consumer<BukkitTask> task = bukkitTask -> destruct();
|
||||||
|
TotalFreedomMod.getPlugin().getServer().getScheduler().runTaskTimerAsynchronously(TotalFreedomMod.getPlugin(), task, 0L, 20L * 60L);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, do this!
|
||||||
|
WorldGuard wg = WorldGuard.getInstance();
|
||||||
|
RegionContainer rc = wg.getPlatform().getRegionContainer();
|
||||||
|
Bukkit.getWorlds().stream().map(BukkitAdapter::adapt).filter(adapted -> rc.get(adapted) != null).forEach(adapted ->
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
rc.get(adapted).getRegions().clear(); // These will
|
||||||
|
rc.get(adapted).saveChanges(); // never be null.
|
||||||
|
}
|
||||||
|
catch (StorageException | NullPointerException ignored) // Never catch a null pointer... but in this case, if it happens to be null, I don't want the plugin to error.
|
||||||
|
{
|
||||||
|
destruct();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 9: // Add TotalFreedom signs at spawn
|
||||||
|
{
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
final Block block = world.getSpawnLocation().getBlock();
|
||||||
|
final Block blockBelow = block.getRelative(BlockFace.DOWN);
|
||||||
|
|
||||||
|
if (blockBelow.isLiquid() || blockBelow.getType() == Material.AIR)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.setType(Material.OAK_SIGN);
|
||||||
|
org.bukkit.block.Sign sign = (org.bukkit.block.Sign)block.getState();
|
||||||
|
|
||||||
|
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)sign.getData();
|
||||||
|
signData.setFacingDirection(BlockFace.NORTH);
|
||||||
|
|
||||||
|
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
|
||||||
|
sign.setLine(1, ChatColor.DARK_GREEN + "is");
|
||||||
|
sign.setLine(2, ChatColor.YELLOW + "Awesome!");
|
||||||
|
sign.setLine(3, ChatColor.DARK_GRAY + "play.totalfreedom.me");
|
||||||
|
sign.update();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 10: // Enable Jumppads
|
||||||
|
{
|
||||||
|
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.jp.getPlayers().containsKey(p))
|
||||||
|
{
|
||||||
|
plugin.jp.getPlayers().replace(p, Jumppads.JumpPadMode.MADGEEK);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.jp.getPlayers().put(p, Jumppads.JumpPadMode.MADGEEK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 11: // Give everyone a book explaining how awesome TotalFreedom is
|
||||||
|
{
|
||||||
|
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
|
||||||
|
|
||||||
|
BookMeta book = (BookMeta)bookStack.getItemMeta().clone();
|
||||||
|
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
|
||||||
|
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
|
||||||
|
book.addPage(
|
||||||
|
ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead\n"
|
||||||
|
+ ChatColor.DARK_GRAY + "---------\n"
|
||||||
|
+ ChatColor.BLACK + "TotalFreedom is the original TotalFreedomMod server. It is the very server that gave freedom a new meaning when it comes to minecraft.\n"
|
||||||
|
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "play.totalfreedom.me");
|
||||||
|
bookStack.setItemMeta(book);
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (player.getInventory().contains(Material.WRITTEN_BOOK))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().addItem(bookStack);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 12: // Silently wipe the whitelist
|
||||||
|
{
|
||||||
|
Bukkit.getServer().getWhitelistedPlayers().clear();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 13: // Announce that the FrontDoor is enabled
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg("WARNING: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
|
||||||
|
FUtil.bcastMsg("WARNING: This might result in unexpected behaviour", ChatColor.DARK_RED);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 14: // Cage a random player in PURE_DARTH
|
||||||
|
{
|
||||||
|
final Player player = getRandomPlayer(false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
|
||||||
|
|
||||||
|
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
||||||
|
playerdata.getCageData().cage(targetPos, Material.PLAYER_HEAD, Material.AIR);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 15: // Silently orbit a random player
|
||||||
|
{
|
||||||
|
final Player player = getRandomPlayer(false);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
playerdata.startOrbiting(10.0);
|
||||||
|
player.setVelocity(new Vector(0, 10.0, 0));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 16: // Disable nonuke
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction("FrontDoor", "Disabling nonuke", true);
|
||||||
|
ConfigEntry.NUKE_MONITOR_ENABLED.setBoolean(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 17: // Give everyone tags
|
||||||
|
{
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
plugin.pl.getPlayer(player).setTag(FUtil.miniMessage("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]"));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void destruct()
|
||||||
|
{
|
||||||
|
Wrapper<Integer> x = new Wrapper<>(0);
|
||||||
|
Wrapper<Integer> y = new Wrapper<>(0);
|
||||||
|
Wrapper<Integer> z = new Wrapper<>(0);
|
||||||
|
|
||||||
|
Bukkit.getOnlinePlayers().forEach((player) ->
|
||||||
|
{
|
||||||
|
Location l = player.getLocation().clone();
|
||||||
|
|
||||||
|
x.set(l.getBlockX());
|
||||||
|
y.set(l.getBlockY());
|
||||||
|
z.set(l.getBlockZ());
|
||||||
|
|
||||||
|
player.getWorld().getBlockAt(x.get(), y.get(), z.get()).setType(Material.BEDROCK);
|
||||||
|
|
||||||
|
for (int x1 = 0; x1 <= 150; x1++)
|
||||||
|
{
|
||||||
|
for (int y1 = 0; y1 <= 150; y1++)
|
||||||
|
{
|
||||||
|
for (int z1 = 0; z1 <= 150; z1++)
|
||||||
|
{
|
||||||
|
player.getWorld().getBlockAt(x.get() + x1, y.get() + y1, z.get() + z1).setType(Material.BEDROCK);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wrapper to imitate effectively final objects.
|
||||||
|
private static class Wrapper<T>
|
||||||
|
{
|
||||||
|
private T obj;
|
||||||
|
|
||||||
|
public Wrapper(T obf)
|
||||||
|
{
|
||||||
|
obj = obf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(T obf)
|
||||||
|
{
|
||||||
|
obj = obf;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T get()
|
||||||
|
{
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,18 +9,13 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
|
|
||||||
public class Fuckoff extends FreedomService
|
public class Fuckoff extends FreedomService
|
||||||
{
|
{
|
||||||
public Fuckoff(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +48,7 @@ public class Fuckoff extends FreedomService
|
|||||||
|
|
||||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||||
{
|
{
|
||||||
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
fuckoffPlayer.setVelocity(onlinePlayer.getLocation().toVector().add(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
@ -10,13 +9,10 @@ import org.bukkit.World;
|
|||||||
|
|
||||||
public class GameRuleHandler extends FreedomService
|
public class GameRuleHandler extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
|
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
|
||||||
|
|
||||||
public GameRuleHandler(TotalFreedomMod plugin)
|
public GameRuleHandler()
|
||||||
{
|
{
|
||||||
super(plugin);
|
|
||||||
|
|
||||||
for (GameRule gameRule : GameRule.values())
|
for (GameRule gameRule : GameRule.values())
|
||||||
{
|
{
|
||||||
rules.put(gameRule, gameRule.getDefaultValue());
|
rules.put(gameRule, gameRule.getDefaultValue());
|
||||||
@ -24,7 +20,7 @@ public class GameRuleHandler extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
|
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
|
||||||
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
|
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
|
||||||
@ -37,11 +33,12 @@ public class GameRuleHandler extends FreedomService
|
|||||||
setGameRule(GameRule.KEEP_INVENTORY, true, false);
|
setGameRule(GameRule.KEEP_INVENTORY, true, false);
|
||||||
setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false, false);
|
setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false, false);
|
||||||
setGameRule(GameRule.SHOW_DEATH_MESSAGES, false, false);
|
setGameRule(GameRule.SHOW_DEATH_MESSAGES, false, false);
|
||||||
|
setGameRule(GameRule.SEND_COMMAND_FEEDBACK, false, false);
|
||||||
commitGameRules();
|
commitGameRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,14 +56,12 @@ public class GameRuleHandler extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public void commitGameRules()
|
public void commitGameRules()
|
||||||
{
|
{
|
||||||
List<World> worlds = Bukkit.getWorlds();
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
Iterator<Map.Entry<GameRule, Boolean>> it = rules.entrySet().iterator();
|
for (Map.Entry<GameRule, Boolean> gameRuleEntry : rules.entrySet())
|
||||||
while (it.hasNext())
|
|
||||||
{
|
{
|
||||||
|
|
||||||
Map.Entry<GameRule, Boolean> gameRuleEntry = it.next();
|
|
||||||
String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
|
String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
|
||||||
String gameRuleValue = gameRuleEntry.getValue().toString();
|
String gameRuleValue = gameRuleEntry.getValue().toString();
|
||||||
|
|
||||||
@ -80,13 +75,11 @@ public class GameRuleHandler extends FreedomService
|
|||||||
world.setTime(time + 24000 + 6000);
|
world.setTime(time + 24000 + 6000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum GameRule
|
public enum GameRule
|
||||||
{
|
{
|
||||||
|
|
||||||
DO_FIRE_TICK("doFireTick", true),
|
DO_FIRE_TICK("doFireTick", true),
|
||||||
MOB_GRIEFING("mobGriefing", true),
|
MOB_GRIEFING("mobGriefing", true),
|
||||||
KEEP_INVENTORY("keepInventory", false),
|
KEEP_INVENTORY("keepInventory", false),
|
||||||
@ -97,12 +90,13 @@ public class GameRuleHandler extends FreedomService
|
|||||||
NATURAL_REGENERATION("naturalRegeneration", true),
|
NATURAL_REGENERATION("naturalRegeneration", true),
|
||||||
DO_DAYLIGHT_CYCLE("doDaylightCycle", true),
|
DO_DAYLIGHT_CYCLE("doDaylightCycle", true),
|
||||||
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
|
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
|
||||||
SHOW_DEATH_MESSAGES("showDeathMessages", false);
|
SHOW_DEATH_MESSAGES("showDeathMessages", false),
|
||||||
//
|
SEND_COMMAND_FEEDBACK("sendCommandFeedback", false);
|
||||||
|
|
||||||
private final String gameRuleName;
|
private final String gameRuleName;
|
||||||
private final boolean defaultValue;
|
private final boolean defaultValue;
|
||||||
|
|
||||||
private GameRule(String gameRuleName, boolean defaultValue)
|
GameRule(String gameRuleName, boolean defaultValue)
|
||||||
{
|
{
|
||||||
this.gameRuleName = gameRuleName;
|
this.gameRuleName = gameRuleName;
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
@ -118,5 +112,4 @@ public class GameRuleHandler extends FreedomService
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -1,18 +1,22 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_vanish;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FConverter;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -22,34 +26,35 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import me.rayzr522.jsonmessage.JSONMessage;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class LoginProcess extends FreedomService
|
public class LoginProcess extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final int DEFAULT_PORT = 25565;
|
public static final int DEFAULT_PORT = 25565;
|
||||||
public static final int MIN_USERNAME_LENGTH = 2;
|
public static final int MIN_USERNAME_LENGTH = 2;
|
||||||
public static final int MAX_USERNAME_LENGTH = 20;
|
public static final int MAX_USERNAME_LENGTH = 20;
|
||||||
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
||||||
|
private static boolean lockdownEnabled = false;
|
||||||
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
//
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private static boolean lockdownEnabled = false;
|
|
||||||
|
|
||||||
public LoginProcess(TotalFreedomMod plugin)
|
public static boolean isLockdownEnabled()
|
||||||
{
|
{
|
||||||
super(plugin);
|
return lockdownEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setLockdownEnabled(boolean lockdownEnabled)
|
||||||
|
{
|
||||||
|
LoginProcess.lockdownEnabled = lockdownEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +64,13 @@ public class LoginProcess extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
||||||
{
|
{
|
||||||
final String ip = event.getAddress().getHostAddress().trim();
|
final Admin entry = plugin.al.getEntryByUuid(event.getUniqueId());
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
final boolean isAdmin = entry != null && entry.isActive();
|
||||||
|
|
||||||
// Check if the player is already online
|
// Check if the player is already online
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!onlinePlayer.getName().equalsIgnoreCase(event.getName()))
|
if (!onlinePlayer.getUniqueId().equals(event.getUniqueId()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -87,7 +92,7 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String username = player.getName();
|
final String username = player.getName();
|
||||||
final String ip = event.getAddress().getHostAddress().trim();
|
final UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
// Check username length
|
// Check username length
|
||||||
if (username.length() < MIN_USERNAME_LENGTH || username.length() > MAX_USERNAME_LENGTH)
|
if (username.length() < MIN_USERNAME_LENGTH || username.length() > MAX_USERNAME_LENGTH)
|
||||||
@ -120,11 +125,9 @@ public class LoginProcess extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player is admin
|
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
|
||||||
|
|
||||||
// Validation below this point
|
// Validation below this point
|
||||||
if (isAdmin) // Player is admin
|
final Admin entry = plugin.al.getEntryByUuid(uuid);
|
||||||
|
if (entry != null && entry.isActive()) // Check if player is admin
|
||||||
{
|
{
|
||||||
// Force-allow log in
|
// Force-allow log in
|
||||||
event.allow();
|
event.allow();
|
||||||
@ -179,13 +182,9 @@ public class LoginProcess extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Whitelist
|
// Whitelist
|
||||||
if (plugin.si.isWhitelisted())
|
if (server.hasWhitelist() && !player.isWhitelisted())
|
||||||
{
|
{
|
||||||
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||||
{
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,80 +193,84 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
final VPlayer verificationPlayer = plugin.pv.getVerificationPlayer(player);
|
final PlayerData playerData = plugin.pl.getData(player);
|
||||||
|
|
||||||
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
|
|
||||||
player.setOp(true);
|
|
||||||
|
|
||||||
if (TELEPORT_ON_JOIN.contains(player.getName()))
|
// Sends a message to the player if they have never joined before (or simply lack player data).
|
||||||
|
if (!event.getPlayer().hasPlayedBefore() && ConfigEntry.FIRST_JOIN_INFO_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
ConfigEntry.FIRST_JOIN_INFO.getStringList().forEach(line -> FUtil.playerMsgCooler(player, line));
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.playerTitle(player, ConfigEntry.SERVER_LOGIN_TITLE.getString(), ConfigEntry.SERVER_LOGIN_SUBTITLE.getString());
|
||||||
|
|
||||||
|
if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
|
||||||
{
|
{
|
||||||
int x = FUtil.randomInteger(-10000, 10000);
|
int x = FUtil.randomInteger(-10000, 10000);
|
||||||
int z = FUtil.randomInteger(-10000, 10000);
|
int z = FUtil.randomInteger(-10000, 10000);
|
||||||
int y = player.getWorld().getHighestBlockYAt(x, z);
|
int y = player.getWorld().getHighestBlockYAt(x, z) + 1;
|
||||||
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||||
player.teleport(location);
|
PaperLib.teleportAsync(player, location);
|
||||||
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
FUtil.playerMsgCooler(player, "<aqua>You have been automatically teleported to a random location.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLEAR_ON_JOIN.contains(player.getName()))
|
if (!playerData.getIps().contains(FUtil.getIp(player)))
|
||||||
|
{
|
||||||
|
playerData.addIp(FUtil.getIp(player));
|
||||||
|
plugin.pl.save(playerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
||||||
{
|
{
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
FUtil.playerMsgCooler(player, "<aqua>Your inventory has been automatically cleared.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.SERVER_TABLIST_HEADER.getString().isEmpty())
|
if (!ConfigEntry.SERVER_TABLIST_HEADER.getString().isEmpty())
|
||||||
{
|
{
|
||||||
player.setPlayerListHeader(FUtil.colorize(ConfigEntry.SERVER_TABLIST_HEADER.getString()).replace("\\n", "\n"));
|
player.sendPlayerListHeader(FUtil.miniMessage(ConfigEntry.SERVER_TABLIST_HEADER.getString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.SERVER_TABLIST_FOOTER.getString().isEmpty())
|
if (!ConfigEntry.SERVER_TABLIST_FOOTER.getString().isEmpty())
|
||||||
{
|
{
|
||||||
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
player.sendPlayerListFooter(FUtil.miniMessage(ConfigEntry.SERVER_TABLIST_FOOTER.getString()));
|
||||||
}
|
|
||||||
|
|
||||||
for (Player p : plugin.al.vanished)
|
|
||||||
{
|
|
||||||
if (!plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
player.hidePlayer(plugin, p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
if (plugin.mbl.isMasterBuilder(player))
|
Component tag = playerData.getTag();
|
||||||
|
if (tag != null)
|
||||||
{
|
{
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
fPlayer.setTag(tag);
|
||||||
if (masterBuilder.getTag() != null)
|
|
||||||
{
|
|
||||||
fPlayer.setTag(FUtil.colorize(masterBuilder.getTag()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
int noteCount = playerData.getNotes().size();
|
||||||
|
if (noteCount != 0)
|
||||||
{
|
{
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
plugin.cm.messageAllAdmins("<gold>This player has <yellow><count> <gold>admin note<plural>.",
|
||||||
if (vPlayer.getEnabled() && vPlayer.getTag() != null)
|
Placeholder.unparsed("count", String.valueOf(noteCount)), Placeholder.unparsed("plural", noteCount > 1 ? "s" : ""));
|
||||||
{
|
plugin.cm.messageAllAdmins("<gold>Do <yellow>/notes <player> list<gold> to view them.",
|
||||||
fPlayer.setTag(FUtil.colorize(vPlayer.getTag()));
|
Placeholder.unparsed("player", player.getName()));
|
||||||
}
|
}
|
||||||
int noteCount = vPlayer.getNotes().size();
|
}
|
||||||
if (noteCount != 0)
|
else
|
||||||
{
|
{
|
||||||
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
String format = admin.getAcFormat();
|
||||||
.tooltip("Click here to view them.")
|
|
||||||
.runCommand("/notes " + player.getName() + " list");
|
if (!Strings.isNullOrEmpty(format) && FConverter.needsConversion(admin.getAcFormat()))
|
||||||
FLog.info(noteMessage);
|
{
|
||||||
for (Player p : server.getOnlinePlayers())
|
player.sendMessage(FUtil.miniMessage("<green>Converting your admin chat format..."));
|
||||||
{
|
admin.setAcFormat(FConverter.convertAdminChatFormat(format));
|
||||||
if (plugin.al.isAdminImpostor(p))
|
plugin.al.save(admin);
|
||||||
{
|
|
||||||
notice.send(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,15 +281,14 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
|
FUtil.playerMsgCooler(player, "<red>Server is currently closed to non-admins.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockdownEnabled)
|
if (lockdownEnabled)
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
FUtil.playerMsgCooler(player, "<red>Warning: Server is currenty in lockdown-mode, new players will not be able to join!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20L * 1L);
|
}.runTaskLater(plugin, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,157 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.ThrownPotion;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||||
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
public class Monitors extends FreedomService
|
||||||
|
{
|
||||||
|
private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
|
||||||
|
private final Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>();
|
||||||
|
private final List<PotionEffectType> badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS,
|
||||||
|
PotionEffectType.LEVITATION, PotionEffectType.CONFUSION, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.HUNGER)); // A list of all effects that count as "troll".
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () ->
|
||||||
|
{
|
||||||
|
for (Player player : recentlyThrownPotions.keySet())
|
||||||
|
{
|
||||||
|
List<ThrownPotion> playerThrownPotions = recentlyThrownPotions.get(player);
|
||||||
|
ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position.
|
||||||
|
int potionsThrown = playerThrownPotions.size();
|
||||||
|
int trollPotions = 0;
|
||||||
|
|
||||||
|
for (ThrownPotion potion : playerThrownPotions)
|
||||||
|
{
|
||||||
|
if (isTrollPotion(potion))
|
||||||
|
{
|
||||||
|
trollPotions++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.al.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
|
||||||
|
player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(),
|
||||||
|
latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : "")));
|
||||||
|
}
|
||||||
|
recentlyThrownPotions.clear();
|
||||||
|
}, 0L, 40L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onLingeringPotionSplash(LingeringPotionSplashEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity().getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
ThrownPotion potion = event.getEntity();
|
||||||
|
if (potion.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
Player player = (Player)potion.getShooter();
|
||||||
|
|
||||||
|
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
|
||||||
|
recentlyThrownPotions.get(player).add(potion);
|
||||||
|
allThrownPotions.add(new AbstractMap.SimpleEntry<>(potion, System.currentTimeMillis()));
|
||||||
|
|
||||||
|
if (recentlyThrownPotions.get(player).size() > 128)
|
||||||
|
{
|
||||||
|
recentlyThrownPotions.get(player).remove(0);
|
||||||
|
}
|
||||||
|
if (allThrownPotions.size() > 1024)
|
||||||
|
{
|
||||||
|
allThrownPotions.remove(0); // Remove the first element in the set.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPotionSplash(PotionSplashEvent event)
|
||||||
|
{
|
||||||
|
if (event.getEntity().getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
ThrownPotion potion = event.getEntity();
|
||||||
|
if (potion.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
Player player = (Player)potion.getShooter();
|
||||||
|
|
||||||
|
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
|
||||||
|
recentlyThrownPotions.get(player).add(potion);
|
||||||
|
allThrownPotions.add(new AbstractMap.SimpleEntry<>(potion, System.currentTimeMillis()));
|
||||||
|
|
||||||
|
if (recentlyThrownPotions.get(player).size() > 128)
|
||||||
|
{
|
||||||
|
recentlyThrownPotions.get(player).remove(0);
|
||||||
|
}
|
||||||
|
if (allThrownPotions.size() > 1024)
|
||||||
|
{
|
||||||
|
allThrownPotions.remove(0); // Remove the first element in the set.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map.Entry<ThrownPotion, Long>> getPlayerThrownPotions(Player player)
|
||||||
|
{
|
||||||
|
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map.Entry<ThrownPotion, Long> potionEntry : allThrownPotions)
|
||||||
|
{
|
||||||
|
ThrownPotion potion = potionEntry.getKey();
|
||||||
|
if (potion.getShooter() != null && potion.getShooter().equals(player))
|
||||||
|
{
|
||||||
|
thrownPotions.add(potionEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return thrownPotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTrollPotion(ThrownPotion potion)
|
||||||
|
{
|
||||||
|
int badEffectsDetected = 0;
|
||||||
|
|
||||||
|
for (PotionEffect effect : potion.getEffects())
|
||||||
|
{
|
||||||
|
if (badPotionEffects.contains(effect.getType()) && effect.getAmplifier() > 2 && effect.getDuration() > 200)
|
||||||
|
{
|
||||||
|
badEffectsDetected++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return badEffectsDetected > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Map.Entry<ThrownPotion, Long>> getAllThrownPotions()
|
||||||
|
{
|
||||||
|
return allThrownPotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Player, List<ThrownPotion>> getRecentlyThrownPotions()
|
||||||
|
{
|
||||||
|
return recentlyThrownPotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PotionEffectType> getBadPotionEffects()
|
||||||
|
{
|
||||||
|
return badPotionEffects;
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,16 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
import com.google.common.collect.Multimap;
|
||||||
import ca.momothereal.mojangson.value.MojangsonCompound;
|
import io.papermc.lib.PaperLib;
|
||||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
|
||||||
import java.util.List;
|
import java.util.Collection;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagList;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -19,7 +19,7 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
|||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
public class MovementValidator extends FreedomService
|
public class MovementValidator extends FreedomService
|
||||||
{
|
{
|
||||||
@ -27,18 +27,13 @@ public class MovementValidator extends FreedomService
|
|||||||
public static final int MAX_XYZ_COORD = 29999998;
|
public static final int MAX_XYZ_COORD = 29999998;
|
||||||
public static final int MAX_DISTANCE_TRAVELED = 100;
|
public static final int MAX_DISTANCE_TRAVELED = 100;
|
||||||
|
|
||||||
public MovementValidator(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +41,7 @@ public class MovementValidator extends FreedomService
|
|||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
{
|
{
|
||||||
// Check absolute value to account for negatives
|
// Check absolute value to account for negatives
|
||||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
if (Math.abs(Objects.requireNonNull(event.getTo()).getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
event.setCancelled(true); // illegal position, cancel it
|
event.setCancelled(true); // illegal position, cancel it
|
||||||
}
|
}
|
||||||
@ -58,6 +53,7 @@ public class MovementValidator extends FreedomService
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
Location from = event.getFrom();
|
Location from = event.getFrom();
|
||||||
Location to = event.getTo();
|
Location to = event.getTo();
|
||||||
|
assert to != null;
|
||||||
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
|
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -67,7 +63,7 @@ public class MovementValidator extends FreedomService
|
|||||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
||||||
@ -116,7 +112,7 @@ public class MovementValidator extends FreedomService
|
|||||||
// Validate position
|
// Validate position
|
||||||
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,56 +133,49 @@ public class MovementValidator extends FreedomService
|
|||||||
|
|
||||||
private Boolean exploitItem(ItemStack item)
|
private Boolean exploitItem(ItemStack item)
|
||||||
{
|
{
|
||||||
net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
if (item == null)
|
||||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
|
||||||
MojangsonCompound compound = new MojangsonCompound();
|
|
||||||
boolean foundNegative = false;
|
|
||||||
boolean foundPositive = false;
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
String mod = modifiers.toString();
|
return false;
|
||||||
String fancy = ("{" + (mod.substring(1, mod.length() - 1).replace("{", "").replace("}", "")) + "}");
|
}
|
||||||
compound.read(fancy);
|
|
||||||
for (String key : compound.keySet())
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null)
|
||||||
|
{
|
||||||
|
Multimap<Attribute, AttributeModifier> attributes = meta.getAttributeModifiers();
|
||||||
|
if (attributes != null)
|
||||||
{
|
{
|
||||||
if (Objects.equals(key, "Amount")) //null-safe .equals()
|
Map<Attribute, Collection<AttributeModifier>> attrMap = attributes.asMap();
|
||||||
|
|
||||||
|
// For every attribute...
|
||||||
|
for (Attribute attr : attributes.keySet())
|
||||||
{
|
{
|
||||||
List<MojangsonValue> values = compound.get(key);
|
// Default values
|
||||||
for (MojangsonValue val : values)
|
boolean posInf = false;
|
||||||
|
boolean negInf = false;
|
||||||
|
|
||||||
|
// For every AttributeModifier...
|
||||||
|
for (AttributeModifier modifier : attrMap.get(attr))
|
||||||
{
|
{
|
||||||
if (val.getValue().toString().equals("Infinityd"))
|
// Are they ∞ or -∞?
|
||||||
|
if (modifier.getAmount() == Double.POSITIVE_INFINITY)
|
||||||
{
|
{
|
||||||
foundPositive = true;
|
posInf = true;
|
||||||
}
|
}
|
||||||
if (val.getValue().toString().equals("-Infinityd"))
|
else if (modifier.getAmount() == Double.NEGATIVE_INFINITY)
|
||||||
{
|
{
|
||||||
foundNegative = true;
|
negInf = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Are both values set as true?
|
||||||
|
if (posInf && negInf)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (MojangsonParseException e)
|
return false;
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return foundNegative && foundPositive;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
|
|
||||||
{
|
|
||||||
if (stack.getTag() == null)
|
|
||||||
{
|
|
||||||
stack.setTag(new NBTTagCompound());
|
|
||||||
}
|
|
||||||
NBTTagList attr = stack.getTag().getList("AttributeModifiers", 10);
|
|
||||||
if (attr == null)
|
|
||||||
{
|
|
||||||
stack.getTag().set("AttributeModifiers", new NBTTagList());
|
|
||||||
}
|
|
||||||
return stack.getTag().getList("AttributeModifiers", 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -1,13 +1,12 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -15,31 +14,21 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
|
|
||||||
public class Muter extends FreedomService
|
public class Muter extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
|
||||||
public final List<String> MUTED_PLAYERS = new ArrayList();
|
|
||||||
|
|
||||||
public Muter(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChatEvent(AsyncChatEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
@ -53,18 +42,10 @@ public class Muter extends FreedomService
|
|||||||
if (plugin.al.isAdminSync(player))
|
if (plugin.al.isAdminSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
MUTED_PLAYERS.remove(player.getName());
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fPlayer.isQuietMuted())
|
player.sendMessage(Component.text("You are muted.", NamedTextColor.RED));
|
||||||
{
|
|
||||||
FSync.playerMsg(event.getPlayer(), event.getFormat());
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,9 +81,9 @@ public class Muter extends FreedomService
|
|||||||
cmdName = command.getName().toLowerCase();
|
cmdName = command.getName().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MUTE_COMMANDS.contains(cmdName))
|
if (ConfigEntry.MUTED_BLOCKED_COMMANDS.getStringList().contains(cmdName))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
player.sendMessage(Component.text("That command is blocked while you are muted.", NamedTextColor.RED));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -113,18 +94,4 @@ public class Muter extends FreedomService
|
|||||||
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
|
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
|
|
||||||
if (MUTED_PLAYERS.contains(player.getName()))
|
|
||||||
{
|
|
||||||
playerdata.setMuted(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -9,19 +9,13 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
public class Orbiter extends FreedomService
|
public class Orbiter extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public Orbiter(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -1,27 +1,28 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.server.ServerListPingEvent;
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class ServerPing extends FreedomService
|
public class ServerPing extends FreedomService
|
||||||
{
|
{
|
||||||
|
private final Gson gson = new Gson();
|
||||||
public ServerPing(TotalFreedomMod plugin)
|
private final VersionMeta meta = gson.fromJson(new InputStreamReader(Bukkit.class.getClassLoader().getResourceAsStream("version.json")),VersionMeta.class);
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,52 +33,39 @@ public class ServerPing extends FreedomService
|
|||||||
|
|
||||||
if (plugin.bm.isIpBanned(ip))
|
if (plugin.bm.isIpBanned(ip))
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_BAN_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_BAN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LoginProcess.isLockdownEnabled())
|
if (LoginProcess.isLockdownEnabled())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_LOCKDOWN_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_LOCKDOWN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.hasWhitelist())
|
if (Bukkit.hasWhitelist())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_WHITELIST_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_WHITELIST_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_FULL_MOTD.getString()));
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_FULL_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
event.motd(FUtil.miniMessage(ConfigEntry.SERVER_MOTD.getString(), Placeholder.unparsed("version", meta.id)));
|
||||||
baseMotd = baseMotd.replace("\\n", "\n");
|
|
||||||
baseMotd = FUtil.colorize(baseMotd);
|
|
||||||
|
|
||||||
if (!ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
|
|
||||||
{
|
|
||||||
event.setMotd(baseMotd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Colorful MOTD
|
|
||||||
final StringBuilder motd = new StringBuilder();
|
|
||||||
for (String word : baseMotd.split(" "))
|
|
||||||
{
|
|
||||||
motd.append(FUtil.randomChatColor()).append(word).append(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setMotd(motd.toString().trim());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
private static class VersionMeta
|
||||||
|
{
|
||||||
|
private String id;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,348 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
|
import me.totalfreedom.totalfreedommod.api.Aggregator;
|
||||||
|
import me.totalfreedom.totalfreedommod.api.ShoppeCommons;
|
||||||
|
import me.totalfreedom.totalfreedommod.api.TFD4JCommons;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.*;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.*;
|
||||||
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.*;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
|
{
|
||||||
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
|
//
|
||||||
|
public static final BuildProperties build = new BuildProperties();
|
||||||
|
//
|
||||||
|
public static String pluginName;
|
||||||
|
public static String pluginVersion;
|
||||||
|
private static TotalFreedomMod plugin;
|
||||||
|
//
|
||||||
|
public MainConfig config;
|
||||||
|
//
|
||||||
|
// Service Handler
|
||||||
|
public FreedomServiceHandler fsh;
|
||||||
|
// Command Loader
|
||||||
|
public CommandLoader cl;
|
||||||
|
// Services
|
||||||
|
public WorldManager wm;
|
||||||
|
public AdminList al;
|
||||||
|
public RankManager rm;
|
||||||
|
public CommandBlocker cb;
|
||||||
|
public EventBlocker eb;
|
||||||
|
public BlockBlocker bb;
|
||||||
|
public MobBlocker mb;
|
||||||
|
public InteractBlocker ib;
|
||||||
|
public PotionBlocker pb;
|
||||||
|
public LoginProcess lp;
|
||||||
|
public AntiNuke nu;
|
||||||
|
public AntiSpam as;
|
||||||
|
public PlayerList pl;
|
||||||
|
public ShoppeCommons sh;
|
||||||
|
public SQLite sql;
|
||||||
|
public Announcer an;
|
||||||
|
public ChatManager cm;
|
||||||
|
public TFD4JCommons dc;
|
||||||
|
public Aggregator ag;
|
||||||
|
public PunishmentList pul;
|
||||||
|
public BanManager bm;
|
||||||
|
public IndefiniteBanList im;
|
||||||
|
public GameRuleHandler gr;
|
||||||
|
public CommandSpy cs;
|
||||||
|
public Cager ca;
|
||||||
|
public Freezer fm;
|
||||||
|
public EditBlocker ebl;
|
||||||
|
public PVPBlocker pbl;
|
||||||
|
public Orbiter or;
|
||||||
|
public Muter mu;
|
||||||
|
public Fuckoff fo;
|
||||||
|
public AutoKick ak;
|
||||||
|
public AutoEject ae;
|
||||||
|
public Monitors mo;
|
||||||
|
public MovementValidator mv;
|
||||||
|
public ServerPing sp;
|
||||||
|
public ItemFun it;
|
||||||
|
public Landminer lm;
|
||||||
|
public MP44 mp;
|
||||||
|
public Jumppads jp;
|
||||||
|
public Trailer tr;
|
||||||
|
public HTTPDaemon hd;
|
||||||
|
public WorldRestrictions wr;
|
||||||
|
public EntityWiper ew;
|
||||||
|
public VanishHandler vh;
|
||||||
|
//
|
||||||
|
// Bridges
|
||||||
|
public BukkitTelnetBridge btb;
|
||||||
|
public EssentialsBridge esb;
|
||||||
|
public LibsDisguisesBridge ldb;
|
||||||
|
public CoreProtectBridge cpb;
|
||||||
|
public WorldEditBridge web;
|
||||||
|
public LuckPermsBridge lpb;
|
||||||
|
|
||||||
|
public static TotalFreedomMod getPlugin()
|
||||||
|
{
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TotalFreedomMod plugin()
|
||||||
|
{
|
||||||
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
||||||
|
{
|
||||||
|
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||||
|
{
|
||||||
|
return (TotalFreedomMod) plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad()
|
||||||
|
{
|
||||||
|
plugin = this;
|
||||||
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
||||||
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
|
FLog.setPluginLogger(plugin.getLogger());
|
||||||
|
FLog.setServerLogger(getServer().getLogger());
|
||||||
|
|
||||||
|
build.load(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
FLog.info("Created by Madgeek1450 and Prozza");
|
||||||
|
FLog.info("Version " + build.version);
|
||||||
|
FLog.info("Compiled " + build.date + " by " + build.author);
|
||||||
|
|
||||||
|
final MethodTimer timer = new MethodTimer();
|
||||||
|
timer.start();
|
||||||
|
|
||||||
|
// Delete unused files
|
||||||
|
FUtil.deleteCoreDumps();
|
||||||
|
FUtil.deleteFolder(new File("./_deleteme"));
|
||||||
|
|
||||||
|
fsh = new FreedomServiceHandler();
|
||||||
|
|
||||||
|
config = new MainConfig();
|
||||||
|
|
||||||
|
if (FUtil.inDeveloperMode())
|
||||||
|
{
|
||||||
|
FLog.debug("Developer mode enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
cl = new CommandLoader();
|
||||||
|
cl.loadCommands();
|
||||||
|
|
||||||
|
BackupManager backups = new BackupManager();
|
||||||
|
backups.createAllBackups();
|
||||||
|
|
||||||
|
mv = new MovementValidator();
|
||||||
|
sp = new ServerPing();
|
||||||
|
|
||||||
|
new Initializer();
|
||||||
|
|
||||||
|
fsh.startServices();
|
||||||
|
|
||||||
|
FLog.info("Started " + fsh.getServiceAmount() + " services.");
|
||||||
|
|
||||||
|
timer.update();
|
||||||
|
FLog.info("Version " + pluginVersion + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
|
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
||||||
|
new Metrics(this, 2966);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
// Stop services and bridges
|
||||||
|
fsh.stopServices();
|
||||||
|
|
||||||
|
getServer().getScheduler().cancelTasks(plugin);
|
||||||
|
|
||||||
|
FLog.info("Plugin disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id)
|
||||||
|
{
|
||||||
|
return new CleanroomChunkGenerator(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerDiscord()
|
||||||
|
{
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("TFD4J"))
|
||||||
|
{
|
||||||
|
dc = ag.getDiscordContext().getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerShoppe()
|
||||||
|
{
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("TF-Shoppe"))
|
||||||
|
{
|
||||||
|
sh = ag.getShoppeContext().getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BuildProperties
|
||||||
|
{
|
||||||
|
public String author;
|
||||||
|
public String codename;
|
||||||
|
public String version;
|
||||||
|
public String number;
|
||||||
|
public String date;
|
||||||
|
public String head;
|
||||||
|
|
||||||
|
public void load(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Properties props;
|
||||||
|
final String unknown = "unknown";
|
||||||
|
|
||||||
|
try (InputStream in = plugin.getResource("build.properties"))
|
||||||
|
{
|
||||||
|
props = new Properties();
|
||||||
|
props.load(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
author = props.getProperty("buildAuthor", unknown);
|
||||||
|
codename = props.getProperty("buildCodeName", unknown);
|
||||||
|
version = props.getProperty("buildVersion", pluginVersion);
|
||||||
|
number = props.getProperty("buildNumber", "1");
|
||||||
|
date = props.getProperty("buildDate", unknown);
|
||||||
|
head = props.getProperty("buildHead", unknown).replace("${git.commit.id.abbrev}", unknown);
|
||||||
|
} catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Could not load build properties! Did you compile with NetBeans/Maven?");
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formattedVersion()
|
||||||
|
{
|
||||||
|
return pluginVersion + "." + number + " (" + head + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is provided to please Codacy.
|
||||||
|
*/
|
||||||
|
private final class Initializer
|
||||||
|
{
|
||||||
|
public Initializer()
|
||||||
|
{
|
||||||
|
initServices();
|
||||||
|
initAdminUtils();
|
||||||
|
initBridges();
|
||||||
|
initFun();
|
||||||
|
initHTTPD();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initServices()
|
||||||
|
{
|
||||||
|
// Start services
|
||||||
|
wm = new WorldManager();
|
||||||
|
sql = new SQLite();
|
||||||
|
al = new AdminList();
|
||||||
|
rm = new RankManager();
|
||||||
|
cb = new CommandBlocker();
|
||||||
|
eb = new EventBlocker();
|
||||||
|
bb = new BlockBlocker();
|
||||||
|
mb = new MobBlocker();
|
||||||
|
ib = new InteractBlocker();
|
||||||
|
pb = new PotionBlocker();
|
||||||
|
lp = new LoginProcess();
|
||||||
|
nu = new AntiNuke();
|
||||||
|
as = new AntiSpam();
|
||||||
|
wr = new WorldRestrictions();
|
||||||
|
pl = new PlayerList();
|
||||||
|
ag = new Aggregator();
|
||||||
|
|
||||||
|
an = new Announcer();
|
||||||
|
cm = new ChatManager();
|
||||||
|
|
||||||
|
|
||||||
|
pul = new PunishmentList();
|
||||||
|
bm = new BanManager();
|
||||||
|
im = new IndefiniteBanList();
|
||||||
|
gr = new GameRuleHandler();
|
||||||
|
ew = new EntityWiper();
|
||||||
|
vh = new VanishHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initAdminUtils()
|
||||||
|
{
|
||||||
|
// Single admin utils
|
||||||
|
cs = new CommandSpy();
|
||||||
|
ca = new Cager();
|
||||||
|
fm = new Freezer();
|
||||||
|
or = new Orbiter();
|
||||||
|
mu = new Muter();
|
||||||
|
ebl = new EditBlocker();
|
||||||
|
pbl = new PVPBlocker();
|
||||||
|
fo = new Fuckoff();
|
||||||
|
ak = new AutoKick();
|
||||||
|
ae = new AutoEject();
|
||||||
|
mo = new Monitors();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initBridges()
|
||||||
|
{
|
||||||
|
// Start bridges
|
||||||
|
btb = new BukkitTelnetBridge();
|
||||||
|
cpb = new CoreProtectBridge();
|
||||||
|
esb = new EssentialsBridge();
|
||||||
|
ldb = new LibsDisguisesBridge();
|
||||||
|
web = new WorldEditBridge();
|
||||||
|
lpb = new LuckPermsBridge();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initFun()
|
||||||
|
{
|
||||||
|
// Fun
|
||||||
|
it = new ItemFun();
|
||||||
|
lm = new Landminer();
|
||||||
|
mp = new MP44();
|
||||||
|
jp = new Jumppads();
|
||||||
|
tr = new Trailer();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initHTTPD()
|
||||||
|
{
|
||||||
|
// HTTPD
|
||||||
|
hd = new HTTPDaemon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,70 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class VanishHandler extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
server.getOnlinePlayers().stream().filter(pl -> !plugin.al.isAdmin(player)
|
||||||
|
&& plugin.al.isVanished(pl.getUniqueId())).forEach(pl -> player.hidePlayer(plugin, pl));
|
||||||
|
|
||||||
|
server.getOnlinePlayers().stream().filter(pl -> !plugin.al.isAdmin(pl)
|
||||||
|
&& plugin.al.isVanished(player.getUniqueId())).forEach(pl -> pl.hidePlayer(plugin, player));
|
||||||
|
|
||||||
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
plugin.esb.setVanished(player.getName(), true);
|
||||||
|
plugin.cm.messageAllAdmins("<yellow><player> has joined silently.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
event.joinMessage(null);
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
player.sendActionBar(FUtil.miniMessage("<gold>You are hidden from other players."));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 0L, 4L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLeave(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.al.isVanished(player.getUniqueId()))
|
||||||
|
{
|
||||||
|
event.quitMessage(null);
|
||||||
|
plugin.cm.messageAllAdmins("<yellow><player> has left silently.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,247 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class Admin
|
||||||
|
{
|
||||||
|
private final List<String> ips = new ArrayList<>();
|
||||||
|
private UUID uuid;
|
||||||
|
private boolean active = true;
|
||||||
|
private DisplayableGroup rank = GroupProvider.ADMIN.getGroup();
|
||||||
|
private Date lastLogin = new Date();
|
||||||
|
private Boolean commandSpy = false;
|
||||||
|
private Boolean potionSpy = false;
|
||||||
|
private String acFormat = null;
|
||||||
|
|
||||||
|
public Admin(Player player)
|
||||||
|
{
|
||||||
|
uuid = player.getUniqueId();
|
||||||
|
this.ips.add(FUtil.getIp(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin(ResultSet resultSet)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.uuid = UUID.fromString(resultSet.getString("uuid"));
|
||||||
|
this.active = resultSet.getBoolean("active");
|
||||||
|
this.rank = GroupProvider.fromArgument(resultSet.getString("rank")).getGroup();
|
||||||
|
this.ips.clear();
|
||||||
|
this.ips.addAll(FUtil.stringToList(resultSet.getString("ips")));
|
||||||
|
this.lastLogin = new Date(resultSet.getLong("last_login"));
|
||||||
|
this.commandSpy = resultSet.getBoolean("command_spy");
|
||||||
|
this.potionSpy = resultSet.getBoolean("potion_spy");
|
||||||
|
this.acFormat = resultSet.getString("ac_format");
|
||||||
|
} catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load admin: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
|
output.append("Admin: ").append(getName() != null ? getName() : getUuid().toString()).append("\n")
|
||||||
|
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
||||||
|
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
||||||
|
.append("- Rank: ").append(rank.getName()).append("\n")
|
||||||
|
.append("- Is Active: ").append(active).append("\n")
|
||||||
|
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||||
|
.append("- Admin Chat Format: ").append(acFormat).append("\n");
|
||||||
|
|
||||||
|
return output.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Object> toSQLStorable()
|
||||||
|
{
|
||||||
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
map.put("uuid", uuid.toString());
|
||||||
|
map.put("active", active);
|
||||||
|
map.put("rank", rank.toString());
|
||||||
|
map.put("ips", FUtil.listToString(ips));
|
||||||
|
map.put("last_login", lastLogin.getTime());
|
||||||
|
map.put("command_spy", commandSpy);
|
||||||
|
map.put("potion_spy", potionSpy);
|
||||||
|
map.put("ac_format", acFormat);
|
||||||
|
return map;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Util IP methods
|
||||||
|
public void addIp(String ip)
|
||||||
|
{
|
||||||
|
if (!ips.contains(ip))
|
||||||
|
{
|
||||||
|
ips.add(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addIps(List<String> ips)
|
||||||
|
{
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
addIp(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeIp(String ip)
|
||||||
|
{
|
||||||
|
ips.remove(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearIPs()
|
||||||
|
{
|
||||||
|
ips.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return uuid != null
|
||||||
|
&& rank != null
|
||||||
|
&& !ips.isEmpty()
|
||||||
|
&& lastLogin != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid()
|
||||||
|
{
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return Bukkit.getOfflinePlayer(uuid).getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive()
|
||||||
|
{
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(boolean active)
|
||||||
|
{
|
||||||
|
this.active = active;
|
||||||
|
|
||||||
|
final TotalFreedomMod plugin = TotalFreedomMod.getPlugin();
|
||||||
|
|
||||||
|
// Avoiding stupid NPE compiler warnings
|
||||||
|
if (plugin == null)
|
||||||
|
{
|
||||||
|
Bukkit.getLogger().severe("The plugin is null!! This is a major issue and WILL break the plugin!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
setActiveSplitWorkToReduceComplexity(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setActiveSplitWorkToReduceComplexity(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
if (getRank().isAtLeast(GroupProvider.ADMIN.getGroup()))
|
||||||
|
{
|
||||||
|
if (plugin.btb != null)
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure admins don't have admin functionality when removed (FS-222)
|
||||||
|
AdminList.vanished.remove(getUuid());
|
||||||
|
|
||||||
|
if (plugin.esb != null)
|
||||||
|
{
|
||||||
|
plugin.esb.setVanished(getName(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
setCommandSpy(false);
|
||||||
|
setPotionSpy(false);
|
||||||
|
|
||||||
|
Server server = Bukkit.getServer();
|
||||||
|
Player player = server.getPlayer(getUuid());
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
// Update chats
|
||||||
|
FPlayer freedomPlayer = plugin.pl.getPlayer(player);
|
||||||
|
freedomPlayer.removeAdminFunctionality();
|
||||||
|
|
||||||
|
// Disable vanish
|
||||||
|
for (Player player1 : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
player1.showPlayer(plugin, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DisplayableGroup getRank()
|
||||||
|
{
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRank(DisplayableGroup rank)
|
||||||
|
{
|
||||||
|
this.rank = rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastLogin()
|
||||||
|
{
|
||||||
|
return lastLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastLogin(Date lastLogin)
|
||||||
|
{
|
||||||
|
this.lastLogin = lastLogin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getCommandSpy()
|
||||||
|
{
|
||||||
|
return commandSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommandSpy(Boolean commandSpy)
|
||||||
|
{
|
||||||
|
this.commandSpy = commandSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getPotionSpy()
|
||||||
|
{
|
||||||
|
return potionSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPotionSpy(Boolean potionSpy)
|
||||||
|
{
|
||||||
|
this.potionSpy = potionSpy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAcFormat()
|
||||||
|
{
|
||||||
|
return acFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAcFormat(String acFormat)
|
||||||
|
{
|
||||||
|
this.acFormat = acFormat;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,328 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
public class AdminList extends FreedomService
|
||||||
|
{
|
||||||
|
public static final List<UUID> vanished = new ArrayList<>();
|
||||||
|
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||||
|
// Only active admins below
|
||||||
|
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||||
|
private final Map<UUID, Admin> uuidTable = Maps.newHashMap();
|
||||||
|
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
||||||
|
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
load();
|
||||||
|
deactivateOldEntries(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
// This does nothing. This comment is here to prevent SonarLint from complaining.
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load()
|
||||||
|
{
|
||||||
|
allAdmins.clear();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet adminSet = plugin.sql.getAdminList();
|
||||||
|
while (adminSet.next())
|
||||||
|
{
|
||||||
|
tryAddAdmin(adminSet);
|
||||||
|
}
|
||||||
|
} catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load admin list: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTables();
|
||||||
|
FLog.info("Loaded " + allAdmins.size() + " admins (" + uuidTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tryAddAdmin(ResultSet adminSet) throws SQLException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Admin admin = new Admin(adminSet);
|
||||||
|
allAdmins.add(admin);
|
||||||
|
} catch (Throwable ex)
|
||||||
|
{
|
||||||
|
FLog.warning("An error occurred whilst reading the admin entry at row #" + adminSet.getRow());
|
||||||
|
FLog.warning(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void messageAllAdmins(Component message)
|
||||||
|
{
|
||||||
|
server.getOnlinePlayers().stream().filter(this::isAdmin).forEach(player -> player.sendMessage(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void potionSpyMessage(String message)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
Admin admin = getAdmin(player.getPlayer());
|
||||||
|
if (isAdmin(player) && admin.getPotionSpy())
|
||||||
|
{
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isAdminSync(CommandSender sender)
|
||||||
|
{
|
||||||
|
return isAdmin(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin admin = getAdmin((Player) sender);
|
||||||
|
|
||||||
|
return admin != null && admin.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cast to OfflinePlayer
|
||||||
|
public boolean isAdmin(Player player)
|
||||||
|
{
|
||||||
|
return isAdmin((OfflinePlayer) player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdmin(OfflinePlayer player)
|
||||||
|
{
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin admin = getAdmin(player);
|
||||||
|
|
||||||
|
return admin != null && admin.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeniorAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
Admin admin = getAdmin(sender);
|
||||||
|
if (admin == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return admin.getRank().getLuckPermsGroup().getWeight().orElse(0)
|
||||||
|
>= GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup().getWeight().orElse(1);
|
||||||
|
// We don't want this to return true if there's no group weight available.
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (sender instanceof Player player)
|
||||||
|
{
|
||||||
|
return getAdmin(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getEntryByName(sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getAdmin(OfflinePlayer player)
|
||||||
|
{
|
||||||
|
return getEntryByUuid(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getEntryByUuid(UUID uuid)
|
||||||
|
{
|
||||||
|
return uuidTable.get(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getEntryByName(String name)
|
||||||
|
{
|
||||||
|
return nameTable.get(name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getEntryByIp(String ip)
|
||||||
|
{
|
||||||
|
return ipTable.get(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
// To cast against OfflinePlayer
|
||||||
|
public Admin getAdmin(Player player)
|
||||||
|
{
|
||||||
|
return getAdmin((OfflinePlayer) player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLastLogin(Player player)
|
||||||
|
{
|
||||||
|
final Admin admin = getAdmin(player);
|
||||||
|
if (admin == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
admin.setLastLogin(new Date());
|
||||||
|
save(admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAdmin(Admin admin)
|
||||||
|
{
|
||||||
|
if (!admin.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store admin, update views
|
||||||
|
allAdmins.add(admin);
|
||||||
|
updateTables();
|
||||||
|
|
||||||
|
// Save admin
|
||||||
|
plugin.sql.addAdmin(admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeAdmin(Admin admin)
|
||||||
|
{
|
||||||
|
if (admin.getRank().isAtLeast(GroupProvider.ADMIN.getGroup()) && (plugin.btb != null))
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(admin.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove admin, update views
|
||||||
|
if (!allAdmins.remove(admin))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
updateTables();
|
||||||
|
|
||||||
|
// Unsave admin
|
||||||
|
plugin.sql.removeAdmin(admin);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTables()
|
||||||
|
{
|
||||||
|
activeAdmins.clear();
|
||||||
|
uuidTable.clear();
|
||||||
|
nameTable.clear();
|
||||||
|
ipTable.clear();
|
||||||
|
|
||||||
|
for (Admin admin : allAdmins)
|
||||||
|
{
|
||||||
|
if (!admin.isActive())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
activeAdmins.add(admin);
|
||||||
|
uuidTable.put(admin.getUuid(), admin);
|
||||||
|
if (admin.getName() != null)
|
||||||
|
{
|
||||||
|
nameTable.put(admin.getName().toLowerCase(), admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String ip : admin.getIps())
|
||||||
|
{
|
||||||
|
ipTable.put(ip, admin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getAdminNames()
|
||||||
|
{
|
||||||
|
return nameTable.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getAdminIps()
|
||||||
|
{
|
||||||
|
return ipTable.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save(Admin admin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet currentSave = plugin.sql.getAdminByUuid(admin.getUuid());
|
||||||
|
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
||||||
|
{
|
||||||
|
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
||||||
|
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null || entry.getValue() == null)
|
||||||
|
{
|
||||||
|
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to save admin: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deactivateOldEntries(boolean verbose)
|
||||||
|
{
|
||||||
|
allAdmins.stream()
|
||||||
|
.filter(admin -> admin.isActive() && !admin.getRank().isAtLeast(GroupProvider.SENIOR_ADMIN.getGroup()))
|
||||||
|
.forEach(admin ->
|
||||||
|
{
|
||||||
|
final Date lastLogin = admin.getLastLogin();
|
||||||
|
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||||
|
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||||
|
}
|
||||||
|
admin.setActive(false);
|
||||||
|
save(admin);
|
||||||
|
});
|
||||||
|
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVanished(UUID uuid)
|
||||||
|
{
|
||||||
|
return vanished.contains(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Admin> getAllAdmins()
|
||||||
|
{
|
||||||
|
return allAdmins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Admin> getActiveAdmins()
|
||||||
|
{
|
||||||
|
return activeAdmins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Admin> getNameTable()
|
||||||
|
{
|
||||||
|
return nameTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Admin> getIpTable()
|
||||||
|
{
|
||||||
|
return ipTable;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.api;
|
||||||
|
|
||||||
|
public class Aggregator
|
||||||
|
{
|
||||||
|
private Context<TFD4JCommons> discord;
|
||||||
|
private Context<ShoppeCommons> shoppe;
|
||||||
|
|
||||||
|
public Context<TFD4JCommons> getDiscordContext()
|
||||||
|
{
|
||||||
|
return discord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscordContext(Context<TFD4JCommons> discord)
|
||||||
|
{
|
||||||
|
this.discord = discord;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Context<ShoppeCommons> getShoppeContext()
|
||||||
|
{
|
||||||
|
return shoppe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShoppeContext(Context<ShoppeCommons> shoppe)
|
||||||
|
{
|
||||||
|
this.shoppe = shoppe;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.api;
|
||||||
|
|
||||||
|
public class Context<T>
|
||||||
|
{
|
||||||
|
private final T value;
|
||||||
|
|
||||||
|
public Context(T value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getValue()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.api;
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface Interpolator
|
||||||
|
{
|
||||||
|
double[] interpolate(double from, double to, int max);
|
||||||
|
}
|
@ -0,0 +1,116 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.api;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
|
||||||
|
public enum ShopItem
|
||||||
|
{
|
||||||
|
GRAPPLING_HOOK("Grappling Hook", Material.FISHING_ROD, 10, ConfigEntry.SHOP_PRICES_GRAPPLING_HOOK, ChatColor.GREEN, "grapplingHook", "/grapplinghook"),
|
||||||
|
LIGHTNING_ROD("Lightning Rod", Material.BLAZE_ROD, 12, ConfigEntry.SHOP_PRICES_LIGHTNING_ROD, ChatColor.LIGHT_PURPLE, "lightningRod", "/lightningrod"),
|
||||||
|
FIRE_BALL("Fire Ball", Material.FIRE_CHARGE, 14, ConfigEntry.SHOP_PRICES_FIRE_BALL, ChatColor.RED, "fireBall", "/fireball"),
|
||||||
|
RIDEABLE_PEARL("Rideable Ender Pearl", Material.ENDER_PEARL, 16, ConfigEntry.SHOP_PRICES_RIDEABLE_PEARL, ChatColor.DARK_PURPLE, "rideablePearl", "/rideablepearl"),
|
||||||
|
STACKING_POTATO("Stacking Potato", Material.POTATO, 19, ConfigEntry.SHOP_PRICES_STACKING_POTATO, ChatColor.YELLOW, "stackingPotato", "/stackingpotato"),
|
||||||
|
CLOWN_FISH("Clown Fish", Material.TROPICAL_FISH, 21, ConfigEntry.SHOP_PRICES_CLOWN_FISH, ChatColor.GOLD, "clownFish", "/clownfish"),
|
||||||
|
LOGIN_MESSAGES("Login Messages", Material.NAME_TAG, 23, ConfigEntry.SHOP_PRICES_LOGIN_MESSAGES, ChatColor.DARK_GREEN, "loginMessages", "/loginmessage"),
|
||||||
|
RAINBOW_TRAIL("Rainbow Trail", Material.RED_WOOL, 25, ConfigEntry.SHOP_PRICES_RAINBOW_TRAIL, ChatColor.DARK_RED, "rainbowTrail", "/trail");
|
||||||
|
|
||||||
|
/*
|
||||||
|
Shop GUI Layout:
|
||||||
|
|
||||||
|
Dimensions: 9x4 = 36
|
||||||
|
Key:
|
||||||
|
g = Grappling Hook,
|
||||||
|
l = Lightning Rod
|
||||||
|
f = Fire Ball
|
||||||
|
r = Rideable Ender Pearl
|
||||||
|
s = Stacking Potato
|
||||||
|
c = Clown Fish
|
||||||
|
x = Login Messages
|
||||||
|
t = Rainbow Trail
|
||||||
|
$ = Coins
|
||||||
|
|
||||||
|
---------
|
||||||
|
-g-l-f-r-
|
||||||
|
-s-c-x-t-
|
||||||
|
--------$
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private final Material icon;
|
||||||
|
|
||||||
|
private final int slot;
|
||||||
|
private final ConfigEntry cost;
|
||||||
|
|
||||||
|
private final ChatColor color;
|
||||||
|
|
||||||
|
private final String dataName;
|
||||||
|
|
||||||
|
private final String command;
|
||||||
|
|
||||||
|
ShopItem(String name, Material icon, int slot, ConfigEntry cost, ChatColor color, String dataName, String command)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.icon = icon;
|
||||||
|
this.slot = slot;
|
||||||
|
this.cost = cost;
|
||||||
|
this.color = color;
|
||||||
|
this.dataName = dataName;
|
||||||
|
this.command = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ShopItem findItem(String string)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return ShopItem.valueOf(string.toUpperCase());
|
||||||
|
}
|
||||||
|
catch (Exception ignored)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColoredName()
|
||||||
|
{
|
||||||
|
return color + name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCost()
|
||||||
|
{
|
||||||
|
return cost.getInteger();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getIcon()
|
||||||
|
{
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSlot()
|
||||||
|
{
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getColor()
|
||||||
|
{
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDataName()
|
||||||
|
{
|
||||||
|
return dataName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCommand()
|
||||||
|
{
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.api;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
|
||||||
|
public interface ShoppeCommons
|
||||||
|
{
|
||||||
|
|
||||||
|
int getCoinsPerReactionWin();
|
||||||
|
|
||||||
|
void startReactionTimer();
|
||||||
|
|
||||||
|
void forceStartReaction();
|
||||||
|
|
||||||
|
void startReaction();
|
||||||
|
|
||||||
|
void endReaction(String winner);
|
||||||
|
|
||||||
|
String getShopPrefix();
|
||||||
|
|
||||||
|
String getShopTitle();
|
||||||
|
|
||||||
|
Inventory generateShopGUI(PlayerData playerData);
|
||||||
|
|
||||||
|
Inventory generateLoginMessageGUI(Player player);
|
||||||
|
|
||||||
|
boolean isRealItem(PlayerData data, ShopItem shopItem, PlayerInventory inventory, ItemStack realItem);
|
||||||
|
|
||||||
|
boolean isRealItem(PlayerData data, ShopItem shopItem, ItemStack givenItem, ItemStack realItem);
|
||||||
|
|
||||||
|
ItemStack getLightningRod();
|
||||||
|
|
||||||
|
ItemStack getGrapplingHook();
|
||||||
|
|
||||||
|
ItemStack getFireBall();
|
||||||
|
|
||||||
|
ItemStack getRideablePearl();
|
||||||
|
|
||||||
|
ItemStack getStackingPotato();
|
||||||
|
|
||||||
|
ItemStack getClownFish();
|
||||||
|
|
||||||
|
boolean canAfford(int price, int coins);
|
||||||
|
|
||||||
|
int amountNeeded(int price, int coins);
|
||||||
|
|
||||||
|
ItemStack shopGUIItem(ShopItem item, PlayerData data);
|
||||||
|
|
||||||
|
ShopItem getShopItem(int slot);
|
||||||
|
|
||||||
|
String getReactionString();
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.api;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface TFD4JCommons
|
||||||
|
{
|
||||||
|
void messageAdminChatChannel(String message);
|
||||||
|
|
||||||
|
void clearQueue();
|
||||||
|
|
||||||
|
void messageChatChannel(String message, boolean system);
|
||||||
|
|
||||||
|
boolean syncRoles(Admin admin, String id);
|
||||||
|
|
||||||
|
String getCode(PlayerData playerData);
|
||||||
|
|
||||||
|
String generateCode(int size);
|
||||||
|
|
||||||
|
Map<String, PlayerData> getLinkCodes();
|
||||||
|
|
||||||
|
String formatBotTag();
|
||||||
|
|
||||||
|
boolean sendReportOffline(Player reporter, OfflinePlayer reported, String reason);
|
||||||
|
|
||||||
|
boolean sendReport(Player reporter, Player reported, String reason);
|
||||||
|
|
||||||
|
boolean isEnabled();
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.api.event;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import net.kyori.adventure.key.Key;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class AdminChatEvent extends Event
|
||||||
|
{
|
||||||
|
private static HandlerList handlerList = new HandlerList();
|
||||||
|
//--
|
||||||
|
private Key identifier;
|
||||||
|
private Component prefix = Component.empty();
|
||||||
|
private Component name;
|
||||||
|
private Displayable displayable;
|
||||||
|
private Component message;
|
||||||
|
|
||||||
|
public AdminChatEvent(Key identifier, Component prefix, Component name, Displayable rank, Component message, boolean async)
|
||||||
|
{
|
||||||
|
super(async);
|
||||||
|
this.identifier = identifier;
|
||||||
|
this.prefix = prefix;
|
||||||
|
this.name = name;
|
||||||
|
this.displayable = rank;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AdminChatEvent(Component name, Displayable rank, Component message, boolean async)
|
||||||
|
{
|
||||||
|
super(async);
|
||||||
|
this.identifier = Key.key("tfm", "default");
|
||||||
|
this.name = name;
|
||||||
|
this.displayable = rank;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList()
|
||||||
|
{
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers()
|
||||||
|
{
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Key getIdentifier()
|
||||||
|
{
|
||||||
|
return identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getPrefix()
|
||||||
|
{
|
||||||
|
return prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Displayable getDisplayable()
|
||||||
|
{
|
||||||
|
return displayable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
@ -1,78 +1,69 @@
|
|||||||
package me.totalfreedom.totalfreedommod.banning;
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.Arrays;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import lombok.Getter;
|
import java.util.UUID;
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
public class Ban
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
|
||||||
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String username = null;
|
|
||||||
@Getter
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
@Getter
|
private String username = null;
|
||||||
@Setter
|
private UUID uuid = null;
|
||||||
private String by = null;
|
private String by = null;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Date at = null;
|
private Date at = null;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private long expiryUnix = -1;
|
private long expiryUnix = -1;
|
||||||
|
|
||||||
public Ban()
|
public Ban()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
|
public Ban(String username, UUID uuid, String ip, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this(username,
|
this(username,
|
||||||
new String[]
|
uuid,
|
||||||
{
|
Collections.singletonList(ip),
|
||||||
ip
|
|
||||||
},
|
|
||||||
by,
|
by,
|
||||||
at,
|
at,
|
||||||
expire,
|
expire,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String[] ips, String by, Date at, Date expire, String reason)
|
public Ban(String username, UUID uuid, List<String> ips, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
this.uuid = uuid;
|
||||||
if (ips != null)
|
if (ips != null)
|
||||||
{
|
{
|
||||||
this.ips.addAll(Arrays.asList(ips));
|
this.ips.addAll(ips);
|
||||||
}
|
}
|
||||||
dedupeIps();
|
dedupeIps();
|
||||||
this.by = by;
|
this.by = by;
|
||||||
this.at = at;
|
this.at = at;
|
||||||
|
if (expire == null)
|
||||||
|
{
|
||||||
|
expire = FUtil.parseDateOffset("24h");
|
||||||
|
}
|
||||||
this.expiryUnix = FUtil.getUnixTime(expire);
|
this.expiryUnix = FUtil.getUnixTime(expire);
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
@ -86,15 +77,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, new String[]
|
return new Ban(null, null, Collections.singletonList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
{
|
|
||||||
Ips.getIp(player)
|
|
||||||
}, by.getName(), Date.from(Instant.now()), expiry, reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
return new Ban(null, null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -107,7 +95,8 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player,
|
return new Ban(player,
|
||||||
(String[])null,
|
null,
|
||||||
|
new ArrayList<>(),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
@ -124,21 +113,17 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
Ips.getIp(player),
|
player.getUniqueId(),
|
||||||
|
FUtil.getIp(player),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
public static SimpleDateFormat getDateFormat()
|
||||||
{
|
{
|
||||||
return new Ban(player.getName(),
|
return DATE_FORMAT;
|
||||||
FUtil.getFuzzyIp(Ips.getIp(player)),
|
|
||||||
by.getName(),
|
|
||||||
Date.from(Instant.now()),
|
|
||||||
expiry,
|
|
||||||
reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasUsername()
|
public boolean hasUsername()
|
||||||
@ -146,6 +131,11 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return username != null && !username.isEmpty();
|
return username != null && !username.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasUUID()
|
||||||
|
{
|
||||||
|
return uuid != null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addIp(String ip)
|
public boolean addIp(String ip)
|
||||||
{
|
{
|
||||||
return ips.add(ip);
|
return ips.add(ip);
|
||||||
@ -168,14 +158,27 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
public boolean isExpired()
|
public boolean isExpired()
|
||||||
{
|
{
|
||||||
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
return hasExpiry() && FUtil.getUnixDate(expiryUnix).before(new Date(FUtil.getUnixTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String bakeKickMessage(String ip)
|
public String bakeKickMessage()
|
||||||
{
|
{
|
||||||
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
||||||
|
|
||||||
message.append(!hasUsername() ? "r IP address is" : " are").append(" temporarily banned from this server.");
|
if (!hasUsername())
|
||||||
|
{
|
||||||
|
message.append("r IP address is");
|
||||||
|
}
|
||||||
|
else if (!hasIps())
|
||||||
|
{
|
||||||
|
message.append("r username is");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message.append(" are");
|
||||||
|
}
|
||||||
|
|
||||||
|
message.append(" temporarily banned from this server.");
|
||||||
message.append("\nAppeal at ").append(ChatColor.BLUE)
|
message.append("\nAppeal at ").append(ChatColor.BLUE)
|
||||||
.append(ConfigEntry.SERVER_BAN_URL.getString());
|
.append(ConfigEntry.SERVER_BAN_URL.getString());
|
||||||
|
|
||||||
@ -203,9 +206,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
message.append("\n").append(ChatColor.RED).append("IP Address: ").append(ChatColor.GOLD)
|
|
||||||
.append(ip);
|
|
||||||
|
|
||||||
return message.toString();
|
return message.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,59 +237,76 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
|
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int hash = 7;
|
|
||||||
hash = 79 * hash + (this.username != null ? this.username.toLowerCase().hashCode() : 0);
|
|
||||||
hash = 79 * hash + (this.ips != null ? this.ips.hashCode() : 0);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
this.username = cs.getString("username", null);
|
|
||||||
this.ips.clear();
|
|
||||||
this.ips.addAll(cs.getStringList("ips"));
|
|
||||||
this.by = cs.getString("by", null);
|
|
||||||
this.at = FUtil.stringToDate(cs.getString("at", null));
|
|
||||||
this.reason = cs.getString("reason", null);
|
|
||||||
this.expiryUnix = cs.getLong("expiry_unix", 0);
|
|
||||||
dedupeIps();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
dedupeIps();
|
|
||||||
cs.set("username", username);
|
|
||||||
cs.set("ips", ips.isEmpty() ? null : ips);
|
|
||||||
cs.set("by", by);
|
|
||||||
cs.set("at", FUtil.dateToString(at));
|
|
||||||
cs.set("reason", reason);
|
|
||||||
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return username != null || !ips.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dedupeIps()
|
private void dedupeIps()
|
||||||
{
|
{
|
||||||
|
|
||||||
Set<String> uniqueIps = new HashSet<>();
|
Set<String> uniqueIps = new HashSet<>();
|
||||||
|
|
||||||
Iterator<String> it = ips.iterator();
|
//Fancy Collections.removeIf lets you do all that while loop work in one lambda.
|
||||||
while (it.hasNext())
|
ips.removeIf(s -> !uniqueIps.add(s));
|
||||||
{
|
|
||||||
if (!uniqueIps.add(it.next()))
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername()
|
||||||
|
{
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username)
|
||||||
|
{
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid()
|
||||||
|
{
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(UUID uuid)
|
||||||
|
{
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBy()
|
||||||
|
{
|
||||||
|
return by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBy(String by)
|
||||||
|
{
|
||||||
|
this.by = by;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getAt()
|
||||||
|
{
|
||||||
|
return at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAt(Date at)
|
||||||
|
{
|
||||||
|
this.at = at;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason)
|
||||||
|
{
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiryUnix()
|
||||||
|
{
|
||||||
|
return expiryUnix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiryUnix(long expiryUnix)
|
||||||
|
{
|
||||||
|
this.expiryUnix = expiryUnix;
|
||||||
|
}
|
||||||
|
}
|
@ -1,22 +1,20 @@
|
|||||||
package me.totalfreedom.totalfreedommod.banning;
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -27,62 +25,53 @@ public class BanManager extends FreedomService
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final Set<Ban> bans = Sets.newHashSet();
|
private final Set<Ban> bans = Sets.newHashSet();
|
||||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
|
||||||
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
||||||
public static final String CONFIG_FILENAME = "bans.yml";
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
|
|
||||||
//
|
//
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
public BanManager(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
this.config = new YamlConfig(plugin, "bans.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
config.load();
|
|
||||||
|
|
||||||
bans.clear();
|
bans.clear();
|
||||||
for (String id : config.getKeys(false))
|
try
|
||||||
{
|
{
|
||||||
if (!config.isConfigurationSection(id))
|
ResultSet banSet = plugin.sql.getBanList();
|
||||||
{
|
{
|
||||||
FLog.warning("Could not load username ban: " + id + ". Invalid format!");
|
while (banSet.next())
|
||||||
continue;
|
{
|
||||||
|
String name = banSet.getString("name");
|
||||||
|
UUID uuid = null;
|
||||||
|
String strUUID = banSet.getString("uuid");
|
||||||
|
if (strUUID != null)
|
||||||
|
{
|
||||||
|
uuid = UUID.fromString(strUUID);
|
||||||
|
}
|
||||||
|
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
|
||||||
|
String by = banSet.getString("by");
|
||||||
|
Date at = new Date(banSet.getLong("at"));
|
||||||
|
Date expires = new Date(banSet.getLong("expires"));
|
||||||
|
String reason = banSet.getString("reason");
|
||||||
|
Ban ban = new Ban(name, uuid, ips, by, at, expires, reason);
|
||||||
|
bans.add(ban);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ban ban = new Ban();
|
catch (SQLException e)
|
||||||
ban.loadFrom(config.getConfigurationSection(id));
|
{
|
||||||
|
FLog.severe("Failed to load ban list: " + e.getMessage());
|
||||||
if (!ban.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Not adding username ban: " + id + ". Missing information.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bans.add(ban);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove expired bans, repopulate ipBans and nameBans,
|
// Remove expired bans, repopulate ipBans and nameBans,
|
||||||
updateViews();
|
updateViews();
|
||||||
|
|
||||||
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
||||||
|
|
||||||
// Load unbannable usernames
|
|
||||||
unbannableUsernames.clear();
|
|
||||||
unbannableUsernames.addAll((Collection<? extends String>)ConfigEntry.FAMOUS_PLAYERS.getList());
|
|
||||||
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
saveAll();
|
// This does nothing. This comment is here to prevent SonarLint from complaining.
|
||||||
logger.info("Saved " + bans.size() + " player bans");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Ban> getAllBans()
|
public Set<Ban> getAllBans()
|
||||||
@ -100,21 +89,6 @@ public class BanManager extends FreedomService
|
|||||||
return Collections.unmodifiableCollection(nameBans.values());
|
return Collections.unmodifiableCollection(nameBans.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAll()
|
|
||||||
{
|
|
||||||
// Remove expired
|
|
||||||
updateViews();
|
|
||||||
|
|
||||||
config.clear();
|
|
||||||
for (Ban ban : bans)
|
|
||||||
{
|
|
||||||
ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save config
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ban getByIp(String ip)
|
public Ban getByIp(String ip)
|
||||||
{
|
{
|
||||||
final Ban directBan = ipBans.get(ip);
|
final Ban directBan = ipBans.get(ip);
|
||||||
@ -138,7 +112,7 @@ public class BanManager extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ips.fuzzyIpMatch(ip, loopIp, 4))
|
if (FUtil.fuzzyIpMatch(ip, loopIp, 4))
|
||||||
{
|
{
|
||||||
return loopBan;
|
return loopBan;
|
||||||
}
|
}
|
||||||
@ -161,6 +135,18 @@ public class BanManager extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Ban getByUUID(UUID uuid)
|
||||||
|
{
|
||||||
|
final Ban directBan = uuidBans.get(uuid);
|
||||||
|
|
||||||
|
if (directBan != null && !directBan.isExpired())
|
||||||
|
{
|
||||||
|
return directBan;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Ban unbanIp(String ip)
|
public Ban unbanIp(String ip)
|
||||||
{
|
{
|
||||||
final Ban ban = getByIp(ip);
|
final Ban ban = getByIp(ip);
|
||||||
@ -168,7 +154,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -181,7 +166,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -197,64 +181,81 @@ public class BanManager extends FreedomService
|
|||||||
return getByUsername(username) != null;
|
return getByUsername(username) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addBan(Ban ban)
|
public void addBan(Ban ban)
|
||||||
{
|
{
|
||||||
if (bans.add(ban))
|
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
|
||||||
{
|
{
|
||||||
saveAll();
|
removeBan(ban);
|
||||||
return true;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
for (String ip : ban.getIps())
|
||||||
|
{
|
||||||
|
if (getByIp(ip) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bans.add(ban))
|
||||||
|
{
|
||||||
|
plugin.sql.addBan(ban);
|
||||||
|
updateViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeBan(Ban ban)
|
public void removeBan(Ban ban)
|
||||||
{
|
{
|
||||||
if (bans.remove(ban))
|
if (bans.remove(ban))
|
||||||
{
|
{
|
||||||
saveAll();
|
plugin.sql.removeBan(ban);
|
||||||
return true;
|
updateViews();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int purge()
|
public int purge()
|
||||||
{
|
{
|
||||||
config.clear();
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
int size = bans.size();
|
int size = bans.size();
|
||||||
bans.clear();
|
bans.clear();
|
||||||
updateViews();
|
updateViews();
|
||||||
|
plugin.sql.truncate("bans");
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
final String username = event.getPlayer().getName();
|
final String username = event.getPlayer().getName();
|
||||||
final String ip = Ips.getIp(event);
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
final String ip = FUtil.getIp(event);
|
||||||
|
|
||||||
// Regular ban
|
// Regular ban
|
||||||
Ban ban = getByUsername(username);
|
Ban ban = getByUsername(username);
|
||||||
if (ban == null)
|
if (ban == null)
|
||||||
{
|
{
|
||||||
ban = getByIp(ip);
|
ban = getByUUID(uuid);
|
||||||
|
|
||||||
|
if (ban == null)
|
||||||
|
{
|
||||||
|
ban = getByIp(ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ban != null && !ban.isExpired())
|
if (ban != null && !ban.isExpired())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage(ip));
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final PlayerData data = plugin.pl.getData(player);
|
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
@ -262,28 +263,35 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Unban admins
|
// Unban admins
|
||||||
for (String storedIp : data.getIps())
|
Ban ban = getByUsername(player.getName());
|
||||||
|
if (ban != null)
|
||||||
{
|
{
|
||||||
unbanIp(storedIp);
|
removeBan(ban);
|
||||||
unbanIp(FUtil.getFuzzyIp(storedIp));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ban = getByIp(FUtil.getIp(player));
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unbanUsername(player.getName());
|
|
||||||
player.setOp(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateViews()
|
private void updateViews()
|
||||||
{
|
{
|
||||||
// Remove expired bans
|
// Remove expired bans
|
||||||
for (Iterator<Ban> it = bans.iterator(); it.hasNext(); )
|
for (Ban ban : new ArrayList<>(bans))
|
||||||
{
|
{
|
||||||
if (it.next().isExpired())
|
if (ban.isExpired())
|
||||||
{
|
{
|
||||||
it.remove();
|
bans.remove(ban);
|
||||||
|
plugin.sql.removeBan(ban);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nameBans.clear();
|
nameBans.clear();
|
||||||
|
uuidBans.clear();
|
||||||
ipBans.clear();
|
ipBans.clear();
|
||||||
for (Ban ban : bans)
|
for (Ban ban : bans)
|
||||||
{
|
{
|
||||||
@ -292,6 +300,11 @@ public class BanManager extends FreedomService
|
|||||||
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ban.hasUUID())
|
||||||
|
{
|
||||||
|
uuidBans.put(ban.getUuid(), ban);
|
||||||
|
}
|
||||||
|
|
||||||
if (ban.hasIps())
|
if (ban.hasIps())
|
||||||
{
|
{
|
||||||
for (String ip : ban.getIps())
|
for (String ip : ban.getIps())
|
||||||
@ -301,5 +314,4 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -0,0 +1,122 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public class IndefiniteBan implements IConfig
|
||||||
|
{
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
private String username = null;
|
||||||
|
private UUID uuid = null;
|
||||||
|
private String reason = null;
|
||||||
|
private Date expiry = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFrom(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
this.username = cs.getName();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String strUUID = cs.getString("uuid", null);
|
||||||
|
if (strUUID != null)
|
||||||
|
{
|
||||||
|
UUID uuid = UUID.fromString(strUUID);
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to load indefinite banned UUID for " + this.username + ". Make sure the UUID is in the correct format with dashes.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ips.clear();
|
||||||
|
this.ips.addAll(cs.getStringList("ips"));
|
||||||
|
this.reason = cs.getString("reason", null);
|
||||||
|
|
||||||
|
String date = cs.getString("expiry", null);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.expiry = date != null ? new SimpleDateFormat("yyyy-MM-dd").parse(date) : null;
|
||||||
|
}
|
||||||
|
catch (ParseException ex)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to load indefinite banned expiry for " + this.username + ". Make sure the expiry is in the correct format (yyyy-MM-dd).");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
// The indefinite ban list is only intended to be modified manually. It is not intended to save.
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return username != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername()
|
||||||
|
{
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username)
|
||||||
|
{
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid()
|
||||||
|
{
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUuid(UUID uuid)
|
||||||
|
{
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReason(String reason)
|
||||||
|
{
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getExpiry()
|
||||||
|
{
|
||||||
|
return expiry;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiry(Date date)
|
||||||
|
{
|
||||||
|
this.expiry = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExpiry()
|
||||||
|
{
|
||||||
|
return this.expiry != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExpired()
|
||||||
|
{
|
||||||
|
return hasExpiry() && expiry.before(new Date(FUtil.getUnixTime()));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,189 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
|
||||||
|
public class IndefiniteBanList extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "indefinitebans.yml";
|
||||||
|
private YamlConfig config;
|
||||||
|
|
||||||
|
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
||||||
|
|
||||||
|
private int nameBanCount = 0;
|
||||||
|
|
||||||
|
private int uuidBanCount = 0;
|
||||||
|
|
||||||
|
private int ipBanCount = 0;
|
||||||
|
|
||||||
|
private final SimpleDateFormat dateFormat = new SimpleDateFormat("dd MMM yyyy, zzzz");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
indefBans.clear();
|
||||||
|
|
||||||
|
config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
for (String name : config.getKeys(false))
|
||||||
|
{
|
||||||
|
if (!config.isConfigurationSection(name))
|
||||||
|
{
|
||||||
|
FLog.warning("Could not load indefinite ban for " + name + ": Invalid format!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IndefiniteBan indefBan = new IndefiniteBan();
|
||||||
|
ConfigurationSection cs = config.getConfigurationSection(name);
|
||||||
|
assert cs != null;
|
||||||
|
indefBan.loadFrom(cs);
|
||||||
|
|
||||||
|
if (!indefBan.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Not adding indefinite ban for " + name + ": Missing information.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (indefBan.isExpired())
|
||||||
|
{
|
||||||
|
FLog.info("Removing " + name + " from indefinite ban list as the entry has expired!");
|
||||||
|
config.set(name, null);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
indefBans.add(indefBan);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCount();
|
||||||
|
config.save();
|
||||||
|
|
||||||
|
FLog.info("Loaded " + nameBanCount + " indefinite name bans, " + uuidBanCount + " UUID bans, and " + ipBanCount + " ip bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
// This does nothing. This comment is here to prevent SonarLint from complaining.
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final String username = event.getPlayer().getName();
|
||||||
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
final String ip = FUtil.getIp(event);
|
||||||
|
|
||||||
|
String bannedBy = "";
|
||||||
|
IndefiniteBan ban = null;
|
||||||
|
|
||||||
|
for (IndefiniteBan indefBan : indefBans)
|
||||||
|
{
|
||||||
|
if (username.equalsIgnoreCase(indefBan.getUsername()))
|
||||||
|
{
|
||||||
|
bannedBy = "username";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid))
|
||||||
|
{
|
||||||
|
bannedBy = "UUID";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (indefBan.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
bannedBy = "IP address";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onPlayerLoginSplitWorkToReduceComplexity(event, ban, bannedBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onPlayerLoginSplitWorkToReduceComplexity(PlayerLoginEvent event, IndefiniteBan ban, String bannedBy) {
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
if (ban.isExpired())
|
||||||
|
{
|
||||||
|
config.set(ban.getUsername(), null);
|
||||||
|
config.save();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String kickMessage = ChatColor.RED + "Your " + bannedBy + " is "
|
||||||
|
+ (ban.hasExpiry() ? "" : "indefinitely ")
|
||||||
|
+ "banned from this server.";
|
||||||
|
String reason = ban.getReason();
|
||||||
|
if (!Strings.isNullOrEmpty(reason))
|
||||||
|
{
|
||||||
|
kickMessage += "\nReason: " + ChatColor.GOLD + reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
Date expiry = ban.getExpiry();
|
||||||
|
if (expiry != null)
|
||||||
|
{
|
||||||
|
kickMessage += ChatColor.RED + "\nExpiry: " + ChatColor.GOLD + dateFormat.format(expiry);
|
||||||
|
}
|
||||||
|
|
||||||
|
String appealURL = ConfigEntry.SERVER_INDEFBAN_URL.getString();
|
||||||
|
if (!Strings.isNullOrEmpty(appealURL))
|
||||||
|
{
|
||||||
|
kickMessage += ChatColor.RED + "\n\nRelease procedures are available at\n" + ChatColor.GOLD + ConfigEntry.SERVER_INDEFBAN_URL.getString();
|
||||||
|
}
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void updateCount()
|
||||||
|
{
|
||||||
|
nameBanCount = 0;
|
||||||
|
uuidBanCount = 0;
|
||||||
|
ipBanCount = 0;
|
||||||
|
|
||||||
|
for (IndefiniteBan indefBan : indefBans)
|
||||||
|
{
|
||||||
|
nameBanCount += 1;
|
||||||
|
if (indefBan.getUuid() != null)
|
||||||
|
{
|
||||||
|
uuidBanCount += 1;
|
||||||
|
}
|
||||||
|
ipBanCount += indefBan.getIps().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<IndefiniteBan> getIndefBans()
|
||||||
|
{
|
||||||
|
return indefBans;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNameBanCount()
|
||||||
|
{
|
||||||
|
return nameBanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUuidBanCount()
|
||||||
|
{
|
||||||
|
return uuidBanCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIpBanCount()
|
||||||
|
{
|
||||||
|
return ipBanCount;
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Banner;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
import org.bukkit.block.banner.Pattern;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -23,22 +15,18 @@ import org.bukkit.inventory.meta.SkullMeta;
|
|||||||
|
|
||||||
public class BlockBlocker extends FreedomService
|
public class BlockBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public BlockBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
// TODO: Remove deprecated method. Complexity is also O(35) which is very bad.
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
@ -48,11 +36,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
case LAVA:
|
case LAVA:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||||
@ -62,11 +46,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case WATER:
|
case WATER:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||||
@ -76,12 +56,9 @@ public class BlockBlocker extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FIRE:
|
case FIRE:
|
||||||
|
case SOUL_FIRE:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||||
@ -89,17 +66,9 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TNT:
|
|
||||||
{
|
|
||||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STRUCTURE_BLOCK:
|
case STRUCTURE_BLOCK:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
@ -109,7 +78,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case JIGSAW:
|
case JIGSAW:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_JIGSAWS.getBoolean())
|
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled.");
|
player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
@ -117,6 +86,16 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case REPEATING_COMMAND_BLOCK:
|
||||||
|
case CHAIN_COMMAND_BLOCK:
|
||||||
|
case COMMAND_BLOCK:
|
||||||
|
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Command blocks are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case GRINDSTONE:
|
case GRINDSTONE:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean())
|
if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean())
|
||||||
@ -152,7 +131,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Bee hives are disabled.");
|
player.sendMessage(ChatColor.GRAY + "Beehives are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -161,17 +140,18 @@ public class BlockBlocker extends FreedomService
|
|||||||
case PLAYER_HEAD:
|
case PLAYER_HEAD:
|
||||||
case PLAYER_WALL_HEAD:
|
case PLAYER_WALL_HEAD:
|
||||||
{
|
{
|
||||||
Skull skull = (Skull) event.getBlockPlaced().getState();
|
Skull skull = (Skull)event.getBlockPlaced().getState();
|
||||||
if (skull.hasOwner())
|
if (skull.getOwner() != null)
|
||||||
{
|
{
|
||||||
if (skull.getOwner().contains("§"))
|
if (skull.getOwner().contains("\u00A7"))
|
||||||
{
|
{
|
||||||
skull.setOwner(skull.getOwner().replace("§", ""));
|
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
|
||||||
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
|
||||||
if (meta != null)
|
if (meta != null)
|
||||||
{
|
{
|
||||||
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
|
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
ItemMeta headMeta = newHead.getItemMeta();
|
ItemMeta headMeta = newHead.getItemMeta();
|
||||||
|
assert headMeta != null;
|
||||||
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
|
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
|
||||||
newHead.setItemMeta(headMeta);
|
newHead.setItemMeta(headMeta);
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
|
||||||
@ -188,21 +168,21 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
case RESPAWN_ANCHOR:
|
||||||
|
|
||||||
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
|
||||||
{
|
|
||||||
Banner banner = (Banner) event.getBlockPlaced().getState();
|
|
||||||
List<Pattern> patterns = banner.getPatterns();
|
|
||||||
Banner handBanner = (Banner) (((Block) event.getItemInHand()).getState());
|
|
||||||
List<Pattern> handPatterns = banner.getPatterns();
|
|
||||||
if (patterns.size() >= 2)
|
|
||||||
{
|
{
|
||||||
banner.setPatterns(patterns.subList(0, 2));
|
if (!ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
||||||
handBanner.setPatterns(handPatterns.subList(0, 2));
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
player.sendMessage(ChatColor.GRAY + "Respawn anchors are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,69 +1,61 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
|
public class EditBlocker extends FreedomService
|
||||||
public class EditBlocker extends FreedomService
|
{
|
||||||
{
|
@Override
|
||||||
|
public void onStart()
|
||||||
public EditBlocker(TotalFreedomMod plugin)
|
{
|
||||||
{
|
}
|
||||||
super(plugin);
|
|
||||||
}
|
@Override
|
||||||
|
public void onStop()
|
||||||
@Override
|
{
|
||||||
protected void onStart()
|
}
|
||||||
{
|
|
||||||
}
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
@Override
|
{
|
||||||
protected void onStop()
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
{
|
if (!fPlayer.isEditBlocked())
|
||||||
}
|
{
|
||||||
|
return;
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
}
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
|
||||||
{
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
{
|
||||||
if (!fPlayer.isEditBlocked())
|
fPlayer.setEditBlocked(false);
|
||||||
{
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
event.setCancelled(true);
|
||||||
{
|
}
|
||||||
fPlayer.setEditBlocked(false);
|
|
||||||
return;
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
}
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
event.setCancelled(true);
|
if (!fPlayer.isEditBlocked())
|
||||||
}
|
{
|
||||||
|
return;
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
}
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
|
||||||
{
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
{
|
||||||
if (!fPlayer.isEditBlocked())
|
fPlayer.setEditBlocked(false);
|
||||||
{
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
event.setCancelled(true);
|
||||||
{
|
}
|
||||||
fPlayer.setEditBlocked(false);
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,32 +1,31 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import me.totalfreedom.scissors.event.block.MasterBlockFireEvent;
|
||||||
|
import io.papermc.paper.event.player.PlayerSignCommandPreprocessEvent;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeModifier;
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
|
import org.bukkit.block.data.AnaloguePowerable;
|
||||||
|
import org.bukkit.block.data.Powerable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.*;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
|
||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
|
||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
|
||||||
import org.bukkit.event.block.BlockGrowEvent;
|
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.FireworkExplodeEvent;
|
import org.bukkit.event.entity.FireworkExplodeEvent;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
@ -35,19 +34,27 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
|||||||
|
|
||||||
public class EventBlocker extends FreedomService
|
public class EventBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* /@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
* /public void onBlockRedstone(BlockRedstoneEvent event)
|
||||||
|
* /{
|
||||||
|
* / if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
* / {
|
||||||
|
* / event.setNewCurrent(0);
|
||||||
|
* / }
|
||||||
|
* /}
|
||||||
|
**/
|
||||||
|
|
||||||
public EventBlocker(TotalFreedomMod plugin)
|
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
|
||||||
{
|
private final ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,6 +109,28 @@ public class EventBlocker extends FreedomService
|
|||||||
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockExplode(BlockExplodeEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setYield(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onMasterBlockFire(MasterBlockFireEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_MASTERBLOCKS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getAt().getBlock().setType(Material.CAKE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityCombust(EntityCombustEvent event)
|
public void onEntityCombust(EntityCombustEvent event)
|
||||||
{
|
{
|
||||||
@ -123,27 +152,19 @@ public class EventBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
switch (event.getCause())
|
if ((event.getCause() == EntityDamageEvent.DamageCause.LAVA)
|
||||||
|
&& !ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||||
{
|
{
|
||||||
case LAVA:
|
event.setCancelled(true);
|
||||||
{
|
return;
|
||||||
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
||||||
{
|
{
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Tameable)
|
if (entity instanceof Tameable tameable && tameable.isTamed())
|
||||||
{
|
{
|
||||||
if (((Tameable)entity).isTamed())
|
event.setCancelled(true);
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -206,27 +227,41 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler
|
||||||
public void onBlockRedstone(BlockRedstoneEvent event)
|
public void onEntitySpawn(EntitySpawnEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_GRAVITY.getBoolean() && event.getEntity() instanceof FallingBlock)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
{
|
{
|
||||||
event.setNewCurrent(0);
|
// Check if the block is involved with redstone.
|
||||||
|
if (event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||||
{
|
{
|
||||||
double maxHealth = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
double maxHealth = Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
|
||||||
if (maxHealth < 1)
|
if (maxHealth < 1)
|
||||||
{
|
{
|
||||||
for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers())
|
for (AttributeModifier attributeModifier : Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getModifiers())
|
||||||
{
|
{
|
||||||
event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).removeModifier(attributeModifier);
|
Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).removeModifier(attributeModifier);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onBlockDispense(BlockDispenseEvent event)
|
public void onBlockDispense(BlockDispenseEvent event)
|
||||||
{
|
{
|
||||||
@ -243,4 +278,10 @@ public class EventBlocker extends FreedomService
|
|||||||
FUtil.fixCommandVoid(event.getEntity());
|
FUtil.fixCommandVoid(event.getEntity());
|
||||||
event.setDeathMessage(event.getDeathMessage());
|
event.setDeathMessage(event.getDeathMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onSignInteract(PlayerSignCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,33 +1,28 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class InteractBlocker extends FreedomService
|
public class InteractBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public InteractBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,10 +38,9 @@ public class InteractBlocker extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case LEFT_CLICK_AIR:
|
default:
|
||||||
case LEFT_CLICK_BLOCK:
|
|
||||||
{
|
{
|
||||||
//
|
// Do nothing
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,36 +49,59 @@ public class InteractBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onRightClickBell(PlayerInteractEvent event)
|
public void onRightClickBell(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock() != null)
|
if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.BELL) && !ConfigEntry.ALLOW_BELLS.getBoolean())
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock().getType().equals(Material.BELL))
|
event.setCancelled(true);
|
||||||
{
|
|
||||||
if (!ConfigEntry.ALLOW_BELLS.getBoolean())
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBedEnter(PlayerBedEnterEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (Groups.EXPLOSIVE_BED_BIOMES.contains(event.getBed().getBiome()))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You may not sleep here.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Current cognitive complexity is O(24). This is too high.
|
||||||
private void handleRightClick(PlayerInteractEvent event)
|
private void handleRightClick(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
final Block clickedBlock = event.getClickedBlock();
|
||||||
|
|
||||||
if (event.getClickedBlock() != null)
|
if (clickedBlock != null && clickedBlock.getType() == Material.RESPAWN_ANCHOR && !ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW))
|
event.setCancelled(true);
|
||||||
{
|
return;
|
||||||
event.setCancelled(true);
|
|
||||||
event.getPlayer().closeInventory();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Groups.SPAWN_EGGS.contains(event.getMaterial()))
|
if (Groups.SPAWN_EGGS.contains(event.getMaterial()))
|
||||||
{
|
{
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
player.sendMessage(ChatColor.GRAY + "Spawn eggs are currently disabled.");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
EntityType eggType = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Material mat = event.getMaterial();
|
||||||
|
if (mat == Material.MOOSHROOM_SPAWN_EGG)
|
||||||
|
{
|
||||||
|
eggType = EntityType.MUSHROOM_COW;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eggType = EntityType.valueOf(mat.name().substring(0, mat.name().length() - 10));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ignored)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
if (eggType != null && clickedBlock != null)
|
||||||
|
{
|
||||||
|
clickedBlock.getWorld().spawnEntity(clickedBlock.getLocation().add(event.getBlockFace().getDirection()).add(0.5, 0.5, 0.5), eggType);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +145,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case ARMOR_STAND:
|
case ARMOR_STAND:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_ARMOR_STANDS.getBoolean())
|
if (ConfigEntry.ALLOW_ARMOR_STANDS.getBoolean())
|
||||||
@ -153,6 +170,23 @@ public class InteractBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case WRITTEN_BOOK:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_BOOKS.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Books are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.bukkit.attribute.Attributable;
|
import org.bukkit.attribute.Attributable;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.entity.Bat;
|
import org.bukkit.entity.Bat;
|
||||||
@ -22,19 +21,13 @@ import org.bukkit.event.entity.EntitySpawnEvent;
|
|||||||
|
|
||||||
public class MobBlocker extends FreedomService
|
public class MobBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public MobBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,17 +43,18 @@ public class MobBlocker extends FreedomService
|
|||||||
Entity entity = e.getEntity();
|
Entity entity = e.getEntity();
|
||||||
if (entity instanceof Attributable)
|
if (entity instanceof Attributable)
|
||||||
{
|
{
|
||||||
if (((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0)
|
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
|
||||||
{
|
{
|
||||||
((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0);
|
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
|
||||||
}
|
}
|
||||||
if (((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0)
|
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
|
||||||
{
|
{
|
||||||
((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(10.0);
|
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Complexity for this method is too high [O(23)]. This needs to be fixed.
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
{
|
{
|
||||||
@ -125,7 +119,7 @@ public class MobBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
int mobcount = 0;
|
int mobcount = 0;
|
||||||
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
for (Entity entity : Objects.requireNonNull(event.getLocation().getWorld()).getLivingEntities())
|
||||||
{
|
{
|
||||||
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
||||||
{
|
{
|
||||||
@ -138,4 +132,4 @@ public class MobBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,35 +1,30 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Trident;
|
|
||||||
import org.bukkit.entity.FishHook;
|
import org.bukkit.entity.FishHook;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.SpectralArrow;
|
||||||
|
import org.bukkit.entity.Trident;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
public class PVPBlocker extends FreedomService
|
public class PVPBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public PVPBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Complexity is O(26). This needs to be reduced.
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||||
{
|
{
|
||||||
@ -50,6 +45,14 @@ public class PVPBlocker extends FreedomService
|
|||||||
player = (Player)arrow.getShooter();
|
player = (Player)arrow.getShooter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event.getDamager() instanceof SpectralArrow)
|
||||||
|
{
|
||||||
|
SpectralArrow spectralArrow = (SpectralArrow)event.getDamager();
|
||||||
|
if (spectralArrow.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)spectralArrow.getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (event.getDamager() instanceof Trident)
|
else if (event.getDamager() instanceof Trident)
|
||||||
{
|
{
|
||||||
Trident trident = (Trident)event.getDamager();
|
Trident trident = (Trident)event.getDamager();
|
||||||
@ -68,7 +71,7 @@ public class PVPBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null & !plugin.al.isAdmin(player))
|
if (player != null && !plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
if (player.getGameMode() == GameMode.CREATIVE)
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
{
|
{
|
||||||
@ -91,7 +94,5 @@ public class PVPBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.ThrownPotion;
|
import org.bukkit.entity.ThrownPotion;
|
||||||
@ -19,18 +18,13 @@ public class PotionBlocker extends FreedomService
|
|||||||
|
|
||||||
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
||||||
|
|
||||||
public PotionBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,5 +82,4 @@ public class PotionBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -2,61 +2,70 @@ package me.totalfreedom.totalfreedommod.blocking.command;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.command.CommandReflection;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
|
|
||||||
public class CommandBlocker extends FreedomService
|
public class CommandBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
private final Pattern whitespacePattern = Pattern.compile("^/?( +)(.*)?");
|
||||||
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
|
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
|
||||||
//
|
//
|
||||||
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||||
private final List<String> unknownCommands = Lists.newArrayList();
|
private final List<String> unknownCommands = Lists.newArrayList();
|
||||||
|
|
||||||
public CommandBlocker(TotalFreedomMod plugin)
|
public static CommandMap getCommandMap()
|
||||||
{
|
{
|
||||||
super(plugin);
|
try
|
||||||
|
{
|
||||||
|
SimplePluginManager simplePluginManager = (SimplePluginManager)Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||||
|
commandMapField.setAccessible(true);
|
||||||
|
|
||||||
|
return (SimpleCommandMap)commandMapField.get(simplePluginManager);
|
||||||
|
}
|
||||||
|
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
entryList.clear();
|
entryList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load()
|
public void load() // TODO: Complexity is 21. Need to fix this.
|
||||||
{
|
{
|
||||||
entryList.clear();
|
entryList.clear();
|
||||||
unknownCommands.clear();
|
unknownCommands.clear();
|
||||||
|
|
||||||
final CommandMap commandMap = CommandReflection.getCommandMap();
|
final CommandMap commandMap = getCommandMap();
|
||||||
if (commandMap == null)
|
|
||||||
{
|
|
||||||
FLog.severe("Error loading commandMap.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
|
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
|
||||||
@ -74,7 +83,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
String commandName = parts[2].toLowerCase().substring(1);
|
String commandName = parts[2].toLowerCase().substring(1);
|
||||||
final String message = (parts.length > 3 ? parts[3] : null);
|
final String message = (parts.length > 3 ? parts[3] : null);
|
||||||
|
|
||||||
if (rank == null || action == null || commandName == null || commandName.isEmpty())
|
if (rank == null || action == null || commandName.isEmpty())
|
||||||
{
|
{
|
||||||
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
||||||
continue;
|
continue;
|
||||||
@ -88,6 +97,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
|
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert commandMap != null;
|
||||||
final Command command = commandMap.getCommand(commandName);
|
final Command command = commandMap.getCommand(commandName);
|
||||||
|
|
||||||
// Obtain command from alias
|
// Obtain command from alias
|
||||||
@ -106,9 +116,9 @@ public class CommandBlocker extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
|
|
||||||
entryList.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
|
||||||
|
|
||||||
|
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
|
||||||
|
entryList.put(commandName, blockedCommandEntry);
|
||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
for (String alias : command.getAliases())
|
for (String alias : command.getAliases())
|
||||||
@ -130,12 +140,6 @@ public class CommandBlocker extends FreedomService
|
|||||||
// CommandBlocker handles messages and broadcasts
|
// CommandBlocker handles messages and broadcasts
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getMessage().contains("translation.test.invalid") || event.getMessage().contains("translation.test.invalid2"))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
FUtil.playerMsg(event.getPlayer(), ChatColor.RED + "No crishy crashy faggy");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCommandBlocked(String command, CommandSender sender)
|
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||||
@ -143,6 +147,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
return isCommandBlocked(command, sender, false);
|
return isCommandBlocked(command, sender, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Complexity is 22. Need to fix this. Complexity can be no more than O(15).
|
||||||
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||||
{
|
{
|
||||||
if (command == null || command.isEmpty())
|
if (command == null || command.isEmpty())
|
||||||
@ -152,6 +157,14 @@ public class CommandBlocker extends FreedomService
|
|||||||
|
|
||||||
// Format
|
// Format
|
||||||
command = command.toLowerCase().trim();
|
command = command.toLowerCase().trim();
|
||||||
|
|
||||||
|
// Whitespaces
|
||||||
|
Matcher whitespaceMatcher = whitespacePattern.matcher(command);
|
||||||
|
if (whitespaceMatcher.matches() && whitespaceMatcher.groupCount() == 2)
|
||||||
|
{
|
||||||
|
command = whitespaceMatcher.group(2);
|
||||||
|
}
|
||||||
|
|
||||||
command = command.startsWith("/") ? command.substring(1) : command;
|
command = command.startsWith("/") ? command.substring(1) : command;
|
||||||
|
|
||||||
// Check for plugin specific commands
|
// Check for plugin specific commands
|
||||||
@ -199,12 +212,9 @@ public class CommandBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate sub command
|
// Validate sub command
|
||||||
if (entry.getSubCommand() != null)
|
if (entry.getSubCommand() != null && (subCommand == null || !subCommand.startsWith(entry.getSubCommand())))
|
||||||
{
|
{
|
||||||
if (subCommand == null || !subCommand.startsWith(entry.getSubCommand()))
|
return false;
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.getRank().hasPermission(sender))
|
if (entry.getRank().hasPermission(sender))
|
@ -8,16 +8,11 @@ public enum CommandBlockerAction
|
|||||||
BLOCK_UNKNOWN("u");
|
BLOCK_UNKNOWN("u");
|
||||||
private final String token;
|
private final String token;
|
||||||
|
|
||||||
private CommandBlockerAction(String token)
|
CommandBlockerAction(String token)
|
||||||
{
|
{
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getToken()
|
|
||||||
{
|
|
||||||
return this.token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandBlockerAction fromToken(String token)
|
public static CommandBlockerAction fromToken(String token)
|
||||||
{
|
{
|
||||||
for (CommandBlockerAction action : CommandBlockerAction.values())
|
for (CommandBlockerAction action : CommandBlockerAction.values())
|
||||||
@ -29,4 +24,9 @@ public enum CommandBlockerAction
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +1,24 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.spigotmc.SpigotConfig;
|
|
||||||
|
|
||||||
public class CommandBlockerEntry
|
public class CommandBlockerEntry
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final CommandBlockerRank rank;
|
private final CommandBlockerRank rank;
|
||||||
@Getter
|
|
||||||
private final CommandBlockerAction action;
|
private final CommandBlockerAction action;
|
||||||
@Getter
|
|
||||||
private final String command;
|
private final String command;
|
||||||
@Getter
|
|
||||||
private final String subCommand;
|
private final String subCommand;
|
||||||
@Getter
|
|
||||||
private final String message;
|
private final String message;
|
||||||
|
|
||||||
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||||
@ -40,15 +39,40 @@ public class CommandBlockerEntry
|
|||||||
{
|
{
|
||||||
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||||
{
|
{
|
||||||
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
TotalFreedomMod.getPlugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
||||||
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
||||||
{
|
{
|
||||||
sender.sendMessage(SpigotConfig.unknownCommandMessage);
|
sender.sendMessage(Bukkit.spigot().getSpigotConfig().getString("messages.unknown-command"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FUtil.playerMsg(sender, FUtil.colorize(message));
|
FUtil.playerMsg(sender, FUtil.colorize(message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CommandBlockerRank getRank()
|
||||||
|
{
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandBlockerAction getAction()
|
||||||
|
{
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCommand()
|
||||||
|
{
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSubCommand()
|
||||||
|
{
|
||||||
|
return subCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,52 +2,34 @@ package me.totalfreedom.totalfreedommod.blocking.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public enum CommandBlockerRank
|
public enum CommandBlockerRank
|
||||||
{
|
{
|
||||||
|
EVERYONE("e"),
|
||||||
ANYONE("a"),
|
|
||||||
OP("o"),
|
OP("o"),
|
||||||
SUPER("s"),
|
ADMIN("a"),
|
||||||
TELNET("t"),
|
SENIOR_ADMIN("s"),
|
||||||
SENIOR("c"),
|
|
||||||
NOBODY("n");
|
NOBODY("n");
|
||||||
//
|
//
|
||||||
private final String token;
|
private final String token;
|
||||||
|
|
||||||
private CommandBlockerRank(String token)
|
CommandBlockerRank(String token)
|
||||||
{
|
{
|
||||||
this.token = token;
|
this.token = token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getToken()
|
|
||||||
{
|
|
||||||
return this.token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPermission(CommandSender sender)
|
|
||||||
{
|
|
||||||
return fromSender(sender).ordinal() >= ordinal();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommandBlockerRank fromSender(CommandSender sender)
|
public static CommandBlockerRank fromSender(CommandSender sender)
|
||||||
{
|
{
|
||||||
if (!(sender instanceof Player))
|
Admin admin = TotalFreedomMod.getPlugin().al.getAdmin(sender);
|
||||||
{
|
|
||||||
return TELNET;
|
|
||||||
}
|
|
||||||
|
|
||||||
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
|
|
||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
if (admin.getRank() == GroupProvider.SENIOR_ADMIN.getGroup())
|
||||||
{
|
{
|
||||||
return SENIOR;
|
return SENIOR_ADMIN;
|
||||||
}
|
}
|
||||||
return SUPER;
|
return ADMIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sender.isOp())
|
if (sender.isOp())
|
||||||
@ -55,8 +37,7 @@ public enum CommandBlockerRank
|
|||||||
return OP;
|
return OP;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ANYONE;
|
return EVERYONE;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CommandBlockerRank fromToken(String token)
|
public static CommandBlockerRank fromToken(String token)
|
||||||
@ -68,6 +49,16 @@ public enum CommandBlockerRank
|
|||||||
return rank;
|
return rank;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ANYONE;
|
return EVERYONE;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return fromSender(sender).ordinal() >= ordinal();
|
||||||
|
}
|
||||||
|
}
|
@ -1,41 +1,36 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class BukkitTelnetBridge extends FreedomService
|
public class BukkitTelnetBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
private BukkitTelnet bukkitTelnetPlugin = null;
|
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||||
|
|
||||||
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,9 +44,9 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
final Admin admin = plugin.al.getEntryByIp(ip);
|
||||||
|
|
||||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
if (admin == null || !admin.isActive())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -72,10 +67,8 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
|
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
|
||||||
{
|
{
|
||||||
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
|
for (Map.Entry<Player, Map<String, Object>> entry : event.getDataTags().entrySet())
|
||||||
while (it.hasNext())
|
|
||||||
{
|
{
|
||||||
final Map.Entry<Player, Map<String, Object>> entry = it.next();
|
|
||||||
final Player player = entry.getKey();
|
final Player player = entry.getKey();
|
||||||
final Map<String, Object> playerTags = entry.getValue();
|
final Map<String, Object> playerTags = entry.getValue();
|
||||||
|
|
||||||
@ -89,8 +82,8 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
boolean active = admin.isActive();
|
boolean active = admin.isActive();
|
||||||
|
|
||||||
isAdmin = active;
|
isAdmin = active;
|
||||||
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
isSeniorAdmin = active && admin.getRank().equals(GroupProvider.SENIOR_ADMIN.getGroup());
|
||||||
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.TELNET_ADMIN);
|
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank().equals(GroupProvider.ADMIN.getGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||||
@ -99,7 +92,10 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
|
|
||||||
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
|
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
|
||||||
|
|
||||||
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
if (server.getPluginManager().isPluginEnabled("Essentials"))
|
||||||
|
{
|
||||||
|
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,15 +106,11 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
||||||
if (bukkitTelnet != null)
|
if (bukkitTelnet instanceof BukkitTelnet)
|
||||||
{
|
{
|
||||||
if (bukkitTelnet instanceof BukkitTelnet)
|
bukkitTelnetPlugin = (BukkitTelnet) bukkitTelnet;
|
||||||
{
|
|
||||||
bukkitTelnetPlugin = (BukkitTelnet)bukkitTelnet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
@ -127,6 +119,24 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
return bukkitTelnetPlugin;
|
return bukkitTelnetPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Admin> getConnectedAdmins()
|
||||||
|
{
|
||||||
|
List<Admin> admins = new ArrayList<>();
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
for (ClientSession session : telnet.appender.getSessions())
|
||||||
|
{
|
||||||
|
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
|
||||||
|
if (admin != null && !admins.contains(admin))
|
||||||
|
{
|
||||||
|
admins.add(admin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return admins;
|
||||||
|
}
|
||||||
|
|
||||||
public void killTelnetSessions(final String name)
|
public void killTelnetSessions(final String name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -136,10 +146,8 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
if (telnet != null)
|
if (telnet != null)
|
||||||
{
|
{
|
||||||
final Iterator<ClientSession> it = telnet.appender.getSessions().iterator();
|
for (ClientSession session : telnet.appender.getSessions())
|
||||||
while (it.hasNext())
|
|
||||||
{
|
{
|
||||||
final ClientSession session = it.next();
|
|
||||||
if (name != null && name.equalsIgnoreCase(session.getUserName()))
|
if (name != null && name.equalsIgnoreCase(session.getUserName()))
|
||||||
{
|
{
|
||||||
sessionsToRemove.add(session);
|
sessionsToRemove.add(session);
|
||||||
@ -152,8 +160,7 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
telnet.appender.removeSession(session);
|
telnet.appender.removeSession(session);
|
||||||
session.syncTerminateSession();
|
session.syncTerminateSession();
|
||||||
}
|
} catch (Exception ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
FLog.severe("Error removing single telnet session: " + ex.getMessage());
|
FLog.severe("Error removing single telnet session: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
@ -161,10 +168,9 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
|
|
||||||
FLog.info(sessionsToRemove.size() + " telnet session(s) removed.");
|
FLog.info(sessionsToRemove.size() + " telnet session(s) removed.");
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
FLog.severe("Error removing telnet sessions: " + ex.getMessage());
|
FLog.severe("Error removing telnet sessions: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,339 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.coreprotect.CoreProtect;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
|
import net.coreprotect.utility.Util;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
import net.kyori.adventure.text.format.TextDecoration;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class CoreProtectBridge extends FreedomService
|
||||||
|
{
|
||||||
|
//-- Block Inspector --//
|
||||||
|
private static final Component name = Component.text("Block Inspector").color(TextColor.color(0x30ade4));
|
||||||
|
private static final Component header = Component.text("---- ").append(name)
|
||||||
|
.append(Component.text(" ---- ")).colorIfAbsent(NamedTextColor.WHITE);
|
||||||
|
private static final Component prefix = name.append(Component.text(" - ").color(NamedTextColor.WHITE))
|
||||||
|
.colorIfAbsent(NamedTextColor.WHITE);
|
||||||
|
//--
|
||||||
|
private final HashMap<UUID, Long> cooldownMap = new HashMap<>();
|
||||||
|
private HashMap<UUID, FUtil.PaginationList<CoreProtectAPI.ParseResult>> historyMap;
|
||||||
|
|
||||||
|
//---------------------//
|
||||||
|
private CoreProtectAPI coreProtectAPI = null;
|
||||||
|
|
||||||
|
public static Long getSecondsLeft(long prevTime, int timeAdd)
|
||||||
|
{
|
||||||
|
return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
if (isEnabled())
|
||||||
|
{
|
||||||
|
historyMap = new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreProtect getCoreProtect()
|
||||||
|
{
|
||||||
|
CoreProtect coreProtect = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin coreProtectPlugin = server.getPluginManager().getPlugin("CoreProtect");
|
||||||
|
assert coreProtectPlugin != null;
|
||||||
|
if (coreProtectPlugin instanceof CoreProtect)
|
||||||
|
{
|
||||||
|
coreProtect = (CoreProtect)coreProtectPlugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return coreProtect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreProtectAPI getCoreProtectAPI()
|
||||||
|
{
|
||||||
|
if (coreProtectAPI == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final CoreProtect coreProtect = getCoreProtect();
|
||||||
|
|
||||||
|
coreProtectAPI = coreProtect.getAPI();
|
||||||
|
|
||||||
|
// Check if the plugin or api is not enabled, if so, return null
|
||||||
|
if (!coreProtect.isEnabled() || !coreProtectAPI.isEnabled())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return coreProtectAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled("CoreProtect"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CoreProtect coreProtect = getCoreProtect();
|
||||||
|
|
||||||
|
return coreProtect != null && coreProtect.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rollback the specified player's edits that were in the last 24 hours.
|
||||||
|
public void rollback(final String name)
|
||||||
|
{
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
coreProtect.performRollback(86400, Collections.singletonList(name), null, null, null, null, 0, null);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverts a rollback for the specified player's edits that were in the last 24 hours.
|
||||||
|
public void restore(final String name)
|
||||||
|
{
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
coreProtect.performRestore(86400, Collections.singletonList(name), null, null, null, null, 0, null);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasHistory(Player player)
|
||||||
|
{
|
||||||
|
return historyMap.containsKey(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FUtil.PaginationList<CoreProtectAPI.ParseResult> getHistoryForPlayer(Player player)
|
||||||
|
{
|
||||||
|
return historyMap.get(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Complexity is O(19). This should be reduced.
|
||||||
|
public void showPageToPlayer(Player player, FUtil.PaginationList<CoreProtectAPI.ParseResult> results, int pageNum)
|
||||||
|
{
|
||||||
|
if (player == null || !player.isOnline())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<CoreProtectAPI.ParseResult> page = results.getPage(pageNum);
|
||||||
|
|
||||||
|
if (page == null || page.isEmpty())
|
||||||
|
{
|
||||||
|
player.sendMessage(prefix.append(Component.text("No results were found.", NamedTextColor.WHITE)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// This shouldn't change at all in any of the other entries, so this should be safe
|
||||||
|
Component location = Component.text(String.format("(%s, %s, %s)", results.get(0).getX(),
|
||||||
|
results.get(0).getY(), results.get(0).getZ()));
|
||||||
|
final long time = System.currentTimeMillis() / 1000;
|
||||||
|
|
||||||
|
player.sendMessage(header.append(location.color(NamedTextColor.GRAY).decorate(TextDecoration.ITALIC)));
|
||||||
|
page.forEach(entry ->
|
||||||
|
{
|
||||||
|
TextComponent.Builder line = Component.text();
|
||||||
|
|
||||||
|
// Time
|
||||||
|
line.append(Component.text(Util.getTimeSince(entry.getTime(), time, false))
|
||||||
|
.color(NamedTextColor.GRAY));
|
||||||
|
|
||||||
|
// Action
|
||||||
|
Component action = Component.text(" interacted with ");
|
||||||
|
Component symbol = Component.text(" - ", NamedTextColor.WHITE);
|
||||||
|
switch (entry.getActionId())
|
||||||
|
{
|
||||||
|
case 0 ->
|
||||||
|
{
|
||||||
|
action = Component.text(" broke ");
|
||||||
|
symbol = Component.text(" - ", NamedTextColor.RED);
|
||||||
|
}
|
||||||
|
case 1 ->
|
||||||
|
{
|
||||||
|
action = Component.text(" placed ");
|
||||||
|
symbol = Component.text(" + ", NamedTextColor.GREEN);
|
||||||
|
}
|
||||||
|
case 2 -> action = Component.text(" clicked ");
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
// Do nothing (shuts Codacy up)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Symbol, player, action, block
|
||||||
|
line.append(symbol).append(Component.text(entry.getPlayer()).color(TextColor.color(0x30ade4)))
|
||||||
|
.append(action.color(NamedTextColor.WHITE)).append(
|
||||||
|
Component.text(entry.getBlockData().getMaterial().name().toLowerCase())
|
||||||
|
.color(TextColor.color(0x30ade4)));
|
||||||
|
|
||||||
|
// Rolled back?
|
||||||
|
if (entry.isRolledBack())
|
||||||
|
{
|
||||||
|
line.decorate(TextDecoration.STRIKETHROUGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(line.append(Component.text(".", NamedTextColor.WHITE)).build());
|
||||||
|
});
|
||||||
|
|
||||||
|
if (results.getPageCount() > 1)
|
||||||
|
{
|
||||||
|
player.sendMessage(Component.text("-----", NamedTextColor.WHITE));
|
||||||
|
|
||||||
|
// Page indicator
|
||||||
|
TextComponent.Builder indicator = Component.text();
|
||||||
|
|
||||||
|
// <-
|
||||||
|
if (pageNum > 1)
|
||||||
|
{
|
||||||
|
indicator.append(Component.text("◀ ", NamedTextColor.WHITE).clickEvent(
|
||||||
|
ClickEvent.runCommand("/ins history " + (pageNum - 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Page <current>/<total>
|
||||||
|
indicator.append(Component.text("Page ", TextColor.color(0x30ade4)).append(Component.text(pageNum + "/"
|
||||||
|
+ results.getPageCount(), NamedTextColor.WHITE)));
|
||||||
|
|
||||||
|
// ->
|
||||||
|
if (pageNum < results.getPageCount())
|
||||||
|
{
|
||||||
|
indicator.append(Component.text(" ▶", NamedTextColor.WHITE).clickEvent(
|
||||||
|
ClickEvent.runCommand("/ins history " + (pageNum + 1))));
|
||||||
|
}
|
||||||
|
|
||||||
|
// | Use /ins history <page> for advanced navigation
|
||||||
|
indicator.append(Component.text(" | ", NamedTextColor.GRAY).append(Component.text("Use ", NamedTextColor.WHITE)
|
||||||
|
.append(Component.text("/ins history <page>", TextColor.color(0x30ade4))
|
||||||
|
.clickEvent(ClickEvent.suggestCommand("/ins history ")))
|
||||||
|
.append(Component.text(" for advanced navigation", NamedTextColor.WHITE))));
|
||||||
|
|
||||||
|
player.sendMessage(indicator.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompletableFuture<FUtil.PaginationList<CoreProtectAPI.ParseResult>> lookupForPlayer(Block block, Player player)
|
||||||
|
{
|
||||||
|
cooldownMap.put(player.getUniqueId(), System.currentTimeMillis());
|
||||||
|
CoreProtectAPI api = getCoreProtectAPI();
|
||||||
|
|
||||||
|
return CompletableFuture.supplyAsync(() ->
|
||||||
|
{
|
||||||
|
historyMap.remove(player.getUniqueId());
|
||||||
|
FUtil.PaginationList<CoreProtectAPI.ParseResult> pages = new FUtil.PaginationList<>(10);
|
||||||
|
api.blockLookup(block, -1).forEach(stringArray -> pages.add(api.parseResult(stringArray)));
|
||||||
|
historyMap.put(player.getUniqueId(), pages);
|
||||||
|
return pages;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
// The inspector only works if we have CoreProtect installed
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if ((event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||||
|
&& plugin.pl.getData(player.getUniqueId()).hasInspection())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
Optional<Long> cooldown = Optional.ofNullable(cooldownMap.get(player.getUniqueId()));
|
||||||
|
|
||||||
|
if (cooldown.isPresent() && getSecondsLeft(cooldown.get(), 3) > 0L)
|
||||||
|
{
|
||||||
|
player.sendMessage(prefix.append(Component.text("You need to wait ")
|
||||||
|
.append(Component.text(getSecondsLeft(cooldown.get(), 3)))
|
||||||
|
.append(Component.text(" seconds before you can make another query."))
|
||||||
|
.color(NamedTextColor.WHITE)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Time to do a look-up.
|
||||||
|
if (block != null)
|
||||||
|
{
|
||||||
|
/* This is a hack to make it so that when you right-click, the coordinates that get used depend on
|
||||||
|
* what's in your hand. Non-blocks use the block you clicked directly, but blocks use wherever the
|
||||||
|
* block was supposed to be placed. */
|
||||||
|
ItemStack hand = player.getInventory().getItemInMainHand();
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && hand.getType().isBlock() && hand.getType() != Material.AIR)
|
||||||
|
{
|
||||||
|
block = block.getRelative(event.getBlockFace()).getState().getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
lookupForPlayer(block, player).thenAccept(results ->
|
||||||
|
{
|
||||||
|
if (results.isEmpty())
|
||||||
|
{
|
||||||
|
player.sendMessage(prefix.append(Component.text("No results were found.").color(NamedTextColor.WHITE)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
showPageToPlayer(player, results, 1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,9 +3,8 @@ package me.totalfreedom.totalfreedommod.bridge;
|
|||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.DisplayableGroup;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
@ -26,19 +25,16 @@ public class EssentialsBridge extends FreedomService
|
|||||||
|
|
||||||
private Essentials essentialsPlugin = null;
|
private Essentials essentialsPlugin = null;
|
||||||
|
|
||||||
public EssentialsBridge(TotalFreedomMod plugin)
|
@Override
|
||||||
|
public void onStart()
|
||||||
{
|
{
|
||||||
super(plugin);
|
// This is completely useless, but it's here to make sure the service is loaded.
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStop()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
{
|
||||||
|
essentialsPlugin = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Essentials getEssentialsPlugin()
|
public Essentials getEssentialsPlugin()
|
||||||
@ -48,9 +44,10 @@ public class EssentialsBridge extends FreedomService
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
||||||
if (essentials != null && essentials instanceof Essentials)
|
assert essentials != null;
|
||||||
|
if (essentials instanceof Essentials e)
|
||||||
{
|
{
|
||||||
essentialsPlugin = (Essentials)essentials;
|
essentialsPlugin = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -119,7 +116,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return FUtil.getField(user, "lastActivity");
|
return user.getLastOnlineActivity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -156,12 +153,12 @@ public class EssentialsBridge extends FreedomService
|
|||||||
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||||
{
|
{
|
||||||
final InventoryHolder inventoryHolder = inventory.getHolder();
|
final InventoryHolder inventoryHolder = inventory.getHolder();
|
||||||
if (inventoryHolder != null && inventoryHolder instanceof HumanEntity)
|
if (inventoryHolder instanceof HumanEntity)
|
||||||
{
|
{
|
||||||
Player invOwner = (Player)inventoryHolder;
|
Player invOwner = (Player)inventoryHolder;
|
||||||
Rank recieverRank = plugin.rm.getRank(player);
|
DisplayableGroup recieverRank = plugin.rm.getRank(player);
|
||||||
Rank playerRank = plugin.rm.getRank(invOwner);
|
DisplayableGroup playerRank = plugin.rm.getRank(invOwner);
|
||||||
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline())
|
if (playerRank.getWeight() >= recieverRank.getWeight() || !invOwner.isOnline())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
refreshPlayer = player;
|
refreshPlayer = player;
|
||||||
@ -209,16 +206,10 @@ public class EssentialsBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
final Essentials ess = getEssentialsPlugin();
|
final Essentials ess = getEssentialsPlugin();
|
||||||
|
|
||||||
return ess != null && ess.isEnabled();
|
return ess != null && ess.isEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,50 +1,40 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.BlockedDisguises;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class LibsDisguisesBridge extends FreedomService
|
public class LibsDisguisesBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
private static LibsDisguises libsDisguisesPlugin = null;
|
||||||
private LibsDisguises libsDisguisesPlugin = null;
|
|
||||||
|
|
||||||
public LibsDisguisesBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public LibsDisguises getLibsDisguisesPlugin()
|
public static LibsDisguises getLibsDisguisesPlugin()
|
||||||
{
|
{
|
||||||
if (libsDisguisesPlugin == null)
|
if (libsDisguisesPlugin == null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises");
|
final Plugin libsDisguises = Bukkit.getServer().getPluginManager().getPlugin("LibsDisguises");
|
||||||
if (libsDisguises != null)
|
if (libsDisguises instanceof LibsDisguises)
|
||||||
{
|
{
|
||||||
if (libsDisguises instanceof LibsDisguises)
|
libsDisguisesPlugin = (LibsDisguises) libsDisguises;
|
||||||
{
|
|
||||||
libsDisguisesPlugin = (LibsDisguises)libsDisguises;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
@ -53,24 +43,7 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
return libsDisguisesPlugin;
|
return libsDisguisesPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isDisguised(Player player)
|
public void undisguiseAll(boolean admin)
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
|
||||||
if (libsDisguises != null)
|
|
||||||
{
|
|
||||||
return DisguiseAPI.isDisguised(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void undisguiseAll(boolean admins)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -85,21 +58,25 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
if (DisguiseAPI.isDisguised(player))
|
if (DisguiseAPI.isDisguised(player))
|
||||||
{
|
{
|
||||||
if (!admins && plugin.al.isAdmin(player))
|
if (!admin && plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DisguiseAPI.undisguiseToAll(player);
|
DisguiseAPI.undisguiseToAll(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception ex)
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDisguisesEnabled(boolean state)
|
public boolean isDisguisesEnabled()
|
||||||
|
{
|
||||||
|
return !BlockedDisguises.disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setDisguisesEnabled(boolean state)
|
||||||
{
|
{
|
||||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
@ -111,15 +88,10 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
BlockedDisguises.disabled = !state;
|
BlockedDisguises.disabled = !state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDisguisesEnabled()
|
|
||||||
{
|
|
||||||
return !BlockedDisguises.disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
public boolean isEnabled()
|
||||||
{
|
{
|
||||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
return libsDisguises != null && libsDisguises.isEnabled();
|
return libsDisguises != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.GroupProvider;
|
||||||
|
import net.luckperms.api.LuckPerms;
|
||||||
|
import net.luckperms.api.track.TrackManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.bukkit.plugin.UnknownDependencyException;
|
||||||
|
|
||||||
|
public class LuckPermsBridge
|
||||||
|
{
|
||||||
|
private final LuckPerms luckPerms;
|
||||||
|
|
||||||
|
public LuckPermsBridge()
|
||||||
|
{
|
||||||
|
RegisteredServiceProvider<LuckPerms> provider = Bukkit.getServicesManager()
|
||||||
|
.getRegistration(LuckPerms.class);
|
||||||
|
|
||||||
|
if (provider == null) throw new UnknownDependencyException("LuckPerms must be present!");
|
||||||
|
|
||||||
|
this.luckPerms = provider.getProvider();
|
||||||
|
|
||||||
|
setupTracks();
|
||||||
|
}
|
||||||
|
|
||||||
|
public LuckPerms getAPI()
|
||||||
|
{
|
||||||
|
return luckPerms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupTracks()
|
||||||
|
{
|
||||||
|
TrackManager trackManager = getAPI().getTrackManager();
|
||||||
|
|
||||||
|
if (!trackManager.isLoaded("fakeOp"))
|
||||||
|
{
|
||||||
|
trackManager.createAndLoadTrack("fakeOp").whenComplete((track, exception) ->
|
||||||
|
{
|
||||||
|
track.appendGroup(GroupProvider.NON_OP.getGroup().getLuckPermsGroup());
|
||||||
|
track.appendGroup(GroupProvider.OP.getGroup().getLuckPermsGroup());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!trackManager.isLoaded("admin"))
|
||||||
|
{
|
||||||
|
trackManager.createAndLoadTrack("admin").whenComplete((track, exception) ->
|
||||||
|
{
|
||||||
|
track.appendGroup(GroupProvider.ADMIN.getGroup().getLuckPermsGroup());
|
||||||
|
track.appendGroup(GroupProvider.SENIOR_ADMIN.getGroup().getLuckPermsGroup());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!trackManager.isLoaded("builder"))
|
||||||
|
{
|
||||||
|
trackManager.createAndLoadTrack("builder").whenComplete((track, exception) ->
|
||||||
|
track.appendGroup(GroupProvider.MASTER_BUILDER.getGroup().getLuckPermsGroup()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,6 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -15,18 +14,13 @@ public class WorldEditBridge extends FreedomService
|
|||||||
//
|
//
|
||||||
private WorldEditPlugin worldeditPlugin = null;
|
private WorldEditPlugin worldeditPlugin = null;
|
||||||
|
|
||||||
public WorldEditBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,54 +48,6 @@ public class WorldEditBridge extends FreedomService
|
|||||||
return worldeditPlugin;
|
return worldeditPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undo(Player player, int count)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LocalSession session = getPlayerSession(player);
|
|
||||||
if (session != null)
|
|
||||||
{
|
|
||||||
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
|
||||||
if (bukkitPlayer != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
|
||||||
session.undo(session.getBlockBag(fuckyou), fuckyou);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void redo(Player player, int count)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LocalSession session = getPlayerSession(player);
|
|
||||||
if (session != null)
|
|
||||||
{
|
|
||||||
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
|
||||||
if (bukkitPlayer != null)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
|
||||||
session.redo(session.getBlockBag(fuckyou), fuckyou);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLimit(Player player, int limit)
|
public void setLimit(Player player, int limit)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -161,23 +107,4 @@ public class WorldEditBridge extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BukkitPlayer getBukkitPlayer(Player player)
|
|
||||||
{
|
|
||||||
final WorldEditPlugin wep = getWorldEditPlugin();
|
|
||||||
if (wep == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return wep.wrapPlayer(player);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.caging;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -12,141 +11,21 @@ import org.bukkit.block.Skull;
|
|||||||
public class CageData
|
public class CageData
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private static String input = null;
|
||||||
private final FPlayer fPlayer;
|
private final FPlayer fPlayer;
|
||||||
//
|
//
|
||||||
private final List<BlockData> cageHistory = new ArrayList<>();
|
|
||||||
//
|
//
|
||||||
@Getter
|
private final List<BlockData> cageHistory = new ArrayList<>();
|
||||||
private boolean caged = false;
|
private boolean caged = false;
|
||||||
@Getter
|
|
||||||
private Location location;
|
private Location location;
|
||||||
@Getter
|
|
||||||
private Material outerMaterial = Material.GLASS;
|
private Material outerMaterial = Material.GLASS;
|
||||||
@Getter
|
|
||||||
private Material innerMaterial = Material.AIR;
|
private Material innerMaterial = Material.AIR;
|
||||||
@Getter
|
|
||||||
private static String input = null;
|
|
||||||
|
|
||||||
public CageData(FPlayer player)
|
public CageData(FPlayer player)
|
||||||
{
|
{
|
||||||
this.fPlayer = player;
|
this.fPlayer = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCaged(boolean cage)
|
|
||||||
{
|
|
||||||
if (cage)
|
|
||||||
{
|
|
||||||
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.caged = false;
|
|
||||||
regenerateHistory();
|
|
||||||
clearHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cage(Location location, Material outer, Material inner)
|
|
||||||
{
|
|
||||||
if (isCaged())
|
|
||||||
{
|
|
||||||
setCaged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.caged = true;
|
|
||||||
this.location = location;
|
|
||||||
this.outerMaterial = outer;
|
|
||||||
this.innerMaterial = inner;
|
|
||||||
this.input = null;
|
|
||||||
|
|
||||||
buildHistory(location, 2, fPlayer);
|
|
||||||
regenerate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cage(Location location, Material outer, Material inner, String input)
|
|
||||||
{
|
|
||||||
if (isCaged())
|
|
||||||
{
|
|
||||||
setCaged(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.caged = true;
|
|
||||||
this.location = location;
|
|
||||||
this.outerMaterial = outer;
|
|
||||||
this.innerMaterial = inner;
|
|
||||||
this.input = input;
|
|
||||||
|
|
||||||
buildHistory(location, 2, fPlayer);
|
|
||||||
regenerate();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void regenerate()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!caged
|
|
||||||
|| location == null
|
|
||||||
|| outerMaterial == null
|
|
||||||
|| innerMaterial == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
generateHollowCube(location, 2, outerMaterial);
|
|
||||||
generateCube(location, 1, innerMaterial);
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: EventHandlerize this?
|
|
||||||
public void playerJoin()
|
|
||||||
{
|
|
||||||
if (!isCaged())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playerQuit()
|
|
||||||
{
|
|
||||||
regenerateHistory();
|
|
||||||
clearHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearHistory()
|
|
||||||
{
|
|
||||||
cageHistory.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void insertHistoryBlock(Location location, Material material)
|
|
||||||
{
|
|
||||||
cageHistory.add(new BlockData(location, material));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void regenerateHistory()
|
|
||||||
{
|
|
||||||
for (BlockData blockdata : this.cageHistory)
|
|
||||||
{
|
|
||||||
blockdata.location.getBlock().setType(blockdata.material);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildHistory(Location location, int length, FPlayer playerdata)
|
|
||||||
{
|
|
||||||
final Block center = location.getBlock();
|
|
||||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
|
||||||
{
|
|
||||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
|
||||||
{
|
|
||||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
|
||||||
{
|
|
||||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
|
||||||
insertHistoryBlock(block.getLocation(), block.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Util methods
|
// Util methods
|
||||||
public static void generateCube(Location location, int length, Material material)
|
public static void generateCube(Location location, int length, Material material)
|
||||||
{
|
{
|
||||||
@ -167,6 +46,7 @@ public class CageData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public static void generateHollowCube(Location location, int length, Material material)
|
public static void generateHollowCube(Location location, int length, Material material)
|
||||||
{
|
{
|
||||||
final Block center = location.getBlock();
|
final Block center = location.getBlock();
|
||||||
@ -213,7 +93,7 @@ public class CageData
|
|||||||
skull.setOwner(input);
|
skull.setOwner(input);
|
||||||
skull.update();
|
skull.update();
|
||||||
}
|
}
|
||||||
catch (ClassCastException e)
|
catch (ClassCastException ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -223,6 +103,176 @@ public class CageData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getInput()
|
||||||
|
{
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setInput(String input)
|
||||||
|
{
|
||||||
|
CageData.input = input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
input = null; // TODO: Remove static variable declaration in a non-static block.
|
||||||
|
|
||||||
|
buildHistory(location);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner, String input)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
CageData.input = input; // TODO: Remove static variable declaration in a non-static block.
|
||||||
|
|
||||||
|
buildHistory(location);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void regenerate()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!caged
|
||||||
|
|| location == null
|
||||||
|
|| outerMaterial == null
|
||||||
|
|| innerMaterial == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateHollowCube(location, 2, outerMaterial);
|
||||||
|
generateCube(location, 1, innerMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: EventHandler this?
|
||||||
|
public void playerJoin()
|
||||||
|
{
|
||||||
|
if (!isCaged())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerQuit()
|
||||||
|
{
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearHistory()
|
||||||
|
{
|
||||||
|
cageHistory.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertHistoryBlock(Location location, Material material)
|
||||||
|
{
|
||||||
|
cageHistory.add(new BlockData(location, material));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void regenerateHistory()
|
||||||
|
{
|
||||||
|
for (BlockData blockdata : this.cageHistory)
|
||||||
|
{
|
||||||
|
blockdata.location.getBlock().setType(blockdata.material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildHistory(Location location)
|
||||||
|
{
|
||||||
|
final Block center = location.getBlock();
|
||||||
|
for (int xOffset = -2; xOffset <= 2; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -2; yOffset <= 2; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -2; zOffset <= 2; zOffset++)
|
||||||
|
{
|
||||||
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
insertHistoryBlock(block.getLocation(), block.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FPlayer getfPlayer()
|
||||||
|
{
|
||||||
|
return fPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<BlockData> getCageHistory()
|
||||||
|
{
|
||||||
|
return cageHistory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCaged()
|
||||||
|
{
|
||||||
|
return caged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaged(boolean cage)
|
||||||
|
{
|
||||||
|
if (cage)
|
||||||
|
{
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caged = false;
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation()
|
||||||
|
{
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(Location location)
|
||||||
|
{
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getOuterMaterial()
|
||||||
|
{
|
||||||
|
return outerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOuterMaterial(Material outerMaterial)
|
||||||
|
{
|
||||||
|
this.outerMaterial = outerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Material getInnerMaterial()
|
||||||
|
{
|
||||||
|
return innerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInnerMaterial(Material innerMaterial)
|
||||||
|
{
|
||||||
|
this.innerMaterial = innerMaterial;
|
||||||
|
}
|
||||||
|
|
||||||
private static class BlockData
|
private static class BlockData
|
||||||
{
|
{
|
||||||
|
|
@ -1,7 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.caging;
|
package me.totalfreedom.totalfreedommod.caging;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -17,19 +18,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
|
|
||||||
public class Cager extends FreedomService
|
public class Cager extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public Cager(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,8 +32,7 @@ public class Cager extends FreedomService
|
|||||||
public void onBreakBlock(BlockBreakEvent event)
|
public void onBreakBlock(BlockBreakEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player == null
|
if (plugin.al.isAdmin(player))
|
||||||
|| plugin.al.isAdmin(player))
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,7 +61,7 @@ public class Cager extends FreedomService
|
|||||||
Location cageLoc = cage.getLocation();
|
Location cageLoc = cage.getLocation();
|
||||||
|
|
||||||
final boolean outOfCage;
|
final boolean outOfCage;
|
||||||
if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
|
if (!Objects.equals(playerLoc.getWorld(), cageLoc.getWorld()))
|
||||||
{
|
{
|
||||||
outOfCage = true;
|
outOfCage = true;
|
||||||
}
|
}
|
||||||
@ -78,7 +72,7 @@ public class Cager extends FreedomService
|
|||||||
|
|
||||||
if (outOfCage)
|
if (outOfCage)
|
||||||
{
|
{
|
||||||
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
|
PaperLib.teleportAsync(player.getPlayer(), cageLoc.subtract(0, 0.1, 0));
|
||||||
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
||||||
cage.regenerate();
|
cage.regenerate();
|
||||||
}
|
}
|
||||||
@ -119,5 +113,4 @@ public class Cager extends FreedomService
|
|||||||
cage.playerJoin();
|
cage.playerJoin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -0,0 +1,10 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface CommandDependencies
|
||||||
|
{
|
||||||
|
String[] value();
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
|
public class CommandLoader extends FreedomService
|
||||||
|
{
|
||||||
|
private final List<FreedomCommand> commands;
|
||||||
|
|
||||||
|
public CommandLoader()
|
||||||
|
{
|
||||||
|
commands = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(FreedomCommand command)
|
||||||
|
{
|
||||||
|
commands.add(command);
|
||||||
|
command.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FreedomCommand getByName(String name)
|
||||||
|
{
|
||||||
|
for (FreedomCommand command : commands)
|
||||||
|
{
|
||||||
|
if (name.equals(command.getName()))
|
||||||
|
{
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlias(String alias)
|
||||||
|
{
|
||||||
|
for (FreedomCommand command : commands)
|
||||||
|
{
|
||||||
|
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadCommands()
|
||||||
|
{
|
||||||
|
Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
|
||||||
|
|
||||||
|
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
|
||||||
|
|
||||||
|
commandLoading:
|
||||||
|
for (Class<? extends FreedomCommand> commandClass : commandClasses)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (commandClass.isAnnotationPresent(CommandDependencies.class))
|
||||||
|
{
|
||||||
|
String[] dependencies = commandClass.getAnnotation(CommandDependencies.class).value();
|
||||||
|
|
||||||
|
for (String plugin : dependencies)
|
||||||
|
{
|
||||||
|
if (!server.getPluginManager().isPluginEnabled(plugin))
|
||||||
|
{
|
||||||
|
FLog.warning("Not loading command due to missing dependency (" + plugin + "): /" + commandClass.getSimpleName().replace("Command_", ""));
|
||||||
|
continue commandLoading;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
add(commandClass.newInstance());
|
||||||
|
}
|
||||||
|
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Loaded " + commands.size() + " commands");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FreedomCommand> getCommands()
|
||||||
|
{
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
}
|
@ -2,15 +2,14 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface CommandPermissions
|
public @interface CommandPermissions
|
||||||
{
|
{
|
||||||
|
|
||||||
Rank level();
|
String permission() default "default";
|
||||||
|
|
||||||
SourceType source();
|
SourceType source() default SourceType.BOTH;
|
||||||
|
|
||||||
boolean blockHostConsole() default false;
|
boolean blockHostConsole() default false;
|
||||||
|
|
@ -1,17 +1,14 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "adminchat", source = SourceType.BOTH)
|
||||||
@CommandParameters(
|
@CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc,ac,staffchat")
|
||||||
description = "Talk privately with other administrators on the server.",
|
|
||||||
usage = "/<command> [message...]",
|
|
||||||
aliases = "o,ac")
|
|
||||||
public class Command_adminchat extends FreedomCommand
|
public class Command_adminchat extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -22,19 +19,17 @@ public class Command_adminchat extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("You must be in-game to toggle admin chat, it cannot be toggled via CONSOLE or Telnet.");
|
msgNew("<red>You must be in-game to toggle admin chat, it cannot be toggled via CONSOLE or Telnet.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
|
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
|
||||||
userinfo.setAdminChat(!userinfo.inAdminChat());
|
userinfo.setAdminChat(!userinfo.inAdminChat());
|
||||||
msg("Toggled your admin chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
msgNew("Admin chat turned <status>.", Placeholder.unparsed("status", userinfo.inAdminChat() ? "on" : "off"));
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
{
|
||||||
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
|
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,16 +2,12 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(permission = "admininfo", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "ai")
|
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "si,ai,staffinfo")
|
||||||
public class Command_admininfo extends FreedomCommand
|
public class Command_admininfo extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -22,13 +18,13 @@ public class Command_admininfo extends FreedomCommand
|
|||||||
|
|
||||||
if (adminInfo.isEmpty())
|
if (adminInfo.isEmpty())
|
||||||
{
|
{
|
||||||
msg("The admin information section of the config.yml file has not been configured.", ChatColor.RED);
|
msgNew("<red>The admin information section of the config.yml file has not been configured.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
msg(FUtil.colorize(StringUtils.join(adminInfo, "\n")));
|
adminInfo.forEach(this::msgNew);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,14 +4,14 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "adminmode", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]")
|
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]", aliases = "staffmode")
|
||||||
public class Command_adminmode extends FreedomCommand
|
public class Command_adminmode extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,20 +26,15 @@ public class Command_adminmode extends FreedomCommand
|
|||||||
if (args[0].equalsIgnoreCase("off"))
|
if (args[0].equalsIgnoreCase("off"))
|
||||||
{
|
{
|
||||||
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
|
||||||
FUtil.adminAction(sender.getName(), "Opening the server to all players.", true);
|
FUtil.adminAction(sender.getName(), "Opening the server to all players", true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("on"))
|
else if (args[0].equalsIgnoreCase("on"))
|
||||||
{
|
{
|
||||||
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
||||||
FUtil.adminAction(sender.getName(), "Closing the server to non-admins.", true);
|
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().filter(player -> !isAdmin(player)).forEach(player ->
|
||||||
{
|
player.kick(Component.text("The server is now closed to non-admins.")));
|
||||||
if (!isAdmin(player))
|
|
||||||
{
|
|
||||||
player.kickPlayer("Server is now closed to non-admins.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,4 +51,4 @@ public class Command_adminmode extends FreedomCommand
|
|||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,192 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "adminworld", source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Allows for admins to configure time, and weather of the AdminWorld, and allows for admins and ops to go to the AdminWorld.",
|
||||||
|
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
||||||
|
aliases = "sw,aw,staffworld")
|
||||||
|
public class Command_adminworld extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
CommandMode commandMode = null;
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.TELEPORT;
|
||||||
|
}
|
||||||
|
else if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if ("time".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.TIME;
|
||||||
|
}
|
||||||
|
else if ("weather".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.WEATHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandMode == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (commandMode)
|
||||||
|
{
|
||||||
|
case TELEPORT ->
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player) || playerSender == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
World adminWorld = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
adminWorld = plugin.wm.adminworld.getWorld();
|
||||||
|
} catch (Exception ignored)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adminWorld == null || playerSender.getWorld() == adminWorld)
|
||||||
|
{
|
||||||
|
msgNew("Going to the main world.");
|
||||||
|
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
msgNew("Going to the AdminWorld.");
|
||||||
|
plugin.wm.adminworld.sendToWorld(playerSender);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case TIME ->
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
|
||||||
|
if (timeOfDay != null)
|
||||||
|
{
|
||||||
|
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
|
||||||
|
msgNew("AdminWorld time set to: <time>", Placeholder.unparsed("time", timeOfDay.name()));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
msgNew("<red>Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
case WEATHER ->
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
|
||||||
|
if (weatherMode != null)
|
||||||
|
{
|
||||||
|
plugin.wm.adminworld.setWeatherMode(weatherMode);
|
||||||
|
msgNew("AdminWorld weather set to <mode>.", Placeholder.unparsed("mode", weatherMode.name()));
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
msgNew("<red>Invalid weather mode. Can be: off, rain, storm");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (PermissionDeniedException ex)
|
||||||
|
{
|
||||||
|
if (ex.getMessage().isEmpty())
|
||||||
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
msgNew("<red>" + ex.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Redo this properly
|
||||||
|
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player) || playerSender == null || !sender.hasPermission("tfm.adminworld.manage"))
|
||||||
|
{
|
||||||
|
throw new PermissionDeniedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
return Arrays.asList("time", "weather");
|
||||||
|
}
|
||||||
|
else if (args.length == 2)
|
||||||
|
{
|
||||||
|
if (args[0].equals("time"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("morning", "noon", "evening", "night");
|
||||||
|
}
|
||||||
|
else if (args[0].equals("weather"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("off", "rain", "storm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum CommandMode
|
||||||
|
{
|
||||||
|
TELEPORT, TIME, WEATHER
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class PermissionDeniedException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private PermissionDeniedException()
|
||||||
|
{
|
||||||
|
super("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private PermissionDeniedException(String string)
|
||||||
|
{
|
||||||
|
super(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,17 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "announce", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
||||||
public class Command_announce extends FreedomCommand
|
public class Command_announce extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
@ -22,5 +21,4 @@ public class Command_announce extends FreedomCommand
|
|||||||
plugin.an.announce(StringUtils.join(args, " "));
|
plugin.an.announce(StringUtils.join(args, " "));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -1,11 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "autoclear", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
||||||
public class Command_autoclear extends FreedomCommand
|
public class Command_autoclear extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -29,7 +29,8 @@ public class Command_autoclear extends FreedomCommand
|
|||||||
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
|
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " have their inventory cleared when they join.");
|
msgNew("<player> will <status> have their inventory cleared when they join.",
|
||||||
|
Placeholder.unparsed("player", args[0]), Placeholder.unparsed("status", enabled ? "no longer" : "now"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "autotp", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
||||||
public class Command_autotp extends FreedomCommand
|
public class Command_autotp extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -29,8 +29,8 @@ public class Command_autotp extends FreedomCommand
|
|||||||
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
|
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " be automatically teleported when they join.");
|
msgNew("<player> will <status> be automatically teleported when they join.",
|
||||||
|
Placeholder.unparsed("player", args[0]), Placeholder.unparsed("status", enabled ? "no longer" : "now"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,182 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "ban", source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
||||||
|
public class Command_ban extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
boolean silent = false;
|
||||||
|
boolean cancelRollback = false;
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
|
||||||
|
{
|
||||||
|
cancelRollback = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final String username;
|
||||||
|
final String ip;
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
// Gets the IP using Essentials data if available
|
||||||
|
if (plugin.esb.isEnabled() && plugin.esb.getEssentialsUser(args[0]) != null)
|
||||||
|
{
|
||||||
|
User essUser = plugin.esb.getEssentialsUser(args[0]);
|
||||||
|
//
|
||||||
|
username = essUser.getName();
|
||||||
|
ip = essUser.getLastLoginAddress();
|
||||||
|
}
|
||||||
|
// Last resort - Getting the first result from the username itself
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlayerData entry = plugin.pl.getData(args[0]);
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
username = entry.getName();
|
||||||
|
ip = entry.getIps().get(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
username = player.getName();
|
||||||
|
ip = FUtil.getIp(player);
|
||||||
|
|
||||||
|
// Deop
|
||||||
|
player.setOp(false);
|
||||||
|
|
||||||
|
// Gamemode survival
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
// Clear inventory
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
// Strike with lightning
|
||||||
|
final Location targetPos = player.getLocation();
|
||||||
|
for (int x = -1; x <= 1; x++)
|
||||||
|
{
|
||||||
|
for (int z = -1; z <= 1; z++)
|
||||||
|
{
|
||||||
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||||
|
Objects.requireNonNull(targetPos.getWorld()).strikeLightning(strike_pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msgNew("Banned <player> quietly.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
}
|
||||||
|
// Kill player
|
||||||
|
player.setHealth(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks if CoreProtect is loaded and installed, and skips the rollback and uses CoreProtect directly
|
||||||
|
if (!cancelRollback)
|
||||||
|
{
|
||||||
|
plugin.cpb.rollback(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null && !silent)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban player
|
||||||
|
Ban ban;
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
ban = Ban.forPlayer(player, sender, null, reason);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ban = Ban.forPlayerName(username, sender, null, reason);
|
||||||
|
}
|
||||||
|
ban.addIp(ip);
|
||||||
|
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
// Broadcast
|
||||||
|
final StringBuilder bcast = new StringBuilder()
|
||||||
|
.append("Banning: ")
|
||||||
|
.append(username);
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||||
|
}
|
||||||
|
msgNew("<name> has been banned and their IP is <ip>.",
|
||||||
|
Placeholder.unparsed("name", username),
|
||||||
|
Placeholder.unparsed("ip", ip));
|
||||||
|
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick player and handle others on IP
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
|
||||||
|
server.getOnlinePlayers().stream().filter(pl -> FUtil.getIp(pl).equalsIgnoreCase(ip)).forEach(pl ->
|
||||||
|
player.kickPlayer(ban.bakeKickMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log ban
|
||||||
|
plugin.pul.logPunishment(new Punishment(username, ip, sender.getName(), PunishmentType.BAN, reason));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "banip", source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]")
|
||||||
|
public class Command_banip extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean silent = false;
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
|
||||||
|
String ip = args[0];
|
||||||
|
|
||||||
|
if (FUtil.isValidIPv4(ip))
|
||||||
|
{
|
||||||
|
msgNew("<red><ip> is not a valid IP address.", Placeholder.unparsed("ip", ip));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.bm.getByIp(ip) != null)
|
||||||
|
{
|
||||||
|
msgNew("<red>The IP <ip> is already banned.", Placeholder.unparsed("ip", ip));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban player
|
||||||
|
Ban ban = Ban.forPlayerIp(ip, sender, null, reason);
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
|
// Kick player and handle others on IP
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> FUtil.getIp(player).equalsIgnoreCase(ip)).forEach(player ->
|
||||||
|
player.kickPlayer(ban.bakeKickMessage()));
|
||||||
|
|
||||||
|
// Broadcasts the message
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
plugin.cm.broadcastSplit("<red><sender> - Banned the IP <ip>", "<red><sender> - Banned an IP", Placeholder.unparsed("ip", ip));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "banlist", source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Shows all banned player names. Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||||
|
public class Command_banlist extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
|
{
|
||||||
|
checkPermission("tfm.banlist.purge");
|
||||||
|
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||||
|
msgNew("<green>Purged <amount> player bans.", Placeholder.unparsed("amount", String.valueOf(plugin.bm.purge())));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
msgNew("<total> player bans (<usernames> usernames, <ips> IPs)",
|
||||||
|
Placeholder.unparsed("total", String.valueOf(plugin.bm.getAllBans().size())),
|
||||||
|
Placeholder.unparsed("usernames", String.valueOf(plugin.bm.getUsernameBans())),
|
||||||
|
Placeholder.unparsed("ips", String.valueOf(plugin.bm.getIpBans().size())));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
return args.length == 1 && sender.hasPermission("tfm.banlist.purge") ? Collections.singletonList("purge") : Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "banname", source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]")
|
||||||
|
public class Command_banname extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean silent = false;
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
|
||||||
|
String name = args[0];
|
||||||
|
|
||||||
|
if (plugin.bm.getByUsername(name) != null)
|
||||||
|
{
|
||||||
|
msgNew("<red>The name <name> is already banned.", Placeholder.unparsed("name", name));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban player
|
||||||
|
Ban ban = Ban.forPlayerName(name, sender, null, reason);
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Banned the name " + name, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer(name);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -2,15 +2,14 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import java.util.SplittableRandom;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(permission = "bird", source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
||||||
public class Command_bird extends FreedomCommand
|
public class Command_bird extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -20,14 +19,14 @@ public class Command_bird extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
||||||
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
||||||
msg(":goodbird:");
|
msgNew("<rainbow>:goodbird:");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityType getRandomFish()
|
public EntityType getRandomFish()
|
||||||
{
|
{
|
||||||
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
||||||
Random random = new Random();
|
SplittableRandom random = new SplittableRandom();
|
||||||
return fishTypes.get(random.nextInt(fishTypes.size()));
|
return fishTypes.get(random.nextInt(fishTypes.size()));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,14 +1,15 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "blockcmd", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
||||||
public class Command_blockcmd extends FreedomCommand
|
public class Command_blockcmd extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -34,7 +35,8 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
playerdata.setCommandsBlocked(false);
|
playerdata.setCommandsBlocked(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg("Unblocked commands for " + counter + " players.");
|
|
||||||
|
msgNew("Unblocked commands for <count> players.", Placeholder.unparsed("count", String.valueOf(counter)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,10 +53,10 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
counter += 1;
|
counter += 1;
|
||||||
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||||
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
msgNew(player, "<red>Your commands have been blocked by an admin.");
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Blocked commands for " + counter + " players.");
|
msgNew("Blocked commands for <count> players.", Placeholder.unparsed("count", String.valueOf(counter)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,23 +64,29 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin(player))
|
if (isAdmin(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
msgNew("<player> is an admin, and cannot have their commands blocked.", Placeholder.unparsed("player", player.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
if (!playerdata.allCommandsBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||||
|
playerdata.setCommandsBlocked(true);
|
||||||
|
msgNew("Blocked commands for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
|
||||||
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.BLOCKCMD, null));
|
||||||
|
}
|
||||||
FUtil.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
|
else
|
||||||
msg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
|
{
|
||||||
|
msgNew("<red>That player's commands are already blocked.");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,113 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "blockedit", source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Restricts/restores block modification abilities for everyone on the server or a certain player.", usage = "/<command> [<player> [reason] | list | purge | all]")
|
||||||
|
public class Command_blockedit extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
switch (args[0].toLowerCase())
|
||||||
|
{
|
||||||
|
case "list" ->
|
||||||
|
{
|
||||||
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
plugin.pl.getPlayer(player).isEditBlocked()).sorted().toList();
|
||||||
|
|
||||||
|
boolean plural = list.size() != 1;
|
||||||
|
msgNew("There <grammar> <count> player<plural> online with restricted block modification abilities: <players>",
|
||||||
|
Placeholder.unparsed("grammar", plural ? "are" : "is"),
|
||||||
|
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||||
|
Placeholder.unparsed("plural", plural ? "s" : ""),
|
||||||
|
Placeholder.unparsed("colon", list.size() > 0 ? ":" : "."),
|
||||||
|
Placeholder.unparsed("players", FUtil.listToString(list.stream().map(HumanEntity::getName).toList())));
|
||||||
|
}
|
||||||
|
case "purge" ->
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restoring block modification abilities for all players", true);
|
||||||
|
|
||||||
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
plugin.pl.getPlayer(player).isEditBlocked()).toList();
|
||||||
|
|
||||||
|
list.forEach(player ->
|
||||||
|
{
|
||||||
|
plugin.pl.getPlayer(player).setEditBlocked(false);
|
||||||
|
msgNew(player, "<green>Your block modification abilities have been restored.");
|
||||||
|
});
|
||||||
|
|
||||||
|
msgNew("Restored block modification abilities for <count> player<plural>.",
|
||||||
|
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||||
|
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||||
|
}
|
||||||
|
case "all", "-a" ->
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for all non-admins", true);
|
||||||
|
|
||||||
|
List<? extends Player> list = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
!plugin.al.isAdmin(player)).toList();
|
||||||
|
|
||||||
|
list.forEach(player ->
|
||||||
|
{
|
||||||
|
plugin.pl.getPlayer(player).setEditBlocked(true);
|
||||||
|
msgNew(player, "<red>Your block modification abilities have been restricted.");
|
||||||
|
});
|
||||||
|
|
||||||
|
msgNew("Restricted block modification abilities for <count> player<plural>.",
|
||||||
|
Placeholder.unparsed("count", String.valueOf(list.size())),
|
||||||
|
Placeholder.unparsed("plural", list.size() != 1 ? "s" : ""));
|
||||||
|
}
|
||||||
|
default -> Optional.ofNullable(getPlayer(args[0])).ifPresentOrElse(player ->
|
||||||
|
{
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (fPlayer.isEditBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restoring block modification abilities for " + player.getName(), true);
|
||||||
|
fPlayer.setEditBlocked(false);
|
||||||
|
msgNew("Restored block modification abilities for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
msgNew(player, "<green>Your block modification abilities have been restored.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
msgNew("<red><player> is an admin, and as such cannot have their block modification abilities restricted.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restricting block modification abilities for " + player.getName(), true);
|
||||||
|
fPlayer.setEditBlocked(true);
|
||||||
|
msgNew("Restricted block modification abilities for <player>.", Placeholder.unparsed("player", player.getName()));
|
||||||
|
msgNew(player, "<red>Your block modification abilities have been restricted.");
|
||||||
|
|
||||||
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player),
|
||||||
|
sender.getName(), PunishmentType.BLOCKEDIT, null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}, () -> msg(PLAYER_NOT_FOUND));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "blockpvp", source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [<player> | list | purge | all]", aliases = "pvpblock,pvpmode")
|
||||||
|
public class Command_blockpvp extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args[0].toLowerCase())
|
||||||
|
{
|
||||||
|
// List
|
||||||
|
case "list" ->
|
||||||
|
{
|
||||||
|
List<String> restricted = server.getOnlinePlayers().stream().filter(player ->
|
||||||
|
plugin.pl.getPlayer(player).isPvpBlocked()).map(Player::getName).toList();
|
||||||
|
|
||||||
|
if (restricted.isEmpty())
|
||||||
|
{
|
||||||
|
msgNew("Nobody currently has their PVP abilities restricted.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msgNew("PVP abilities are restricted for these player(s): <players>",
|
||||||
|
Placeholder.unparsed("players", FUtil.listToString(restricted)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Purge
|
||||||
|
case "purge" ->
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restoring PVP abilities for all players", true);
|
||||||
|
List<? extends Player> affected = server.getOnlinePlayers().stream().filter(player -> plugin.pl.getPlayer(player).isPvpBlocked()).toList();
|
||||||
|
affected.forEach(player ->
|
||||||
|
{
|
||||||
|
msgNew(player, "<green>Your PVP abilities have been restored.");
|
||||||
|
plugin.pl.getPlayer(player).setPvpBlocked(false);
|
||||||
|
});
|
||||||
|
msgNew("Restored PVP abilities for <count> players.", Placeholder.unparsed("count", String.valueOf(affected.size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// All
|
||||||
|
case "all" ->
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restricting PVP capabilities for all non-admins", true);
|
||||||
|
List<? extends Player> affected = server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).toList();
|
||||||
|
affected.forEach(player ->
|
||||||
|
{
|
||||||
|
msgNew(player, "<red>Your PVP abilities have been restricted.");
|
||||||
|
plugin.pl.getPlayer(player).setPvpBlocked(true);
|
||||||
|
});
|
||||||
|
msgNew("Restricted PVP abilities for <count> players.", Placeholder.unparsed("count", String.valueOf(affected.size())));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific players
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
final Player p = getPlayer(args[0]);
|
||||||
|
if (p == null)
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||||
|
if (pd.isPvpBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Restoring PVP capabilities for " + p.getName(), true);
|
||||||
|
pd.setPvpBlocked(false);
|
||||||
|
msgNew("Enabled the ability to PVP for <player>.", Placeholder.unparsed("player", p.getName()));
|
||||||
|
msgNew(p, "<green>Your PVP abilities have been restored.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(p))
|
||||||
|
{
|
||||||
|
msgNew("<red><player> is an admin, and cannot have their PVP disabled.", Placeholder.unparsed("player", p.getName()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Restricting PVP for " + p.getName(), true);
|
||||||
|
pd.setPvpBlocked(true);
|
||||||
|
plugin.pul.logPunishment(new Punishment(p.getName(), FUtil.getIp(p), sender.getName(), PunishmentType.BLOCKPVP, null));
|
||||||
|
|
||||||
|
msgNew(p, "<red>Your PVP abilities have been restricted.");
|
||||||
|
msgNew("Restricted PVP abilities for <player>. ", Placeholder.unparsed("player", p.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,14 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "blockredstone", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
||||||
public class Command_blockredstone extends FreedomCommand
|
public class Command_blockredstone extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -38,4 +37,4 @@ public class Command_blockredstone extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,9 +5,9 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -15,42 +15,41 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(permission = "cage", source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | off | <partialname> [head | block] [playername | blockname]")
|
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||||
public class Command_cage extends FreedomCommand
|
public class Command_cage extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String skullName = null;
|
String skullName = null;
|
||||||
if ("off".equals(args[0]) && sender instanceof Player)
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
|
||||||
playerdata.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ("purge".equals(args[0]))
|
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
server.getOnlinePlayers().stream().map(player -> plugin.pl.getPlayer(player)).forEach(fPlayer ->
|
||||||
{
|
fPlayer.getCageData().setCaged(false));
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
|
||||||
fPlayer.getCageData().setCaged(false);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = getPlayer(args[0]);
|
Player player = getPlayer(args[0]);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
msg(PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
if (fPlayer.getCageData().isCaged())
|
||||||
|
{
|
||||||
|
msgNew("<red>That player is already caged.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Material outerMaterial = Material.GLASS;
|
Material outerMaterial = Material.GLASS;
|
||||||
Material innerMaterial = Material.AIR;
|
Material innerMaterial = Material.AIR;
|
||||||
if (args.length >= 2 && args[1] != null)
|
if (args.length >= 2 && args[1] != null)
|
||||||
@ -58,13 +57,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
final String s = args[1];
|
final String s = args[1];
|
||||||
switch (s)
|
switch (s)
|
||||||
{
|
{
|
||||||
case "off":
|
case "head" ->
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
|
||||||
fPlayer.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head":
|
|
||||||
{
|
{
|
||||||
outerMaterial = Material.PLAYER_HEAD;
|
outerMaterial = Material.PLAYER_HEAD;
|
||||||
if (args.length >= 3)
|
if (args.length >= 3)
|
||||||
@ -75,22 +68,47 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
outerMaterial = Material.SKELETON_SKULL;
|
outerMaterial = Material.SKELETON_SKULL;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case "block":
|
case "block" ->
|
||||||
{
|
{
|
||||||
if (Material.matchMaterial(args[2]) != null)
|
if (args.length >= 3)
|
||||||
{
|
{
|
||||||
outerMaterial = Material.matchMaterial(args[2]);
|
// Checks the validity of the Material and checks if it's a block.
|
||||||
break;
|
// This is incredibly inefficient, as Spigot's isBlock() method in Material is an actual
|
||||||
|
// nightmare of switch-cases.
|
||||||
|
if (Material.matchMaterial(args[2]) != null && Material.matchMaterial(args[2]).isBlock())
|
||||||
|
{
|
||||||
|
outerMaterial = Material.matchMaterial(args[2]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msgNew("<red>Invalid block!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.RED + "Invalid block!");
|
else
|
||||||
break;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default ->
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (outerMaterial == Material.PLAYER_HEAD)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
||||||
|
}
|
||||||
|
|
||||||
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
||||||
|
|
||||||
if (skullName != null)
|
if (skullName != null)
|
||||||
{
|
{
|
||||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
||||||
@ -100,14 +118,8 @@ public class Command_cage extends FreedomCommand
|
|||||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||||
}
|
}
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
if (outerMaterial == Material.PLAYER_HEAD)
|
|
||||||
{
|
plugin.pul.logPunishment(new Punishment(player.getName(), FUtil.getIp(player), sender.getName(), PunishmentType.CAGE, null));
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,14 +142,14 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!args[0].equals("purge"))
|
if (!args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
return Arrays.asList("off", "head", "block");
|
return Arrays.asList("head", "block");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.length == 3)
|
else if (args.length == 3)
|
||||||
{
|
{
|
||||||
if (args[1].equals("block"))
|
if (args[1].equals("block"))
|
||||||
{
|
{
|
||||||
return FUtil.getAllMaterialNames();
|
return Arrays.stream(Material.values()).map(Enum::name).toList();
|
||||||
}
|
}
|
||||||
else if (args[1].equals("head"))
|
else if (args[1].equals("head"))
|
||||||
{
|
{
|
||||||
@ -147,4 +159,4 @@ public class Command_cage extends FreedomCommand
|
|||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "cake", source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "For the people that are still alive - gives a cake to everyone on the server.", usage = "/<command>")
|
||||||
|
public class Command_cake extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||||
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
|
assert heldItemMeta != null;
|
||||||
|
heldItemMeta.displayName(FUtil.miniMessage("<white>The <dark_gray>Lie"));
|
||||||
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
server.getOnlinePlayers().forEach(player -> player.getInventory().addItem(heldItem));
|
||||||
|
server.broadcast(FUtil.miniMessage("<rainbow>But there's no sense crying over every mistake. You just keep on trying till you run out of cake."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(permission = "cleanchat", source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
||||||
|
public class Command_cleanchat extends FreedomCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
server.getOnlinePlayers().stream().filter(player -> !plugin.al.isAdmin(player)).forEach(player ->
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
msg(player, Component.space());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +1,26 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandDependencies({"TFD4J"})
|
||||||
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
|
@CommandPermissions(permission = "cleardiscordqueue", source = SourceType.ONLY_CONSOLE)
|
||||||
|
@CommandParameters(description = "Clear the Discord message queue.", usage = "/<command>")
|
||||||
public class Command_cleardiscordqueue extends FreedomCommand
|
public class Command_cleardiscordqueue extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
if (plugin.dc == null)
|
||||||
|
{
|
||||||
|
msgNew("<red>Discord is not enabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
plugin.dc.clearQueue();
|
plugin.dc.clearQueue();
|
||||||
msg("Cleared the discord message queue.");
|
msgNew("<green>Cleared the Discord message queue.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user