mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 20:46:41 +00:00
Compare commits
938 Commits
v5.0-mc1.1
...
2021-02-RC
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
bc8ff3cd7f | |||
e23bfa7f87 | |||
cbc1d997ec | |||
af935cb824 | |||
9485b62716 | |||
372ba97bef | |||
925fe4a4b2 | |||
4a5032bb4c | |||
48ee7b0e6d | |||
c94ce6b276 | |||
ecc907b535 | |||
ce804ac23b | |||
1744eaac69 | |||
9874fe0ed5 | |||
2d7353c076 | |||
b2abc1db45 | |||
682145eb13 | |||
046bebe54c | |||
ea6d541270 | |||
7fef35a7e2 | |||
1772164fa2 | |||
c5d778896e | |||
ee8eb30a92 | |||
b7c1a46cbd | |||
a37d8ecb31 | |||
47a62753d1 | |||
608791d918 | |||
5b0ba0917c | |||
8c0391f050 | |||
56d5a669cf | |||
7940313dd1 | |||
1ee1cbca2b | |||
939e0730fd | |||
93a9885477 | |||
5641d0d504 | |||
6d0400cdf3 | |||
89b91598fb | |||
98ed23969a | |||
f989b34ada | |||
cf21b8d07e | |||
81621d260d | |||
5bb489e8ba | |||
24d121643e | |||
035acbfa19 | |||
fbcb6da30d | |||
3b715fc091 | |||
648d0e9b2e | |||
1181de8ed4 | |||
a7de5edfcb | |||
fbfc605f1e | |||
156c85ce69 | |||
3ea73f78e9 | |||
52269c2122 | |||
446f658c13 | |||
ee4bbea340 | |||
a2404d1bc6 | |||
81c5775150 | |||
35ef866690 | |||
eb3a266bf6 | |||
c53de9d789 | |||
0efbf77cf7 | |||
33cc304330 | |||
7d19de5dfa | |||
fa51976ea5 | |||
6a5dc4b98e | |||
73a799d709 | |||
96e1d0afdc | |||
9fb89f2c69 | |||
855c01a46b | |||
1bc06f2c1d | |||
1dc2bd8518 | |||
ef9f55f7ad | |||
9167c47c2f | |||
82cd7f2d05 | |||
d40c85f39c | |||
86a4577023 | |||
7cffdac400 | |||
259f3068e2 | |||
ce643661fc | |||
4d1cdfedc7 | |||
6b3d170c6d | |||
d767e7ebd6 | |||
572ebdd0f5 | |||
d0b64c6438 | |||
9a6cd007ed | |||
97caed9313 | |||
f0aec56186 | |||
a0571b0175 | |||
ee44b5fb7f | |||
69fb21f57c | |||
d7e3f05010 | |||
c096c4a781 | |||
135d1af27d | |||
f758be9e70 | |||
bd84257c16 | |||
d78d28cc7a | |||
5206ab5b27 | |||
2c99a8e4f4 | |||
9de3388525 | |||
5cfb525a1f | |||
93e6361148 | |||
7572f77ab6 | |||
4344ae58bf | |||
9a50903c14 | |||
f7bca3f868 | |||
bbcf4a984b | |||
acd7de715e | |||
43b4fc89ef | |||
a79b26f4be | |||
90febba91a | |||
bb9e46b1fd | |||
79d54d09f9 | |||
cc6a9a843c | |||
421315a31c | |||
0ab0ca2c66 | |||
f4a77859bf | |||
ac1065afff | |||
0abfb70a42 | |||
d99e6629c4 | |||
4ca89c6bf2 | |||
f976c8ba19 | |||
aac208710d | |||
9d20b8cf1d | |||
7936936942 | |||
ba9d3a085f | |||
60c46b7c8e | |||
9f22115b30 | |||
07e0b4e2c8 | |||
ea93b069df | |||
e0bbbbdda8 | |||
fd809a0d33 | |||
b3f785beb9 | |||
a926f72b67 | |||
5a6dacfc37 | |||
7726cae9a3 | |||
e884d9b47e | |||
75168dbb38 | |||
337a612437 | |||
b2305a918b | |||
8d0540dc66 | |||
5c1c06afa0 | |||
a40785f31e | |||
35ff7494a4 | |||
4aaf9bc9ff | |||
23b29bdf38 | |||
4a69f529c2 | |||
fe2bdef026 | |||
233632eaf1 | |||
db42985743 | |||
1d932e2c7b | |||
b525e53348 | |||
d582398f93 | |||
f05d6a71ae | |||
aad33958f0 | |||
ac850bc41d | |||
d6dbdf15bc | |||
2a168ece3d | |||
4f339b29b8 | |||
9f4b48af5a | |||
14c9db3433 | |||
44f101841b | |||
81002cbe97 | |||
eccf940b81 | |||
1babf57570 | |||
bd6c7d55a7 | |||
d21c5f0e9d | |||
f2f3720de2 | |||
d6d42cc905 | |||
03e1a7c9c4 | |||
73470a90e5 | |||
7d0ea0837e | |||
1c3970b984 | |||
cecbf09584 | |||
a166154e48 | |||
1951d9adea | |||
e7ebc51847 | |||
841e354d35 | |||
fb336f27bb | |||
a4ee58cac7 | |||
5085b90727 | |||
503a8d5b4f | |||
c01c436d40 | |||
6187c9c068 | |||
dffd9f8c3c | |||
fb0bfb847f | |||
1eaa55bb6d | |||
ca790b6d2c | |||
668ccda5cd | |||
894feaf1dc | |||
d635e2c3d1 | |||
2254f1225d | |||
0b7813d87f | |||
9a5f2e2231 | |||
561854f2f0 | |||
ca868a290d | |||
5ab0feebfd | |||
797d8516d1 | |||
5a59877f24 | |||
ae1701613b | |||
9cb4bd7822 | |||
c3d35487e7 | |||
a71bfde4ee | |||
95ef7d6cfe | |||
6706437ab7 | |||
b4dd877f2b | |||
6dcccac2b0 | |||
e861f272fe | |||
27aaa5406d | |||
de1fbde20a | |||
a97a3f3177 | |||
521825024e | |||
bcb466a95c | |||
635316dcd2 | |||
7a4b044d45 | |||
c7e0a7a288 | |||
4a91c8129b | |||
591b8644cb | |||
6b8cab5005 | |||
7fbc255ee4 | |||
59ee519955 | |||
92ad950155 | |||
481983aeaf | |||
ea6d0aba60 | |||
8f097c7454 | |||
f3cc70330e | |||
59cbc05a4a | |||
4dc63fb756 | |||
843a6ce88f | |||
e3adc7ab83 | |||
f263c0f5f6 | |||
00483be7d4 | |||
a77e53932b | |||
b4bb2cf4d8 | |||
a56a9396d4 | |||
56175dacb4 | |||
5b2334c60f | |||
d7931793f1 | |||
3d7d363e30 | |||
7c6c407f78 | |||
746ccdfd44 | |||
93d4c9654e | |||
3754222582 | |||
f649e3d6c3 | |||
8c7823d7bf | |||
2408054a49 | |||
72db71b3cf | |||
7a43f991e3 | |||
322ed77232 | |||
d58ee9f590 | |||
6b176820c5 | |||
516c21533c | |||
2bfc412e78 | |||
d17457dbfa | |||
3895c2235e | |||
34c8544690 | |||
87cd901f72 | |||
968a36b216 | |||
47565ece6b | |||
94d91bbb31 | |||
1588ab8baa | |||
aac921b283 | |||
84c0e90164 | |||
75fb1b2172 | |||
69efba711a | |||
73cea831af | |||
e285a72719 | |||
f3baf37279 | |||
533e7892cc | |||
0657d01059 | |||
da06ff50cb | |||
93e7957e25 | |||
6ec420f7fe | |||
2716e2500b | |||
5da2237cb3 | |||
1f9078b702 | |||
60c627c591 | |||
8bd8efc665 | |||
b97fd70b83 | |||
12f023196a | |||
b702c1cec5 | |||
1e60b06dba | |||
941bbc8da3 | |||
9c2f181ab9 | |||
ed9200689c | |||
f8b5078f84 | |||
c0e16ee9c7 | |||
45a10a871f | |||
519b456807 | |||
655766a0c4 | |||
bf6e35238e | |||
575818ba69 | |||
7baf5f322e | |||
8268cea3db | |||
815211e454 | |||
48383af346 | |||
9360148426 | |||
d2d93ec76a | |||
1bffb5994a | |||
fb7c17aff7 | |||
7a2b7ec78b | |||
551a0b2317 | |||
3c46df0082 | |||
af777f1a76 | |||
25aa28194b | |||
0d0ad7d947 | |||
38e1769f0d | |||
113ab62f0b | |||
c0b43f26ea | |||
65bd609952 | |||
f671f3c3fa | |||
7278176143 | |||
0d503a6c06 | |||
7e93b2ae53 | |||
7170b1c999 | |||
6275fd8bcb | |||
d29f192a36 | |||
22c6cf014c | |||
402a1e28b7 | |||
a90e7654d1 | |||
31015be69f | |||
ebb05fa6a6 | |||
bfefebe480 | |||
0c702ee967 | |||
cae068a151 | |||
e8eda42295 | |||
301c5b8da1 | |||
f0a9b6d747 | |||
24f65dc46b | |||
fdbc02bac9 | |||
46cc6d37c3 | |||
04089973f0 | |||
f167134a3a | |||
8602850245 | |||
114567f94c | |||
12a0b6961b | |||
b43a9b6749 | |||
107d886b35 | |||
92d63180f9 | |||
bd44173a14 | |||
650f732dd4 | |||
d7450bf181 | |||
0898c0a81b | |||
6e2255c904 | |||
c071c701b3 | |||
e92b755306 | |||
7a45734baf | |||
553767454d | |||
1ad60c1c80 | |||
c9a0626239 | |||
4da29d5c9d | |||
57e7fe13cf | |||
6c5ae5d7d7 | |||
a6584eaa9d | |||
7228180f4b | |||
d38d780887 | |||
b44d08eb55 | |||
c835d38b7c | |||
7026423e8e | |||
435898550b | |||
100e155fe0 | |||
b8f4119924 | |||
6647088429 | |||
4cf338bfb5 | |||
56b712729a | |||
713ec7c8d9 | |||
ee7dbd56da | |||
45bda95a75 | |||
aad947a354 | |||
f82f3932b9 | |||
6e7297e48f | |||
bdae2b7b54 | |||
f7f6c47a1a | |||
ff3f9f0a66 | |||
baf367b003 | |||
69e82b5746 | |||
6e3fa2d6dd | |||
94b7e138d7 | |||
40362eb790 | |||
1ff7d7c8cc | |||
7b1a8cb527 | |||
6853baebdd | |||
1371e23d59 | |||
83017e518d | |||
34a8e7f912 | |||
ffbe71f5dd | |||
200a856413 | |||
b402987e41 | |||
f23818a9f9 | |||
a8e39e3db2 | |||
dec237db9f | |||
a63681d4a3 | |||
affe77c203 | |||
1080893be4 | |||
d5a3742849 | |||
88f89d7e67 | |||
01223d44ef | |||
3576a9bb6e | |||
50cb6c4ca9 | |||
c423f273c5 | |||
5223339a9e | |||
664c56dfd5 | |||
101e490104 | |||
7c7265e662 | |||
40a78f8608 | |||
2185794444 | |||
0551337e8b | |||
2bffcef9a9 | |||
c8683ea489 | |||
04c6b9ba64 | |||
8b425967a4 | |||
b801979f72 | |||
908caafb7d | |||
4f2a6bfcb8 | |||
9b6394c8c6 | |||
7c3ea836e7 | |||
d2eea67f67 | |||
09e5b39099 | |||
4ed0db05de | |||
3f360a4d5e | |||
059bf14d90 | |||
d9d1d4fa9b | |||
7e524da928 | |||
6a09b23331 | |||
1871451ed6 | |||
b931cce3bb | |||
a67fe49c98 | |||
77131c2138 | |||
75c0db71ff | |||
f56ecd4663 | |||
cffe0a6db5 | |||
a697acbdea | |||
381c06e818 | |||
019950152b | |||
7c42f78426 | |||
336a2de231 | |||
a1a0894eb5 | |||
bb8dbc9e31 | |||
c5e40bcc13 | |||
a10a0cbef9 | |||
5ee8c31a3d | |||
ff8f6a1a96 | |||
b485a9792d | |||
cba204d9f3 | |||
1fcaef8ab1 | |||
5d80ef063f | |||
1c46c26ad9 | |||
7b33d91c94 | |||
51eb3f59fd | |||
2443d3eaca | |||
3babdf88a2 | |||
25ad80be60 | |||
9e7c385fef | |||
af11581133 | |||
8c8c5360c2 | |||
489bbf4fc9 | |||
c42ad5e706 | |||
3958c58ed2 | |||
a916a06994 | |||
6812d9cfd5 | |||
c4fcd91776 | |||
c866571e93 | |||
e1ac92b784 | |||
212b367c3c | |||
a9681fb7d7 | |||
79857345bb | |||
8bb4911607 | |||
13be60142a | |||
8f45d08ea3 | |||
2bb2c77caf | |||
4011ecd7e7 | |||
b9098a7251 | |||
b397e57139 | |||
d878fd2458 | |||
ed2f15cc54 | |||
3c09bc7995 | |||
13dc0a25be | |||
299e0ccd4a | |||
4f6d32330b | |||
089fc0670d | |||
b55ca70056 | |||
3bc8adfb98 | |||
3668c5e9d6 | |||
1971910178 | |||
655d7471dc | |||
2c5ac7297d | |||
e16714ea6c | |||
c4ebbb74c7 | |||
8c424a45f9 | |||
98f0fdb620 | |||
26c83ff585 | |||
f97de65787 | |||
30a6b7a442 | |||
5d7aa8913b | |||
f25207104c | |||
c6a2496d72 | |||
baf73df4f9 | |||
5ffbc9e8a4 | |||
7245de1513 | |||
d2503da298 | |||
c8fb54182e | |||
f3130f5cfc | |||
6e6842dbd2 | |||
28142a6883 | |||
0bb5265b77 | |||
60b143e248 | |||
aaeee0d36e | |||
7b183612e4 | |||
0eb0c7a02f | |||
475b299e37 | |||
be8203a832 | |||
9fa4c0662c | |||
c10b08df27 | |||
25fafa7a6c | |||
2ff66ad54b | |||
1e47d29adf | |||
2008871658 | |||
cadf4e4fc7 | |||
662cef44d5 | |||
c885bbb144 | |||
f2260d56a4 | |||
174a782759 | |||
6a86f66cf6 | |||
b153debdef | |||
71c46b5431 | |||
580e88d1a9 | |||
92a7e354ba | |||
6a004a9f35 | |||
91506480b7 | |||
1a16f06ac6 |
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@v2
|
||||||
|
|
||||||
|
# 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@1.1.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@v1
|
||||||
|
with:
|
||||||
|
sarif_file: results.sarif
|
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
# 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@v2
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
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@v1
|
||||||
|
|
||||||
|
# ℹ️ 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@v1
|
17
.github/workflows/maven.yml
vendored
Normal file
17
.github/workflows/maven.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: Maven-Build
|
||||||
|
|
||||||
|
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
|
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,6 +1,6 @@
|
|||||||
# TFM excludes
|
# TFM excludes
|
||||||
/lib
|
|
||||||
build.properties
|
build.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
|
||||||
# Netbeans excludes
|
# Netbeans excludes
|
||||||
/nbproject/private
|
/nbproject/private
|
||||||
@ -17,10 +17,15 @@ manifest.mf
|
|||||||
/.settings
|
/.settings
|
||||||
|
|
||||||
# IntelliJ excludes
|
# IntelliJ excludes
|
||||||
*.iml
|
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
/.idea
|
/.idea/modules.xml
|
||||||
|
/.idea/discord.xml
|
||||||
|
/.idea/jarRepositories.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/uiDesigner.xml
|
||||||
|
/.idea/libraries
|
||||||
|
*.iml
|
||||||
|
|
||||||
# Maven excludes
|
# Maven excludes
|
||||||
/target
|
/target
|
||||||
@ -32,3 +37,4 @@ manifest.mf
|
|||||||
.Trashes
|
.Trashes
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
.idea/inspectionProfiles/Project_Default.xml
|
||||||
|
13
.travis.yml
Normal file
13
.travis.yml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk11
|
||||||
|
- openjdk11
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- sshpass
|
||||||
|
script: mvn clean install
|
||||||
|
after_success:
|
||||||
|
- ./travis-upload.sh
|
17
README.md
17
README.md
@ -1,11 +1,16 @@
|
|||||||
# TotalFreedomMod #
|
# TotalFreedomMod [](https://travis-ci.com/AtlasMediaGroup/TotalFreedomMod) [](https://www.codacy.com/gh/AtlasMediaGroup/TotalFreedomMod/dashboard?utm_source=github.com&utm_medium=referral&utm_content=AtlasMediaGroup/TotalFreedomMod&utm_campaign=Badge_Grade)
|
||||||
|
|
||||||
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.
|
||||||
|
|
||||||
### Download ###
|
|
||||||
You may download official binaries from the [releases page](https://github.com/TotalFreedom/TotalFreedomMod/releases).
|
|
||||||
|
|
||||||
### Contributing ###
|
### Contributing ###
|
||||||
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).
|
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 our security policy and reporting an issue, please see [SECURITY.md](SECURITY.md)
|
||||||
|
|
||||||
|
### Compiling ###
|
||||||
|
|
||||||
|
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.
|
||||||
|
20
SECURITY.md
Normal file
20
SECURITY.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Security Policy
|
||||||
|
|
||||||
|
## Supported Versions
|
||||||
|
|
||||||
|
We currently support the code running on the "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, we support the following versions:
|
||||||
|
|
||||||
|
| Version | Supported |
|
||||||
|
| ------- | ------------------ |
|
||||||
|
| 2020.11 | :white_check_mark: |
|
||||||
|
| 6.0.x (Pre-Release) | :x: |
|
||||||
|
| < 2020.11 | :x: |
|
||||||
|
| < 5.x | :x: |
|
||||||
|
|
||||||
|
## 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,7 +1,7 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!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"/>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
<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">
|
||||||
@ -20,7 +20,8 @@
|
|||||||
<module name="OuterTypeFilename"/>
|
<module name="OuterTypeFilename"/>
|
||||||
<module name="IllegalTokenText">
|
<module name="IllegalTokenText">
|
||||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||||
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
<property name="format"
|
||||||
|
value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||||
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="LineLength">
|
<module name="LineLength">
|
||||||
@ -36,7 +37,8 @@
|
|||||||
</module>
|
</module>
|
||||||
<module name="RightCurly">
|
<module name="RightCurly">
|
||||||
<property name="option" value="alone"/>
|
<property name="option" value="alone"/>
|
||||||
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
<property name="tokens"
|
||||||
|
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="WhitespaceAround">
|
<module name="WhitespaceAround">
|
||||||
<property name="allowEmptyConstructors" value="true"/>
|
<property name="allowEmptyConstructors" value="true"/>
|
||||||
@ -89,7 +91,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][0-9]?)$|([A-Z][a-zA-Z0-9][_]*[T]$)"/>
|
||||||
<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>
|
||||||
@ -114,7 +116,8 @@
|
|||||||
<module name="MethodParamPad"/>
|
<module name="MethodParamPad"/>
|
||||||
<module name="OperatorWrap">
|
<module name="OperatorWrap">
|
||||||
<property name="option" value="NL"/>
|
<property name="option" value="NL"/>
|
||||||
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
<property name="tokens"
|
||||||
|
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
||||||
</module>
|
</module>
|
||||||
<module name="AnnotationLocation">
|
<module name="AnnotationLocation">
|
||||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||||
@ -130,4 +133,4 @@
|
|||||||
</module>
|
</module>
|
||||||
<module name="CommentsIndentation"/>
|
<module name="CommentsIndentation"/>
|
||||||
</module>
|
</module>
|
||||||
</module>
|
</module>
|
||||||
|
@ -1,18 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project-shared-configuration>
|
<project-shared-configuration>
|
||||||
<!--
|
<!--
|
||||||
This file contains additional configuration written by modules in the NetBeans IDE.
|
This file contains additional configuration written by modules in the NetBeans IDE.
|
||||||
The configuration is intended to be shared among all the users of project and
|
The configuration is intended to be shared among all the users of project and
|
||||||
therefore it is assumed to be part of version control checkout.
|
therefore it is assumed to be part of version control checkout.
|
||||||
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
||||||
-->
|
-->
|
||||||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
||||||
<!--
|
<!--
|
||||||
Properties that influence various parts of the IDE, especially code formatting and the like.
|
Properties that influence various parts of the IDE, especially code formatting and the like.
|
||||||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
||||||
That way multiple projects can share the same settings (useful for formatting rules for example).
|
That way multiple projects can share the same settings (useful for formatting rules for example).
|
||||||
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
||||||
-->
|
-->
|
||||||
|
<netbeans.hint.jdkPlatform>JDK_11</netbeans.hint.jdkPlatform>
|
||||||
<netbeans.checkstyle.format>true</netbeans.checkstyle.format>
|
<netbeans.checkstyle.format>true</netbeans.checkstyle.format>
|
||||||
</properties>
|
</properties>
|
||||||
</project-shared-configuration>
|
</project-shared-configuration>
|
||||||
|
431
pom.xml
431
pom.xml
@ -1,27 +1,24 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>me.totalfreedom</groupId>
|
<groupId>me.totalfreedom</groupId>
|
||||||
<artifactId>totalfreedom</artifactId>
|
<artifactId>TotalFreedomMod</artifactId>
|
||||||
<version>5.0</version>
|
<version>2021.02-RC02</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<tfm.build.version>${project.version}</tfm.build.version>
|
<tfm.build.codename>Phoenix</tfm.build.codename>
|
||||||
<tfm.build.codename>Electrum</tfm.build.codename>
|
|
||||||
<tfm.build.number>${maven.buildnumber}</tfm.build.number>
|
|
||||||
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
|
|
||||||
<tfm.build.author>${buildAuthor}</tfm.build.author>
|
|
||||||
<tfm.build.head>${buildHead}</tfm.build.head>
|
|
||||||
<jar.finalName>${project.name}</jar.finalName>
|
<jar.finalName>${project.name}</jar.finalName>
|
||||||
<maven.build.timestamp.format>dd/MM/yyyy hh:mm aa</maven.build.timestamp.format>
|
<timestamp>${maven.build.timestamp}</timestamp>
|
||||||
|
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<name>TotalFreedomMod</name>
|
<name>TotalFreedomMod</name>
|
||||||
<description>Server modification for the TotalFreedom server</description>
|
<description>Server modification for the TotalFreedom server</description>
|
||||||
<url>https://github.com/TotalFreedom/TotalFreedomMod</url>
|
<url>https://github.com/AtlasMediaGroup/TotalFreedomMod</url>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
@ -31,70 +28,254 @@
|
|||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
<organization>
|
<organization>
|
||||||
<name>Total Freedom</name>
|
<name>TotalFreedom</name>
|
||||||
<url>https://totalfreedom.me</url>
|
<url>https://totalfreedom.me</url>
|
||||||
</organization>
|
</organization>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</connection>
|
<connection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</developerConnection>
|
||||||
<url>git@github.com:TotalFreedom/TotalFreedomMod.git</url>
|
<url>git@github.com:TFPatches/TotalFreedomMod.git</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>CodeMC</id>
|
||||||
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>nms-repo</id>
|
||||||
|
<url>https://repo.codemc.org/repository/nms/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>enginehub</id>
|
||||||
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>elmakers-repo</id>
|
||||||
|
<url>https://maven.elmakers.com/repository/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-snapshots</id>
|
||||||
|
<url>https://maven.sk89q.com/artifactory/repo</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>jcenter</id>
|
||||||
|
<name>jcenter-bintray</name>
|
||||||
|
<url>https://jcenter.bintray.com</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>playpro</id>
|
||||||
|
<url>https://maven.playpro.com/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>md_5-public</id>
|
||||||
|
<url>https://repo.md-5.net/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>https://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>https://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>rayzr-repo</id>
|
||||||
|
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>ess-repo</id>
|
||||||
|
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>1.16.6</version>
|
<version>2.8.0</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.11</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>1.15</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.speedxx</groupId>
|
||||||
|
<artifactId>Mojangson</artifactId>
|
||||||
|
<version>1957eef8d6</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
<version>1.8</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.10</version>
|
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/Spigot-1.10.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.pravian</groupId>
|
<groupId>com.github.TotalFreedomMC</groupId>
|
||||||
<artifactId>aero</artifactId>
|
<artifactId>BukkitTelnet</artifactId>
|
||||||
<version>2.0</version>
|
<version>541e9fdb84</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/Aero-2.0.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.totalfreedom</groupId>
|
<groupId>com.github.TotalFreedomMC</groupId>
|
||||||
<artifactId>bukkittelnet</artifactId>
|
<artifactId>TF-LibsDisguises</artifactId>
|
||||||
<version>4.2</version>
|
<version>48f01cf2fe</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/BukkitTelnet-4.3.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.totalfreedom</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>tf-worldedit</artifactId>
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
<version>6.1.0-TF</version>
|
<version>7.3.0-SNAPSHOT</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/TF-WorldEdit-6.1.1.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.totalfreedom</groupId>
|
<groupId>net.ess3</groupId>
|
||||||
<artifactId>tf-essentials</artifactId>
|
<artifactId>EssentialsX</artifactId>
|
||||||
<version>2.0-TF</version>
|
<version>2.18.2</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/TF-Essentials-2.1.jar</systemPath>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.dv8tion</groupId>
|
||||||
|
<artifactId>JDA</artifactId>
|
||||||
|
<version>4.2.0_224</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.coreprotect</groupId>
|
||||||
|
<artifactId>coreprotect</artifactId>
|
||||||
|
<version>19.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
<version>7.0.4</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc</groupId>
|
||||||
|
<artifactId>paperlib</artifactId>
|
||||||
|
<version>1.0.6</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.rayzr522</groupId>
|
||||||
|
<artifactId>jsonmessage</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.vexsoftware</groupId>
|
||||||
|
<artifactId>votifier</artifactId>
|
||||||
|
<version>v1.9</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.goldtreeservers</groupId>
|
||||||
|
<artifactId>worldguardextraflags</artifactId>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.reflections</groupId>
|
||||||
|
<artifactId>reflections</artifactId>
|
||||||
|
<version>0.9.12</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.javassist</groupId>
|
||||||
|
<artifactId>javassist</artifactId>
|
||||||
|
<version>3.27.0-GA</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TotalFreedomMC</groupId>
|
||||||
|
<artifactId>TFGuilds</artifactId>
|
||||||
|
<version>db036fb187</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>20.1.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter</artifactId>
|
||||||
|
<version>5.4.2</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -107,32 +288,81 @@
|
|||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- Compiler -->
|
<!-- Compiler -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.3</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||||
<compilerVersion>1.7</compilerVersion>
|
<compilerVersion>11</compilerVersion>
|
||||||
<source>1.7</source>
|
<source>11</source>
|
||||||
<target>1.7</target>
|
<target>11</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Git describe -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>pl.project13.maven</groupId>
|
||||||
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
<version>4.0.2</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>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Antrun -->
|
<!-- Antrun -->
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
<version>1.8</version>
|
<version>1.8</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<id>default-cli</id>
|
||||||
<phase>initialize</phase>
|
<phase>initialize</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>
|
<target>
|
||||||
<propertyfile file="build.properties" comment="Build information. Edit this to your liking.">
|
<propertyfile file="${project.basedir}/src/main/resources/build.properties"
|
||||||
<entry key="buildAuthor" default="unknown" />
|
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>
|
</propertyfile>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -156,58 +386,13 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<files>
|
<files>
|
||||||
<file>${basedir}/build.properties</file>
|
<file>${project.basedir}/src/main/resources/build.properties</file>
|
||||||
</files>
|
</files>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Checkstyle -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<version>2.17</version>
|
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>process-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<configLocation>checkstyle.xml</configLocation>
|
|
||||||
<consoleOutput>true</consoleOutput>
|
|
||||||
<failsOnError>true</failsOnError>
|
|
||||||
<failOnViolation>true</failOnViolation>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Git describe -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.lukegb.mojo</groupId>
|
|
||||||
<artifactId>gitdescribe-maven-plugin</artifactId>
|
|
||||||
<version>3.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>git-describe</id>
|
|
||||||
<phase>initialize</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>gitdescribe</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<descriptionProperty>buildHead</descriptionProperty>
|
|
||||||
<extraArguments>
|
|
||||||
<param>--tags</param>
|
|
||||||
<param>--always</param>
|
|
||||||
<param>HEAD</param>
|
|
||||||
</extraArguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Buildnumber -->
|
<!-- Buildnumber -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
@ -224,13 +409,56 @@
|
|||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
||||||
<buildNumberPropertiesFileLocation>${basedir}/build.properties</buildNumberPropertiesFileLocation>
|
<buildNumberPropertiesFileLocation>${project.basedir}/src/main/resources/build.properties
|
||||||
|
</buildNumberPropertiesFileLocation>
|
||||||
<format>{0,number,#}</format>
|
<format>{0,number,#}</format>
|
||||||
<items>
|
<items>
|
||||||
<item>buildNumber</item>
|
<item>buildNumber</item>
|
||||||
</items>
|
</items>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Shade -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</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>commons-io:commons-io</include>
|
||||||
|
<include>org.apache.commons:commons-lang3</include>
|
||||||
|
<include>commons-codec:commons-codec</include>
|
||||||
|
<include>org.reflections:reflections</include>
|
||||||
|
<include>org.javassist:javassist</include>
|
||||||
|
<include>me.rayzr522:jsonmessage</include>
|
||||||
|
<include>io.papermc:paperlib</include>
|
||||||
|
<include>com.github.speedxx:Mojangson</include>
|
||||||
|
<include>org.bstats:bstats-bukkit</include>
|
||||||
|
<include>org.jetbrains:annotations</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -240,13 +468,8 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jxr-plugin</artifactId>
|
|
||||||
<version>2.5</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<version>2.17</version>
|
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configLocation>checkstyle.xml</configLocation>
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
<failOnViolation>true</failOnViolation>
|
<failOnViolation>true</failOnViolation>
|
||||||
|
@ -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;
|
||||||
@ -36,7 +27,7 @@ public class Announcer extends FreedomService
|
|||||||
announcements.clear();
|
announcements.clear();
|
||||||
for (Object announcement : ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList())
|
for (Object announcement : ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList())
|
||||||
{
|
{
|
||||||
announcements.add(FUtil.colorize((String) announcement));
|
announcements.add(FUtil.colorize((String)announcement));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ 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 me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,46 +31,17 @@ public class AntiNuke extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Location location = event.getBlock().getLocation();
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
final Location playerLocation = player.getLocation();
|
|
||||||
|
|
||||||
final double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
|
|
||||||
|
|
||||||
boolean outOfRange = false;
|
|
||||||
if (!playerLocation.getWorld().equals(location.getWorld()))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
else if (playerLocation.distanceSquared(location) > (nukeMonitorRange * nukeMonitorRange))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outOfRange)
|
|
||||||
{
|
|
||||||
if (fPlayer.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
|
||||||
{
|
|
||||||
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
|
||||||
plugin.ae.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
|
|
||||||
|
|
||||||
fPlayer.resetFreecamDestroyCount();
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||||
plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
//plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||||
|
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||||
|
|
||||||
fPlayer.resetBlockDestroyCount();
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,41 +54,13 @@ public class AntiNuke extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location blockLocation = event.getBlock().getLocation();
|
|
||||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
Location playerLocation = player.getLocation();
|
|
||||||
|
|
||||||
double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
|
|
||||||
|
|
||||||
boolean outOfRange = false;
|
|
||||||
if (!playerLocation.getWorld().equals(blockLocation.getWorld()))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outOfRange)
|
|
||||||
{
|
|
||||||
if (fPlayer.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
|
||||||
{
|
|
||||||
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
|
||||||
plugin.ae.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
|
|
||||||
|
|
||||||
fPlayer.resetFreecamPlaceCount();
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||||
plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
||||||
|
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
|
||||||
|
|
||||||
fPlayer.resetBlockPlaceCount();
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
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 me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -9,6 +11,7 @@ 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.PlayerKickEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
@ -19,14 +22,10 @@ public class AntiSpam extends FreedomService
|
|||||||
public static final int TICKS_PER_CYCLE = 2 * 10;
|
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||||
//
|
//
|
||||||
public BukkitTask cycleTask = null;
|
public BukkitTask cycleTask = null;
|
||||||
|
List<Player> markedForDeath = new ArrayList<>();
|
||||||
public AntiSpam(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@ -40,7 +39,7 @@ public class AntiSpam extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
FUtil.cancel(cycleTask);
|
FUtil.cancel(cycleTask);
|
||||||
}
|
}
|
||||||
@ -62,6 +61,12 @@ public class AntiSpam extends FreedomService
|
|||||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String message = event.getMessage().trim();
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||||
@ -69,24 +74,23 @@ public class AntiSpam extends FreedomService
|
|||||||
// Check for spam
|
// Check for spam
|
||||||
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
{
|
{
|
||||||
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
if (!markedForDeath.contains(player))
|
||||||
FSync.autoEject(player, "Kicked for spamming chat.");
|
{
|
||||||
|
markedForDeath.add(player);
|
||||||
|
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||||
|
FSync.autoEject(player, "Kicked for spamming chat.");
|
||||||
|
|
||||||
playerdata.resetMsgCount();
|
playerdata.resetMsgCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
||||||
// Check for message repeat
|
|
||||||
if (playerdata.getLastMessage().equalsIgnoreCase(message))
|
|
||||||
{
|
{
|
||||||
FSync.playerMsg(player, "Please do not repeat messages.");
|
FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playerdata.setLastMessage(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
@ -104,6 +108,11 @@ public class AntiSpam extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||||
@ -114,4 +123,9 @@ public class AntiSpam extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
|
{
|
||||||
|
markedForDeath.remove(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
}
|
}
|
||||||
@ -107,10 +97,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,15 +15,10 @@ 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();
|
||||||
|
|
||||||
if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean())
|
if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean())
|
||||||
@ -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,10 +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.isEssentialsEnabled()
|
= plugin.esb.isEnabled()
|
||||||
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
&& (((float)server.getOnlinePlayers().size() / (float)server.getMaxPlayers()) > autoKickThreshold);
|
||||||
|
|
||||||
if (!doAwayKickCheck)
|
if (!doAwayKickCheck)
|
||||||
{
|
{
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
|
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>
|
public class BackupManager extends FreedomService
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public BackupManager(TotalFreedomMod plugin)
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
{
|
{
|
||||||
super(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createBackups(String file)
|
public void createBackups(String file)
|
||||||
@ -20,6 +26,15 @@ 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(PermissionConfig.PERMISSIONS_FILENAME, true);
|
||||||
|
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];
|
||||||
|
@ -1,36 +1,38 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
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 static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.SoundCategory;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
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.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
|
|
||||||
public class ChatManager extends FreedomService
|
public class ChatManager extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public ChatManager(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -48,35 +50,44 @@ public class ChatManager extends FreedomService
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
String message = event.getMessage().trim();
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
// Strip color from messages
|
// Format colors and strip &k
|
||||||
message = ChatColor.stripColor(message);
|
message = FUtil.colorize(message);
|
||||||
|
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
||||||
|
|
||||||
// Truncate messages that are too long - 100 characters is vanilla client max
|
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
||||||
if (message.length() > 100)
|
|
||||||
{
|
{
|
||||||
message = message.substring(0, 100);
|
event.setCancelled(true);
|
||||||
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
|
plugin.pl.save(data);
|
||||||
|
plugin.sh.endReaction(player.getName());
|
||||||
|
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate messages that are too long - 256 characters is vanilla client max
|
||||||
|
if (message.length() > 256)
|
||||||
|
{
|
||||||
|
message = message.substring(0, 256);
|
||||||
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
|
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for caps
|
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
if (message.length() >= 6)
|
if (fPlayer.isLockedUp())
|
||||||
{
|
{
|
||||||
int caps = 0;
|
FSync.playerMsg(player, "You're locked up and cannot talk.");
|
||||||
for (char c : message.toCharArray())
|
event.setCancelled(true);
|
||||||
{
|
return;
|
||||||
if (Character.isUpperCase(c))
|
|
||||||
{
|
|
||||||
caps++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
|
|
||||||
{
|
|
||||||
message = message.toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for adminchat
|
// Check for adminchat
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
|
||||||
if (fPlayer.inAdminChat())
|
if (fPlayer.inAdminChat())
|
||||||
{
|
{
|
||||||
FSync.adminChatMessage(player, message);
|
FSync.adminChatMessage(player, message);
|
||||||
@ -84,11 +95,26 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for 4chan trigger
|
||||||
|
boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
||||||
|
boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
||||||
|
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
if (green)
|
||||||
|
{
|
||||||
|
message = ChatColor.GREEN + message;
|
||||||
|
}
|
||||||
|
else if (orange)
|
||||||
|
{
|
||||||
|
message = ChatColor.GOLD + message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, set message
|
// Finally, set message
|
||||||
event.setMessage(message);
|
event.setMessage(message);
|
||||||
|
|
||||||
// Make format
|
// Make format
|
||||||
String format = "<%1$s> %2$s";
|
String format = "%1$s §8\u00BB §f%2$s";
|
||||||
|
|
||||||
String tag = fPlayer.getTag();
|
String tag = fPlayer.getTag();
|
||||||
if (tag != null && !tag.isEmpty())
|
if (tag != null && !tag.isEmpty())
|
||||||
@ -96,20 +122,59 @@ public class ChatManager extends FreedomService
|
|||||||
format = tag.replace("%", "%%") + " " + format;
|
format = tag.replace("%", "%%") + " " + format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for mentions
|
||||||
|
boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
||||||
|
{
|
||||||
|
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1337F, 0.9F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set format
|
// Set format
|
||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
|
|
||||||
|
// Send to discord
|
||||||
|
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
||||||
|
{
|
||||||
|
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getColor(Displayable display)
|
||||||
|
{
|
||||||
|
return display.getColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColoredTag(Displayable display)
|
||||||
|
{
|
||||||
|
ChatColor color = display.getColor();
|
||||||
|
return color + display.getAbbr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adminChat(CommandSender sender, String message)
|
public void adminChat(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
FLog.info("[ADMIN] " + name + ": " + message);
|
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||||
|
plugin.dc.messageAdminChatChannel(sender.getName() + " \u00BB " + message);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.GOLD + message);
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
|
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
||||||
|
{
|
||||||
|
String format = admin.getAcFormat();
|
||||||
|
ChatColor color = getColor(display);
|
||||||
|
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
||||||
|
player.sendMessage(FUtil.colorize(msg));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,6 +188,6 @@ public class ChatManager extends FreedomService
|
|||||||
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -6,31 +6,35 @@ 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;
|
||||||
|
|
||||||
public class CommandSpy extends FreedomService {
|
public class CommandSpy extends FreedomService
|
||||||
|
{
|
||||||
public CommandSpy(TotalFreedomMod plugin) {
|
@Override
|
||||||
super(plugin);
|
public void onStart()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
public void onStop()
|
||||||
}
|
{
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
if (plugin.al.isAdmin(event.getPlayer())) {
|
{
|
||||||
return;
|
for (Player player : server.getOnlinePlayers())
|
||||||
}
|
{
|
||||||
|
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers()) {
|
if (player != event.getPlayer())
|
||||||
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled()) {
|
{
|
||||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -1,168 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.io.Files;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import net.pravian.aero.component.PluginComponent;
|
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
|
|
||||||
public class ConfigConverter extends PluginComponent<TotalFreedomMod>
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final int CURRENT_CONFIG_VERSION = 1;
|
|
||||||
|
|
||||||
public ConfigConverter(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void convert()
|
|
||||||
{
|
|
||||||
File data = plugin.getDataFolder();
|
|
||||||
data.mkdirs();
|
|
||||||
File versionFile = new File(data, "version.yml");
|
|
||||||
|
|
||||||
boolean convert = false;
|
|
||||||
if (!versionFile.exists() && data.listFiles().length > 0)
|
|
||||||
{
|
|
||||||
convert = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
YamlConfig config = new YamlConfig(plugin, versionFile, true);
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
if (config.getInt("version", -1) < CURRENT_CONFIG_VERSION)
|
|
||||||
{
|
|
||||||
convert = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!convert)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.warning("Converting old configs to new format...");
|
|
||||||
|
|
||||||
File backup = new File(data, "backup_old_format");
|
|
||||||
backup.mkdirs();
|
|
||||||
|
|
||||||
for (File file : data.listFiles())
|
|
||||||
{
|
|
||||||
if (file.equals(backup) || file.equals(versionFile))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Files.move(file, new File(backup, file.getName()));
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
logger.severe("Could not backup file: " + file.getName());
|
|
||||||
logger.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
convertSuperadmins(new File(backup, "superadmin.yml"));
|
|
||||||
convertPermbans(new File(backup, "permban.yml"));
|
|
||||||
|
|
||||||
logger.info("Conversion complete!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void convertSuperadmins(File oldFile)
|
|
||||||
{
|
|
||||||
if (!oldFile.exists() || !oldFile.isFile())
|
|
||||||
{
|
|
||||||
logger.warning("No old superadmin list found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert old admin list
|
|
||||||
YamlConfig oldYaml = new YamlConfig(plugin, oldFile, false);
|
|
||||||
oldYaml.load();
|
|
||||||
|
|
||||||
ConfigurationSection admins = oldYaml.getConfigurationSection("admins");
|
|
||||||
if (admins == null)
|
|
||||||
{
|
|
||||||
logger.warning("No admin section in superadmin list!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Admin> conversions = Lists.newArrayList();
|
|
||||||
for (String uuid : admins.getKeys(false))
|
|
||||||
{
|
|
||||||
ConfigurationSection asec = admins.getConfigurationSection(uuid);
|
|
||||||
if (asec == null)
|
|
||||||
{
|
|
||||||
logger.warning("Invalid superadmin format for admin: " + uuid);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String username = asec.getString("last_login_name");
|
|
||||||
Rank rank;
|
|
||||||
if (asec.getBoolean("is_senior_admin"))
|
|
||||||
{
|
|
||||||
rank = Rank.SENIOR_ADMIN;
|
|
||||||
}
|
|
||||||
else if (asec.getBoolean("is_telnet_admin"))
|
|
||||||
{
|
|
||||||
rank = Rank.TELNET_ADMIN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rank = Rank.SUPER_ADMIN;
|
|
||||||
}
|
|
||||||
List<String> ips = asec.getStringList("ips");
|
|
||||||
String loginMessage = asec.getString("custom_login_message");
|
|
||||||
boolean active = asec.getBoolean("is_activated");
|
|
||||||
|
|
||||||
Admin admin = new Admin(username);
|
|
||||||
admin.setName(username);
|
|
||||||
admin.setRank(rank);
|
|
||||||
admin.addIps(ips);
|
|
||||||
admin.setLoginMessage(loginMessage);
|
|
||||||
admin.setActive(active);
|
|
||||||
admin.setLastLogin(new Date());
|
|
||||||
conversions.add(admin);
|
|
||||||
}
|
|
||||||
|
|
||||||
YamlConfig newYaml = new YamlConfig(plugin, AdminList.CONFIG_FILENAME);
|
|
||||||
for (Admin admin : conversions)
|
|
||||||
{
|
|
||||||
admin.saveTo(newYaml.createSection(admin.getName().toLowerCase()));
|
|
||||||
}
|
|
||||||
newYaml.save();
|
|
||||||
|
|
||||||
logger.info("Converted " + conversions.size() + " admins");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void convertPermbans(File oldFile)
|
|
||||||
{
|
|
||||||
if (!oldFile.exists())
|
|
||||||
{
|
|
||||||
logger.warning("No old permban list found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Files.copy(oldFile, new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
|
|
||||||
logger.info("Converted permban list");
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
logger.warning("Could not copy old permban list!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,159 +1,110 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
|
||||||
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.FUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.AreaEffectCloud;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.Boat;
|
|
||||||
import org.bukkit.entity.EnderCrystal;
|
|
||||||
import org.bukkit.entity.EnderSignal;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Explosive;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Firework;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.Minecart;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.ThrownExpBottle;
|
|
||||||
import org.bukkit.entity.ThrownPotion;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class EntityWiper extends FreedomService
|
public class EntityWiper extends FreedomService
|
||||||
{
|
{
|
||||||
|
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||||
private static final long WIPE_RATE = 5 * 20L;
|
EntityType.ARMOR_STAND,
|
||||||
//
|
EntityType.PAINTING,
|
||||||
private final List<Class<? extends Entity>> wipables = new ArrayList<>();
|
EntityType.BOAT,
|
||||||
//
|
EntityType.LEASH_HITCH,
|
||||||
private BukkitTask wipeTask;
|
EntityType.ITEM_FRAME,
|
||||||
|
EntityType.MINECART
|
||||||
public EntityWiper(TotalFreedomMod plugin)
|
);
|
||||||
{
|
private BukkitTask wiper;
|
||||||
super(plugin);
|
|
||||||
wipables.add(EnderCrystal.class);
|
|
||||||
wipables.add(EnderSignal.class);
|
|
||||||
wipables.add(ExperienceOrb.class);
|
|
||||||
wipables.add(Projectile.class);
|
|
||||||
wipables.add(FallingBlock.class);
|
|
||||||
wipables.add(Firework.class);
|
|
||||||
wipables.add(Item.class);
|
|
||||||
wipables.add(ThrownPotion.class);
|
|
||||||
wipables.add(ThrownExpBottle.class);
|
|
||||||
wipables.add(AreaEffectCloud.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
// Continuous Entity Wiper
|
||||||
|
wiper = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wipeTask = new BukkitRunnable()
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
wipeEntities(!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean(), false);
|
wipeEntities(false);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, WIPE_RATE, WIPE_RATE);
|
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
FUtil.cancel(wipeTask);
|
wiper.cancel();
|
||||||
wipeTask = null;
|
wiper = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canWipe(Entity entity, boolean wipeExplosives, boolean wipeVehicles)
|
// Methods for wiping
|
||||||
{
|
|
||||||
if (wipeExplosives)
|
|
||||||
{
|
|
||||||
if (Explosive.class.isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wipeVehicles)
|
public int wipeEntities(boolean bypassBlacklist)
|
||||||
{
|
|
||||||
if (Boat.class.isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (Minecart.class.isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator<Class<? extends Entity>> it = wipables.iterator();
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
if (it.next().isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int wipeEntities(boolean wipeExplosives, boolean wipeVehicles)
|
|
||||||
{
|
{
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
Iterator<World> worlds = Bukkit.getWorlds().iterator();
|
|
||||||
while (worlds.hasNext())
|
|
||||||
{
|
{
|
||||||
Iterator<Entity> entities = worlds.next().getEntities().iterator();
|
for (Entity entity : world.getEntities())
|
||||||
while (entities.hasNext())
|
|
||||||
{
|
{
|
||||||
Entity entity = entities.next();
|
if (!(entity instanceof Player))
|
||||||
if (canWipe(entity, wipeExplosives, wipeVehicles))
|
|
||||||
{
|
{
|
||||||
|
if ((!bypassBlacklist && BLACKLIST.contains(entity.getType())) || Groups.MOB_TYPES.contains(entity.getType()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
public int wipeEntities(EntityType entityType)
|
||||||
public void onContainerBreak(BlockBreakEvent event)
|
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
return;
|
for (Entity entity : world.getEntities())
|
||||||
|
{
|
||||||
|
if (!entity.getType().equals(entityType))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
BlockState state = event.getBlock().getState();
|
public int purgeMobs(EntityType type)
|
||||||
if (!(state instanceof InventoryHolder))
|
{
|
||||||
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
return;
|
for (Entity entity : world.getLivingEntities())
|
||||||
|
{
|
||||||
|
if (entity instanceof LivingEntity && !(entity instanceof Player))
|
||||||
|
{
|
||||||
|
if (type != null && !entity.getType().equals(type))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return removed;
|
||||||
Inventory inv = ((InventoryHolder) state).getInventory();
|
|
||||||
inv.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,26 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import net.pravian.aero.component.service.AbstractService;
|
import java.util.logging.Logger;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public abstract class FreedomService extends AbstractService<TotalFreedomMod>
|
public abstract class FreedomService implements Listener
|
||||||
{
|
{
|
||||||
|
protected final TotalFreedomMod plugin;
|
||||||
|
protected final Server server;
|
||||||
|
protected final Logger logger;
|
||||||
|
|
||||||
public FreedomService(TotalFreedomMod plugin)
|
public FreedomService()
|
||||||
{
|
{
|
||||||
super(plugin);
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,12 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
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.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
@ -9,17 +14,15 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import java.util.function.Consumer;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_trail;
|
|
||||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
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.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.command.CommandReflection;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -29,8 +32,8 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
@ -41,6 +44,7 @@ import org.bukkit.plugin.RegisteredListener;
|
|||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* - A message from the TFM Devs -
|
* - A message from the TFM Devs -
|
||||||
@ -76,7 +80,23 @@ public class FrontDoor extends FreedomService
|
|||||||
// TODO: reimplement in superclass
|
// TODO: reimplement in superclass
|
||||||
private final Listener playerCommandPreprocess = new Listener()
|
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
|
@EventHandler
|
||||||
|
@SuppressWarnings("all")
|
||||||
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
|
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
@ -91,7 +111,7 @@ public class FrontDoor extends FreedomService
|
|||||||
final String commandName = commandParts[0].replaceFirst("/", "");
|
final String commandName = commandParts[0].replaceFirst("/", "");
|
||||||
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
||||||
|
|
||||||
Command command = CommandReflection.getCommandMap().getCommand(commandName);
|
Command command = getCommandMap().getCommand(commandName);
|
||||||
|
|
||||||
if (command == null)
|
if (command == null)
|
||||||
{
|
{
|
||||||
@ -109,18 +129,18 @@ public class FrontDoor extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatcher.runCommand(player, command, commandName, args);
|
// Dual call to player... not sure if this will be an issue?
|
||||||
|
dispatcher.run(player, player, command, commandName, args, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public FrontDoor(TotalFreedomMod plugin)
|
public FrontDoor(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
|
||||||
URL tempUrl = null;
|
URL tempUrl = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll"
|
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll" // This will need to be changed.
|
||||||
+ "?version=" + TotalFreedomMod.build.formattedVersion()
|
+ "?version=" + TotalFreedomMod.build.formattedVersion()
|
||||||
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
|
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
|
||||||
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
|
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
|
||||||
@ -152,7 +172,7 @@ public class FrontDoor extends FreedomService
|
|||||||
{
|
{
|
||||||
frontdoor.cancel();
|
frontdoor.cancel();
|
||||||
enabled = false;
|
enabled = false;
|
||||||
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
|
unregisterListener(playerCommandPreprocess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,14 +204,14 @@ public class FrontDoor extends FreedomService
|
|||||||
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
|
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (Player) players.toArray()[random.nextInt(players.size())];
|
return (Player)players.toArray()[random.nextInt(players.size())];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RegisteredListener getRegisteredListener(Listener listener, Class<? extends Event> eventClass)
|
private static RegisteredListener getRegisteredListener(Listener listener)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final HandlerList handlerList = ((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null));
|
final HandlerList handlerList = ((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null));
|
||||||
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
|
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
|
||||||
for (RegisteredListener registeredListener : registeredListeners)
|
for (RegisteredListener registeredListener : registeredListeners)
|
||||||
{
|
{
|
||||||
@ -208,11 +228,11 @@ public class FrontDoor extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unregisterRegisteredListener(RegisteredListener registeredListener, Class<? extends Event> eventClass)
|
private static void unregisterRegisteredListener(RegisteredListener registeredListener)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null)).unregister(registeredListener);
|
((HandlerList)PlayerCommandPreprocessEvent.class.getMethod("getHandlerList", (Class<?>[])null).invoke(null)).unregister(registeredListener);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -220,12 +240,12 @@ public class FrontDoor extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unregisterListener(Listener listener, Class<? extends Event> eventClass)
|
private static void unregisterListener(Listener listener)
|
||||||
{
|
{
|
||||||
RegisteredListener registeredListener = getRegisteredListener(listener, eventClass);
|
RegisteredListener registeredListener = getRegisteredListener(listener);
|
||||||
if (registeredListener != null)
|
if (registeredListener != null)
|
||||||
{
|
{
|
||||||
unregisterRegisteredListener(registeredListener, eventClass);
|
unregisterRegisteredListener(registeredListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +272,7 @@ public class FrontDoor extends FreedomService
|
|||||||
|
|
||||||
enabled = false;
|
enabled = false;
|
||||||
FUtil.cancel(updater);
|
FUtil.cancel(updater);
|
||||||
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
|
unregisterListener(playerCommandPreprocess);
|
||||||
FLog.info("Disabled FrontDoor, thank you for being kind.");
|
FLog.info("Disabled FrontDoor, thank you for being kind.");
|
||||||
plugin.config.load();
|
plugin.config.load();
|
||||||
}
|
}
|
||||||
@ -276,7 +296,7 @@ public class FrontDoor extends FreedomService
|
|||||||
FLog.warning("* is for good men to do nothing. *", true);
|
FLog.warning("* is for good men to do nothing. *", true);
|
||||||
FLog.warning("*****************************************************", true);
|
FLog.warning("*****************************************************", true);
|
||||||
|
|
||||||
if (getRegisteredListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class) == null)
|
if (getRegisteredListener(playerCommandPreprocess) == null)
|
||||||
{
|
{
|
||||||
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
|
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
|
||||||
}
|
}
|
||||||
@ -354,7 +374,7 @@ public class FrontDoor extends FreedomService
|
|||||||
case 3: // Displays a message
|
case 3: // Displays a message
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
|
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
|
||||||
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "tf.sauc.in", ChatColor.BLUE);
|
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "play.totalfreedom.me", ChatColor.BLUE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,22 +452,34 @@ public class FrontDoor extends FreedomService
|
|||||||
case 7: // Allow all blocked commands >:)
|
case 7: // Allow all blocked commands >:)
|
||||||
{
|
{
|
||||||
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
|
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
|
||||||
plugin.cb.stop();
|
plugin.cb.onStop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 8: // Remove all protected areas
|
case 8:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
// Switched this case to something a bit more hardware friendly, while still fucking shit up.
|
||||||
|
if (Bukkit.getServer().getPluginManager().getPlugin("WorldGuard") == null)
|
||||||
{
|
{
|
||||||
if (plugin.pa.getProtectedAreaLabels().isEmpty())
|
Consumer<BukkitTask> task = bukkitTask -> destruct();
|
||||||
{
|
TotalFreedomMod.getPlugin().getServer().getScheduler().runTaskTimerAsynchronously(TotalFreedomMod.getPlugin(), task, 0L, 20L * 60L);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Removing all protected areas", true);
|
|
||||||
plugin.pa.clearProtectedAreas(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -463,16 +495,16 @@ public class FrontDoor extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
block.setType(Material.SIGN_POST);
|
block.setType(Material.OAK_SIGN);
|
||||||
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
|
org.bukkit.block.Sign sign = (org.bukkit.block.Sign)block.getState();
|
||||||
|
|
||||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData();
|
org.bukkit.material.Sign signData = (org.bukkit.material.Sign)sign.getData();
|
||||||
signData.setFacingDirection(BlockFace.NORTH);
|
signData.setFacingDirection(BlockFace.NORTH);
|
||||||
|
|
||||||
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
|
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN + "is");
|
sign.setLine(1, ChatColor.DARK_GREEN + "is");
|
||||||
sign.setLine(2, ChatColor.YELLOW + "Awesome!");
|
sign.setLine(2, ChatColor.YELLOW + "Awesome!");
|
||||||
sign.setLine(3, ChatColor.DARK_GRAY + "tf.sauc.in");
|
sign.setLine(3, ChatColor.DARK_GRAY + "play.totalfreedom.me");
|
||||||
sign.update();
|
sign.update();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -480,13 +512,18 @@ public class FrontDoor extends FreedomService
|
|||||||
|
|
||||||
case 10: // Enable Jumppads
|
case 10: // Enable Jumppads
|
||||||
{
|
{
|
||||||
if (plugin.jp.getMode().isOn())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
|
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
|
||||||
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,14 +531,14 @@ public class FrontDoor extends FreedomService
|
|||||||
{
|
{
|
||||||
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
|
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
|
||||||
|
|
||||||
BookMeta book = (BookMeta) bookStack.getItemMeta().clone();
|
BookMeta book = (BookMeta)bookStack.getItemMeta().clone();
|
||||||
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
|
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
|
||||||
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
|
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
|
||||||
book.addPage(
|
book.addPage(
|
||||||
ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead\n"
|
ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead\n"
|
||||||
+ ChatColor.DARK_GRAY + "---------\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.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 + "tf.sauc.in");
|
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "play.totalfreedom.me");
|
||||||
bookStack.setItemMeta(book);
|
bookStack.setItemMeta(book);
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
for (Player player : Bukkit.getOnlinePlayers())
|
||||||
@ -518,6 +555,7 @@ public class FrontDoor extends FreedomService
|
|||||||
|
|
||||||
case 12: // Silently wipe the whitelist
|
case 12: // Silently wipe the whitelist
|
||||||
{
|
{
|
||||||
|
Bukkit.getServer().getWhitelistedPlayers().clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,7 +579,7 @@ public class FrontDoor extends FreedomService
|
|||||||
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
|
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
|
||||||
|
|
||||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
||||||
playerdata.getCageData().cage(targetPos, Material.SKULL, Material.AIR);
|
playerdata.getCageData().cage(targetPos, Material.PLAYER_HEAD, Material.AIR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -589,4 +627,54 @@ public class FrontDoor extends FreedomService
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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,19 +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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,11 +23,6 @@ public class Fuckoff extends FreedomService
|
|||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
final Player fuckoffPlayer = event.getPlayer();
|
final Player fuckoffPlayer = event.getPlayer();
|
||||||
if (plugin.al.isAdmin(fuckoffPlayer))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
|
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
|
||||||
@ -59,10 +48,9 @@ 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,23 +1,18 @@
|
|||||||
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;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
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());
|
||||||
@ -25,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);
|
||||||
@ -35,11 +30,15 @@ public class GameRuleHandler extends FreedomService
|
|||||||
setGameRule(GameRule.MOB_GRIEFING, false, false);
|
setGameRule(GameRule.MOB_GRIEFING, false, false);
|
||||||
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
|
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
|
||||||
setGameRule(GameRule.NATURAL_REGENERATION, true, false);
|
setGameRule(GameRule.NATURAL_REGENERATION, true, false);
|
||||||
|
setGameRule(GameRule.KEEP_INVENTORY, true, false);
|
||||||
|
setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, 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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,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();
|
||||||
|
|
||||||
@ -78,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),
|
||||||
@ -93,12 +88,15 @@ public class GameRuleHandler extends FreedomService
|
|||||||
DO_TILE_DROPS("doTileDrops", true),
|
DO_TILE_DROPS("doTileDrops", true),
|
||||||
COMMAND_BLOCK_OUTPUT("commandBlockOutput", true),
|
COMMAND_BLOCK_OUTPUT("commandBlockOutput", true),
|
||||||
NATURAL_REGENERATION("naturalRegeneration", true),
|
NATURAL_REGENERATION("naturalRegeneration", true),
|
||||||
DO_DAYLIGHT_CYCLE("doDaylightCycle", true);
|
DO_DAYLIGHT_CYCLE("doDaylightCycle", true),
|
||||||
//
|
ANNOUNCE_ADVANCEMENTS("announceAdvancements", 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;
|
||||||
@ -114,5 +112,4 @@ public class GameRuleHandler extends FreedomService
|
|||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -1,18 +1,20 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.NoSuchProviderException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
|
||||||
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 org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
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;
|
||||||
@ -20,28 +22,22 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class LogViewer extends FreedomService
|
public class LogViewer extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public LogViewer(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
||||||
{
|
{
|
||||||
updateLogsRegistration(sender, target.getName(), target.getAddress().getAddress().getHostAddress().trim(), mode);
|
updateLogsRegistration(sender, target.getName(), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
|
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
|
||||||
{
|
{
|
||||||
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
||||||
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
||||||
@ -63,14 +59,16 @@ public class LogViewer extends FreedomService
|
|||||||
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = new URLBuilder(logsRegisterUrl)
|
final String key = SecureCodeGenerator.generateCode(20);
|
||||||
.addQueryParameter("mode", mode.toString())
|
|
||||||
|
final URL urlAdd = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", mode.name())
|
||||||
.addQueryParameter("password", logsRegisterPassword)
|
.addQueryParameter("password", logsRegisterPassword)
|
||||||
.addQueryParameter("name", targetName)
|
.addQueryParameter("name", targetName)
|
||||||
.addQueryParameter("ip", targetIP)
|
.addQueryParameter("key", key)
|
||||||
.getURL();
|
.getURL();
|
||||||
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection connection = (HttpURLConnection)urlAdd.openConnection();
|
||||||
connection.setConnectTimeout(1000 * 5);
|
connection.setConnectTimeout(1000 * 5);
|
||||||
connection.setReadTimeout(1000 * 5);
|
connection.setReadTimeout(1000 * 5);
|
||||||
connection.setUseCaches(false);
|
connection.setUseCaches(false);
|
||||||
@ -92,7 +90,29 @@ public class LogViewer extends FreedomService
|
|||||||
{
|
{
|
||||||
if (responseCode == 200)
|
if (responseCode == 200)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GREEN + "Registration " + mode.toString() + "d.");
|
if (mode == LogsRegistrationMode.ADD)
|
||||||
|
{
|
||||||
|
String link = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final URL urlVerify = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", LogsRegistrationMode.VERIFY.name())
|
||||||
|
.addQueryParameter("name", targetName)
|
||||||
|
.addQueryParameter("key", key)
|
||||||
|
.getURL();
|
||||||
|
link = urlVerify.toString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Open this link to verify your logviewer registration:\n" + ChatColor.DARK_GREEN + link);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Logviewer access revoked successfully.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,30 +130,10 @@ public class LogViewer extends FreedomService
|
|||||||
}.runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivateSuperadmin(Admin superadmin)
|
public enum LogsRegistrationMode
|
||||||
{
|
|
||||||
for (String ip : superadmin.getIps())
|
|
||||||
{
|
|
||||||
updateLogsRegistration(null, superadmin.getName(), ip, LogsRegistrationMode.DELETE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum LogsRegistrationMode
|
|
||||||
{
|
{
|
||||||
|
|
||||||
UPDATE("update"), DELETE("delete");
|
ADD, DELETE, VERIFY
|
||||||
private final String mode;
|
|
||||||
|
|
||||||
private LogsRegistrationMode(String mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class URLBuilder
|
private static class URLBuilder
|
||||||
@ -156,15 +156,46 @@ public class LogViewer extends FreedomService
|
|||||||
public URL getURL() throws MalformedURLException
|
public URL getURL() throws MalformedURLException
|
||||||
{
|
{
|
||||||
List<String> pairs = new ArrayList<>();
|
List<String> pairs = new ArrayList<>();
|
||||||
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
|
for (Map.Entry<String, String> pair : queryStringMap.entrySet())
|
||||||
while (it.hasNext())
|
|
||||||
{
|
{
|
||||||
Map.Entry<String, String> pair = it.next();
|
try
|
||||||
pairs.add(pair.getKey() + "=" + pair.getValue());
|
{
|
||||||
|
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SecureCodeGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String CHARACTER_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
public static String generateCode(final int length)
|
||||||
|
{
|
||||||
|
SecureRandom random;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException | NoSuchProviderException ex)
|
||||||
|
{
|
||||||
|
random = new SecureRandom();
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
sb.append(CHARACTER_SET.charAt(random.nextInt(CHARACTER_SET.length())));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,18 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import lombok.Getter;
|
import me.rayzr522.jsonmessage.JSONMessage;
|
||||||
import lombok.Setter;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
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 org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
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;
|
||||||
@ -17,28 +23,32 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
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;
|
||||||
@Getter
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
@Setter
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
private boolean lockdownEnabled = false;
|
public List<String> CLOWNFISH_TOGGLE = new ArrayList<>();
|
||||||
|
|
||||||
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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,17 +114,13 @@ public class LoginProcess extends FreedomService
|
|||||||
final int forceIpPort = ConfigEntry.FORCE_IP_PORT.getInteger();
|
final int forceIpPort = ConfigEntry.FORCE_IP_PORT.getInteger();
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||||
ConfigEntry.FORCE_IP_KICKMSG.getString()
|
ConfigEntry.FORCE_IP_KICKMSG.getString()
|
||||||
.replace("%address%", ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == DEFAULT_PORT ? "" : ":" + forceIpPort)));
|
.replace("%address%", ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == DEFAULT_PORT ? "" : ":" + forceIpPort)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player is admin
|
|
||||||
// Not safe to use TFM_Util.isSuperAdmin(player) because player.getAddress() will return a null until after player login.
|
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
|
||||||
|
|
||||||
// Validation below this point
|
// Validation below this point
|
||||||
if (isAdmin) // Player is superadmin
|
if (plugin.al.getEntryByIp(ip) != null) // Check if player is admin
|
||||||
{
|
{
|
||||||
// Force-allow log in
|
// Force-allow log in
|
||||||
event.allow();
|
event.allow();
|
||||||
@ -174,7 +180,6 @@ public class LoginProcess extends FreedomService
|
|||||||
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,6 +188,71 @@ public class LoginProcess extends FreedomService
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(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()) || ConfigEntry.AUTO_TP.getBoolean())
|
||||||
|
{
|
||||||
|
int x = FUtil.randomInteger(-10000, 10000);
|
||||||
|
int z = FUtil.randomInteger(-10000, 10000);
|
||||||
|
int y = player.getWorld().getHighestBlockYAt(x, z);
|
||||||
|
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||||
|
PaperLib.teleportAsync(player, location);
|
||||||
|
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!playerData.hasVerification() && !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.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConfigEntry.SERVER_TABLIST_HEADER.getString().isEmpty())
|
||||||
|
{
|
||||||
|
player.setPlayerListHeader(FUtil.colorize(ConfigEntry.SERVER_TABLIST_HEADER.getString()).replace("\\n", "\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConfigEntry.SERVER_TABLIST_FOOTER.getString().isEmpty())
|
||||||
|
{
|
||||||
|
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
String tag = playerData.getTag();
|
||||||
|
if (tag != null)
|
||||||
|
{
|
||||||
|
fPlayer.setTag(FUtil.colorize(tag));
|
||||||
|
}
|
||||||
|
|
||||||
|
int noteCount = playerData.getNotes().size();
|
||||||
|
if (noteCount != 0)
|
||||||
|
{
|
||||||
|
String noteMessage = "This player has " + noteCount + " admin note" + (noteCount > 1 ? "s" : "") + ".";
|
||||||
|
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
||||||
|
.tooltip("Click here to view them.")
|
||||||
|
.runCommand("/notes " + player.getName() + " list");
|
||||||
|
FLog.info(noteMessage);
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdminImpostor(p))
|
||||||
|
{
|
||||||
|
notice.send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@ -191,7 +261,7 @@ 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-superadmins.");
|
player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockdownEnabled)
|
if (lockdownEnabled)
|
||||||
@ -199,7 +269,6 @@ public class LoginProcess extends FreedomService
|
|||||||
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20L * 1L);
|
}.runTaskLater(plugin, 20L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
157
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal file
157
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal file
@ -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,28 +1,39 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonCompound;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import net.minecraft.server.v1_16_R3.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_16_R3.NBTTagList;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
|
||||||
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.PlayerItemHeldEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class MovementValidator extends FreedomService
|
public class MovementValidator extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final int MAX_XZ_COORD = 30000000;
|
public static final int MAX_XYZ_COORD = 29999998;
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,22 +41,147 @@ 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_XZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XZ_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
Location from = event.getFrom();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.kickPlayer(ChatColor.RED + "You were moving too quickly!");
|
||||||
|
}
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your helmet slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getBoots()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setBoots(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your boots slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getLeggings()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your leggings slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getChestplate()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your chestplate slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInMainHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your hand.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInOffHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your offhand.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
// Validate position
|
// Validate position
|
||||||
if (Math.abs(player.getLocation().getX()) >= MAX_XZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XZ_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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@EventHandler
|
||||||
|
public void onPlayerHoldItem(PlayerItemHeldEvent event)
|
||||||
|
{
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInMainHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your hand.");
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInOffHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your offhand.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean exploitItem(ItemStack item)
|
||||||
|
{
|
||||||
|
net.minecraft.server.v1_16_R3.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||||
|
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||||
|
MojangsonCompound compound = new MojangsonCompound();
|
||||||
|
boolean foundNegative = false;
|
||||||
|
boolean foundPositive = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String mod = modifiers.toString();
|
||||||
|
String fancy = ("{" + (mod.substring(1, mod.length() - 1).replace("{", "").replace("}", "")) + "}");
|
||||||
|
compound.read(fancy);
|
||||||
|
for (String key : compound.keySet())
|
||||||
|
{
|
||||||
|
if (Objects.equals(key, "Amount")) //null-safe .equals()
|
||||||
|
{
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
List<MojangsonValue> values = compound.get(key);
|
||||||
|
for (MojangsonValue<?> val : values)
|
||||||
|
{
|
||||||
|
if (val.getValue().toString().equals("Infinityd"))
|
||||||
|
{
|
||||||
|
foundPositive = true;
|
||||||
|
}
|
||||||
|
if (val.getValue().toString().equals("-Infinityd"))
|
||||||
|
{
|
||||||
|
foundNegative = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (MojangsonParseException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return foundNegative && foundPositive;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R3.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,12 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
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.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.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
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;
|
||||||
@ -14,44 +15,44 @@ 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 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(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
if (!fPlayer.isMuted())
|
if (!fPlayer.isMuted())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.al.isAdminSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
|
MUTED_PLAYERS.remove(player.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,4 +102,15 @@ public class Muter extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@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,397 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.ObjectInputStream;
|
|
||||||
import java.io.ObjectOutputStream;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
public class ProtectArea extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String DATA_FILENAME = "protectedareas.dat";
|
|
||||||
public static final double MAX_RADIUS = 50.0;
|
|
||||||
//
|
|
||||||
private final Map<String, SerializableProtectedRegion> areas = Maps.newHashMap();
|
|
||||||
|
|
||||||
public ProtectArea(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
File input = new File(plugin.getDataFolder(), DATA_FILENAME);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (input.exists())
|
|
||||||
{
|
|
||||||
FileInputStream fis = new FileInputStream(input);
|
|
||||||
ObjectInputStream ois = new ObjectInputStream(fis);
|
|
||||||
areas.clear();
|
|
||||||
areas.putAll((HashMap<String, SerializableProtectedRegion>) ois.readObject());
|
|
||||||
ois.close();
|
|
||||||
fis.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
input.delete();
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanProtectedAreas();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void save()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), DATA_FILENAME));
|
|
||||||
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
|
||||||
oos.writeObject(areas);
|
|
||||||
oos.close();
|
|
||||||
fos.close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onBlockBreak(BlockBreakEvent event)
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location location = event.getBlock().getLocation();
|
|
||||||
|
|
||||||
if (isInProtectedArea(location))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location location = event.getBlock().getLocation();
|
|
||||||
|
|
||||||
if (isInProtectedArea(location))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInProtectedArea(final Location modifyLocation)
|
|
||||||
{
|
|
||||||
boolean doSave = false;
|
|
||||||
boolean inProtectedArea = false;
|
|
||||||
|
|
||||||
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
final SerializableProtectedRegion region = it.next().getValue();
|
|
||||||
|
|
||||||
Location regionCenter = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
regionCenter = region.getLocation();
|
|
||||||
}
|
|
||||||
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
doSave = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regionCenter != null)
|
|
||||||
{
|
|
||||||
if (modifyLocation.getWorld() == regionCenter.getWorld())
|
|
||||||
{
|
|
||||||
final double regionRadius = region.getRadius();
|
|
||||||
if (modifyLocation.distanceSquared(regionCenter) <= (regionRadius * regionRadius))
|
|
||||||
{
|
|
||||||
inProtectedArea = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doSave)
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return inProtectedArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInProtectedArea(final Vector min, final Vector max, final String worldName)
|
|
||||||
{
|
|
||||||
boolean doSave = false;
|
|
||||||
boolean inProtectedArea = false;
|
|
||||||
|
|
||||||
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
final SerializableProtectedRegion region = it.next().getValue();
|
|
||||||
|
|
||||||
Location regionCenter = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
regionCenter = region.getLocation();
|
|
||||||
}
|
|
||||||
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
doSave = true;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (regionCenter != null)
|
|
||||||
{
|
|
||||||
if (worldName.equals(regionCenter.getWorld().getName()))
|
|
||||||
{
|
|
||||||
if (cubeIntersectsSphere(min, max, regionCenter.toVector(), region.getRadius()))
|
|
||||||
{
|
|
||||||
inProtectedArea = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doSave)
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
return inProtectedArea;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean cubeIntersectsSphere(Vector min, Vector max, Vector sphere, double radius)
|
|
||||||
{
|
|
||||||
double d = square(radius);
|
|
||||||
|
|
||||||
if (sphere.getX() < min.getX())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getX() - min.getX());
|
|
||||||
}
|
|
||||||
else if (sphere.getX() > max.getX())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getX() - max.getX());
|
|
||||||
}
|
|
||||||
if (sphere.getY() < min.getY())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getY() - min.getY());
|
|
||||||
}
|
|
||||||
else if (sphere.getY() > max.getY())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getY() - max.getY());
|
|
||||||
}
|
|
||||||
if (sphere.getZ() < min.getZ())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getZ() - min.getZ());
|
|
||||||
}
|
|
||||||
else if (sphere.getZ() > max.getZ())
|
|
||||||
{
|
|
||||||
d -= square(sphere.getZ() - max.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
return d > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private double square(double v)
|
|
||||||
{
|
|
||||||
return v * v;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addProtectedArea(String label, Location location, double radius)
|
|
||||||
{
|
|
||||||
areas.put(label.toLowerCase(), new SerializableProtectedRegion(location, radius));
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeProtectedArea(String label)
|
|
||||||
{
|
|
||||||
areas.remove(label.toLowerCase());
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearProtectedAreas()
|
|
||||||
{
|
|
||||||
clearProtectedAreas(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void clearProtectedAreas(boolean createSpawnpointProtectedAreas)
|
|
||||||
{
|
|
||||||
areas.clear();
|
|
||||||
|
|
||||||
if (createSpawnpointProtectedAreas)
|
|
||||||
{
|
|
||||||
autoAddSpawnpoints();
|
|
||||||
}
|
|
||||||
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cleanProtectedAreas()
|
|
||||||
{
|
|
||||||
boolean doSave = false;
|
|
||||||
|
|
||||||
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
|
||||||
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
it.next().getValue().getLocation();
|
|
||||||
}
|
|
||||||
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
|
||||||
{
|
|
||||||
it.remove();
|
|
||||||
doSave = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doSave)
|
|
||||||
{
|
|
||||||
save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getProtectedAreaLabels()
|
|
||||||
{
|
|
||||||
return areas.keySet();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void autoAddSpawnpoints()
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ConfigEntry.PROTECTAREA_SPAWNPOINTS.getBoolean())
|
|
||||||
{
|
|
||||||
for (World world : Bukkit.getWorlds())
|
|
||||||
{
|
|
||||||
addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), ConfigEntry.PROTECTAREA_RADIUS.getDouble());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class SerializableProtectedRegion implements Serializable
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 213123517828282L;
|
|
||||||
private final double x, y, z;
|
|
||||||
private final double radius;
|
|
||||||
private final String worldName;
|
|
||||||
private final UUID worldUUID;
|
|
||||||
private transient Location location = null;
|
|
||||||
|
|
||||||
public SerializableProtectedRegion(final Location location, final double radius)
|
|
||||||
{
|
|
||||||
this.x = location.getX();
|
|
||||||
this.y = location.getY();
|
|
||||||
this.z = location.getZ();
|
|
||||||
this.radius = radius;
|
|
||||||
this.worldName = location.getWorld().getName();
|
|
||||||
this.worldUUID = location.getWorld().getUID();
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Location getLocation() throws CantFindWorldException
|
|
||||||
{
|
|
||||||
if (this.location == null)
|
|
||||||
{
|
|
||||||
World world = Bukkit.getWorld(this.worldUUID);
|
|
||||||
|
|
||||||
if (world == null)
|
|
||||||
{
|
|
||||||
world = Bukkit.getWorld(this.worldName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world == null)
|
|
||||||
{
|
|
||||||
throw new CantFindWorldException("Can't find world " + this.worldName + ", UUID: " + this.worldUUID.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
location = new Location(world, x, y, z);
|
|
||||||
}
|
|
||||||
return this.location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getRadius()
|
|
||||||
{
|
|
||||||
return radius;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CantFindWorldException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public CantFindWorldException(String string)
|
|
||||||
{
|
|
||||||
super(string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
214
src/main/java/me/totalfreedom/totalfreedommod/Pterodactyl.java
Normal file
214
src/main/java/me/totalfreedom/totalfreedommod/Pterodactyl.java
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import joptsimple.internal.Strings;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Response;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
public class Pterodactyl extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public final String URL = ConfigEntry.PTERO_URL.getString();
|
||||||
|
private final String SERVER_KEY = ConfigEntry.PTERO_SERVER_KEY.getString();
|
||||||
|
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
|
||||||
|
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
|
||||||
|
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
|
||||||
|
|
||||||
|
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||||
|
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAccountStatus(Admin admin)
|
||||||
|
{
|
||||||
|
String id = admin.getPteroID();
|
||||||
|
|
||||||
|
if (Strings.isNullOrEmpty(id) || !enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!admin.isActive() || admin.getRank() != Rank.SENIOR_ADMIN)
|
||||||
|
{
|
||||||
|
FLog.debug("Disabling ptero acc");
|
||||||
|
removeAccountFromServer(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.debug("Enabling ptero acc");
|
||||||
|
addAccountToServer(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public String createAccount(String username, String password)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("username", username);
|
||||||
|
json.put("password", password);
|
||||||
|
json.put("email", username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString());
|
||||||
|
json.put("first_name", username);
|
||||||
|
json.put("last_name", "\u200E"); // required, so I made it appear empty
|
||||||
|
|
||||||
|
Response response;
|
||||||
|
JSONObject jsonResponse;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = FUtil.sendRequest(URL + "/api/application/users", "POST", ADMIN_HEADERS, json.toJSONString());
|
||||||
|
jsonResponse = response.getJSONMessage();
|
||||||
|
}
|
||||||
|
catch (IOException | ParseException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((JSONObject)jsonResponse.get("attributes")).get("id").toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteAccount(String id)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return FUtil.sendRequest(URL + "/api/application/users/" + id, "DELETE", ADMIN_HEADERS, json.toJSONString()).getCode() == 204;
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void addAccountToServer(String id)
|
||||||
|
{
|
||||||
|
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
|
||||||
|
|
||||||
|
JSONObject userData = getUserData(id);
|
||||||
|
if (userData == null)
|
||||||
|
{
|
||||||
|
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("email", userData.get("email").toString());
|
||||||
|
json.put("permissions", Arrays.asList("control.console", "control.start", "control.restart", "control.stop", "control.kill"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(url, "POST", SERVER_HEADERS, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAccountFromServer(String id)
|
||||||
|
{
|
||||||
|
JSONObject userData = getUserData(id);
|
||||||
|
if (userData == null)
|
||||||
|
{
|
||||||
|
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users/" + userData.get("uuid");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(url, "DELETE", SERVER_HEADERS, null);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getUserData(String id)
|
||||||
|
{
|
||||||
|
Response response;
|
||||||
|
JSONObject jsonResponse;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = FUtil.sendRequest(URL + "/api/application/users/" + id, "GET", ADMIN_HEADERS, null);
|
||||||
|
jsonResponse = response.getJSONMessage();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (IOException | ParseException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (JSONObject)jsonResponse.get("attributes");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void setPassword(String id, String password)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("password", password);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(URL + "/api/application/users/" + id, "PATCH", ADMIN_HEADERS, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getURL()
|
||||||
|
{
|
||||||
|
return URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getServerKey()
|
||||||
|
{
|
||||||
|
return SERVER_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAdminKey()
|
||||||
|
{
|
||||||
|
return ADMIN_KEY;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getServerHeaders()
|
||||||
|
{
|
||||||
|
return SERVER_HEADERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAdminHeaders()
|
||||||
|
{
|
||||||
|
return ADMIN_HEADERS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled)
|
||||||
|
{
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
}
|
@ -8,24 +8,17 @@ import java.io.ObjectOutputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
||||||
|
|
||||||
public class SavedFlags extends FreedomService
|
public class SavedFlags extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public SavedFlags(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,15 +26,15 @@ public class SavedFlags extends FreedomService
|
|||||||
public Map<String, Boolean> getSavedFlags()
|
public Map<String, Boolean> getSavedFlags()
|
||||||
{
|
{
|
||||||
Map<String, Boolean> flags = null;
|
Map<String, Boolean> flags = null;
|
||||||
|
File input = new File(TotalFreedomMod.getPlugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||||
|
|
||||||
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
|
||||||
if (input.exists())
|
if (input.exists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis))
|
try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis))
|
||||||
{
|
{
|
||||||
flags = (HashMap<String, Boolean>) ois.readObject();
|
flags = (HashMap<String, Boolean>)ois.readObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -4,35 +4,18 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
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.minecraft.server.v1_10_R1.EntityPlayer;
|
import net.minecraft.server.v1_16_R3.EntityPlayer;
|
||||||
import net.minecraft.server.v1_10_R1.MinecraftServer;
|
import net.minecraft.server.v1_16_R3.MinecraftServer;
|
||||||
import net.minecraft.server.v1_10_R1.PropertyManager;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_16_R3.CraftServer;
|
||||||
|
|
||||||
public class ServerInterface extends FreedomService
|
public class ServerInterface extends FreedomService
|
||||||
{
|
{
|
||||||
|
public static final String COMPILE_NMS_VERSION = "v1_16_R3";
|
||||||
public static final String COMPILE_NMS_VERSION = "v1_10_R1";
|
|
||||||
|
|
||||||
public ServerInterface(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void warnVersion()
|
public static void warnVersion()
|
||||||
{
|
{
|
||||||
final String nms = FUtil.getNmsVersion();
|
final String nms = FUtil.getNMSVersion();
|
||||||
|
|
||||||
if (!COMPILE_NMS_VERSION.equals(nms))
|
if (!COMPILE_NMS_VERSION.equals(nms))
|
||||||
{
|
{
|
||||||
@ -41,11 +24,19 @@ public class ServerInterface extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public void setOnlineMode(boolean mode)
|
public void setOnlineMode(boolean mode)
|
||||||
{
|
{
|
||||||
final PropertyManager manager = getServer().getPropertyManager();
|
getServer().setOnlineMode(mode);
|
||||||
manager.setProperty("online-mode", mode);
|
|
||||||
manager.savePropertiesFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int purgeWhitelist()
|
public int purgeWhitelist()
|
||||||
@ -86,7 +77,7 @@ public class ServerInterface extends FreedomService
|
|||||||
|
|
||||||
private MinecraftServer getServer()
|
private MinecraftServer getServer()
|
||||||
{
|
{
|
||||||
return ((CraftServer) Bukkit.getServer()).getServer();
|
return ((CraftServer)Bukkit.getServer()).getServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,26 +3,19 @@ package me.totalfreedom.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 org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
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.server.ServerListPingEvent;
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
|
||||||
public class ServerPing extends FreedomService
|
public class ServerPing extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public ServerPing(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,25 +26,31 @@ public class ServerPing extends FreedomService
|
|||||||
|
|
||||||
if (plugin.bm.isIpBanned(ip))
|
if (plugin.bm.isIpBanned(ip))
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "You are banned.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_BAN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Server is closed.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LoginProcess.isLockdownEnabled())
|
||||||
|
{
|
||||||
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_LOCKDOWN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.hasWhitelist())
|
if (Bukkit.hasWhitelist())
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Whitelist enabled.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_WHITELIST_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Server is full.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_FULL_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,5 +73,4 @@ public class ServerPing extends FreedomService
|
|||||||
|
|
||||||
event.setMotd(motd.toString().trim());
|
event.setMotd(motd.toString().trim());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
34
src/main/java/me/totalfreedom/totalfreedommod/Sitter.java
Normal file
34
src/main/java/me/totalfreedom/totalfreedommod/Sitter.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.command.Command_sit;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||||
|
|
||||||
|
public class Sitter extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDismount(EntityDismountEvent e)
|
||||||
|
{
|
||||||
|
Entity dm = e.getDismounted();
|
||||||
|
if (dm instanceof ArmorStand)
|
||||||
|
{
|
||||||
|
if (Command_sit.STANDS.contains(dm))
|
||||||
|
{
|
||||||
|
Command_sit.STANDS.remove(dm);
|
||||||
|
dm.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,66 +1,87 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.PVPBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.SignBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
||||||
import me.totalfreedom.totalfreedommod.caging.Cager;
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.CurseListener;
|
||||||
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
||||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MP44;
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||||
|
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||||
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
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 me.totalfreedom.totalfreedommod.util.MethodTimer;
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||||
import net.pravian.aero.component.service.ServiceManager;
|
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||||
import net.pravian.aero.plugin.AeroPlugin;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.mcstats.Metrics;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "config.yml";
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
//
|
//
|
||||||
public static final BuildProperties build = new BuildProperties();
|
public static final BuildProperties build = new BuildProperties();
|
||||||
//
|
//
|
||||||
public static String pluginName;
|
public static String pluginName;
|
||||||
public static String pluginVersion;
|
public static String pluginVersion;
|
||||||
|
private static TotalFreedomMod plugin;
|
||||||
//
|
//
|
||||||
public MainConfig config;
|
public MainConfig config;
|
||||||
|
public PermissionConfig permissions;
|
||||||
//
|
//
|
||||||
|
// Service Handler
|
||||||
|
public FreedomServiceHandler fsh;
|
||||||
|
// Command Loader
|
||||||
|
public CommandLoader cl;
|
||||||
// Services
|
// Services
|
||||||
public ServiceManager<TotalFreedomMod> services;
|
|
||||||
public ServerInterface si;
|
public ServerInterface si;
|
||||||
public SavedFlags sf;
|
public SavedFlags sf;
|
||||||
public WorldManager wm;
|
public WorldManager wm;
|
||||||
public LogViewer lv;
|
public LogViewer lv;
|
||||||
public AdminList al;
|
public AdminList al;
|
||||||
|
public ActivityLog acl;
|
||||||
public RankManager rm;
|
public RankManager rm;
|
||||||
public CommandLoader cl;
|
|
||||||
public CommandBlocker cb;
|
public CommandBlocker cb;
|
||||||
public EventBlocker eb;
|
public EventBlocker eb;
|
||||||
public BlockBlocker bb;
|
public BlockBlocker bb;
|
||||||
@ -71,55 +92,89 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public AntiNuke nu;
|
public AntiNuke nu;
|
||||||
public AntiSpam as;
|
public AntiSpam as;
|
||||||
public PlayerList pl;
|
public PlayerList pl;
|
||||||
|
public Shop sh;
|
||||||
|
public Votifier vo;
|
||||||
|
public SQLite sql;
|
||||||
public Announcer an;
|
public Announcer an;
|
||||||
public ChatManager cm;
|
public ChatManager cm;
|
||||||
|
public Discord dc;
|
||||||
|
public PunishmentList pul;
|
||||||
public BanManager bm;
|
public BanManager bm;
|
||||||
public PermbanList pm;
|
public IndefiniteBanList im;
|
||||||
public ProtectArea pa;
|
public PermissionManager pem;
|
||||||
public GameRuleHandler gr;
|
public GameRuleHandler gr;
|
||||||
public RollbackManager rb;
|
|
||||||
public CommandSpy cs;
|
public CommandSpy cs;
|
||||||
public Cager ca;
|
public Cager ca;
|
||||||
public Freezer fm;
|
public Freezer fm;
|
||||||
|
public EditBlocker ebl;
|
||||||
|
public PVPBlocker pbl;
|
||||||
public Orbiter or;
|
public Orbiter or;
|
||||||
public Muter mu;
|
public Muter mu;
|
||||||
public Fuckoff fo;
|
public Fuckoff fo;
|
||||||
public AutoKick ak;
|
public AutoKick ak;
|
||||||
public AutoEject ae;
|
public AutoEject ae;
|
||||||
|
public Monitors mo;
|
||||||
public MovementValidator mv;
|
public MovementValidator mv;
|
||||||
public EntityWiper ew;
|
|
||||||
public FrontDoor fd;
|
|
||||||
public ServerPing sp;
|
public ServerPing sp;
|
||||||
|
public CurseListener cul;
|
||||||
public ItemFun it;
|
public ItemFun it;
|
||||||
public Landminer lm;
|
public Landminer lm;
|
||||||
public MP44 mp;
|
public MP44 mp;
|
||||||
public Jumppads jp;
|
public Jumppads jp;
|
||||||
public Trailer tr;
|
public Trailer tr;
|
||||||
public HTTPDaemon hd;
|
public HTTPDaemon hd;
|
||||||
|
public WorldRestrictions wr;
|
||||||
|
public SignBlocker snp;
|
||||||
|
public EntityWiper ew;
|
||||||
|
public Sitter st;
|
||||||
|
public VanishHandler vh;
|
||||||
|
public Pterodactyl ptero;
|
||||||
|
//public HubWorldRestrictions hwr;
|
||||||
//
|
//
|
||||||
// Bridges
|
// Bridges
|
||||||
public ServiceManager<TotalFreedomMod> bridges;
|
|
||||||
public BukkitTelnetBridge btb;
|
public BukkitTelnetBridge btb;
|
||||||
public EssentialsBridge esb;
|
public EssentialsBridge esb;
|
||||||
|
public LibsDisguisesBridge ldb;
|
||||||
|
public CoreProtectBridge cpb;
|
||||||
|
public TFGuildsBridge tfg;
|
||||||
public WorldEditBridge web;
|
public WorldEditBridge web;
|
||||||
|
public WorldGuardBridge wgb;
|
||||||
|
|
||||||
|
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
|
@Override
|
||||||
public void load()
|
public void onLoad()
|
||||||
{
|
{
|
||||||
|
plugin = this;
|
||||||
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
||||||
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
FLog.setPluginLogger(plugin.getLogger());
|
FLog.setPluginLogger(plugin.getLogger());
|
||||||
FLog.setServerLogger(server.getLogger());
|
FLog.setServerLogger(getServer().getLogger());
|
||||||
|
|
||||||
build.load(plugin);
|
build.load(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
FLog.info("Created by Madgeek1450 and Prozza");
|
FLog.info("Created by Madgeek1450 and Prozza");
|
||||||
FLog.info("Version " + build.formattedVersion());
|
FLog.info("Version " + build.version);
|
||||||
FLog.info("Compiled " + build.date + " by " + build.author);
|
FLog.info("Compiled " + build.date + " by " + build.author);
|
||||||
|
|
||||||
final MethodTimer timer = new MethodTimer();
|
final MethodTimer timer = new MethodTimer();
|
||||||
@ -132,118 +187,63 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
FUtil.deleteCoreDumps();
|
FUtil.deleteCoreDumps();
|
||||||
FUtil.deleteFolder(new File("./_deleteme"));
|
FUtil.deleteFolder(new File("./_deleteme"));
|
||||||
|
|
||||||
// Convert old config files
|
fsh = new FreedomServiceHandler();
|
||||||
new ConfigConverter(plugin).convert();
|
|
||||||
|
|
||||||
BackupManager backups = new BackupManager(this);
|
config = new MainConfig();
|
||||||
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
|
||||||
backups.createBackups(AdminList.CONFIG_FILENAME);
|
|
||||||
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
|
||||||
|
|
||||||
config = new MainConfig(this);
|
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
// Start services
|
if (FUtil.inDeveloperMode())
|
||||||
services = new ServiceManager<>(plugin);
|
{
|
||||||
si = services.registerService(ServerInterface.class);
|
FLog.debug("Developer mode enabled.");
|
||||||
sf = services.registerService(SavedFlags.class);
|
}
|
||||||
wm = services.registerService(WorldManager.class);
|
|
||||||
lv = services.registerService(LogViewer.class);
|
|
||||||
al = services.registerService(AdminList.class);
|
|
||||||
rm = services.registerService(RankManager.class);
|
|
||||||
cl = services.registerService(CommandLoader.class);
|
|
||||||
cb = services.registerService(CommandBlocker.class);
|
|
||||||
eb = services.registerService(EventBlocker.class);
|
|
||||||
bb = services.registerService(BlockBlocker.class);
|
|
||||||
mb = services.registerService(MobBlocker.class);
|
|
||||||
ib = services.registerService(InteractBlocker.class);
|
|
||||||
pb = services.registerService(PotionBlocker.class);
|
|
||||||
lp = services.registerService(LoginProcess.class);
|
|
||||||
nu = services.registerService(AntiNuke.class);
|
|
||||||
as = services.registerService(AntiSpam.class);
|
|
||||||
|
|
||||||
pl = services.registerService(PlayerList.class);
|
cl = new CommandLoader();
|
||||||
an = services.registerService(Announcer.class);
|
cl.loadCommands();
|
||||||
cm = services.registerService(ChatManager.class);
|
|
||||||
bm = services.registerService(BanManager.class);
|
|
||||||
pm = services.registerService(PermbanList.class);
|
|
||||||
pa = services.registerService(ProtectArea.class);
|
|
||||||
gr = services.registerService(GameRuleHandler.class);
|
|
||||||
|
|
||||||
// Single admin utils
|
BackupManager backups = new BackupManager();
|
||||||
rb = services.registerService(RollbackManager.class);
|
backups.createAllBackups();
|
||||||
cs = services.registerService(CommandSpy.class);
|
|
||||||
ca = services.registerService(Cager.class);
|
|
||||||
fm = services.registerService(Freezer.class);
|
|
||||||
or = services.registerService(Orbiter.class);
|
|
||||||
mu = services.registerService(Muter.class);
|
|
||||||
fo = services.registerService(Fuckoff.class);
|
|
||||||
ak = services.registerService(AutoKick.class);
|
|
||||||
ae = services.registerService(AutoEject.class);
|
|
||||||
|
|
||||||
mv = services.registerService(MovementValidator.class);
|
permissions = new PermissionConfig();
|
||||||
ew = services.registerService(EntityWiper.class);
|
permissions.load();
|
||||||
fd = services.registerService(FrontDoor.class);
|
|
||||||
sp = services.registerService(ServerPing.class);
|
|
||||||
|
|
||||||
// Fun
|
mv = new MovementValidator();
|
||||||
it = services.registerService(ItemFun.class);
|
sp = new ServerPing();
|
||||||
lm = services.registerService(Landminer.class);
|
|
||||||
mp = services.registerService(MP44.class);
|
|
||||||
jp = services.registerService(Jumppads.class);
|
|
||||||
tr = services.registerService(Trailer.class);
|
|
||||||
|
|
||||||
// HTTPD
|
new Initializer();
|
||||||
hd = services.registerService(HTTPDaemon.class);
|
|
||||||
services.start();
|
|
||||||
|
|
||||||
// Start bridges
|
fsh.startServices();
|
||||||
bridges = new ServiceManager<>(plugin);
|
|
||||||
btb = bridges.registerService(BukkitTelnetBridge.class);
|
FLog.info("Started " + fsh.getServiceAmount() + " services.");
|
||||||
esb = bridges.registerService(EssentialsBridge.class);
|
|
||||||
web = bridges.registerService(WorldEditBridge.class);
|
|
||||||
bridges.start();
|
|
||||||
|
|
||||||
timer.update();
|
timer.update();
|
||||||
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
||||||
try
|
new Metrics(this, 2966);
|
||||||
{
|
|
||||||
final Metrics metrics = new Metrics(plugin);
|
|
||||||
metrics.start();
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
FLog.warning("Failed to submit metrics data: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
|
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
||||||
new BukkitRunnable()
|
SpigotConfig.config.set("settings.restart-on-crash", false);
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
plugin.pa.autoAddSpawnpoints();
|
|
||||||
}
|
|
||||||
}.runTaskLater(plugin, 60L);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
// Stop services and bridges
|
// Stop services and bridges
|
||||||
bridges.stop();
|
fsh.stopServices();
|
||||||
services.stop();
|
|
||||||
|
|
||||||
server.getScheduler().cancelTasks(plugin);
|
getServer().getScheduler().cancelTasks(plugin);
|
||||||
|
|
||||||
FLog.info("Plugin disabled");
|
FLog.info("Plugin disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkGenerator getDefaultWorldGenerator(@NotNull String worldName, String id)
|
||||||
|
{
|
||||||
|
return new CleanroomChunkGenerator(id);
|
||||||
|
}
|
||||||
|
|
||||||
public static class BuildProperties
|
public static class BuildProperties
|
||||||
{
|
{
|
||||||
|
|
||||||
public String author;
|
public String author;
|
||||||
public String codename;
|
public String codename;
|
||||||
public String version;
|
public String version;
|
||||||
@ -256,22 +256,24 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Properties props;
|
final Properties props;
|
||||||
|
|
||||||
try (InputStream in = plugin.getResource("build.properties"))
|
try (InputStream in = plugin.getResource("build.properties"))
|
||||||
{
|
{
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
props.load(in);
|
props.load(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
author = props.getProperty("program.build.author", "unknown");
|
author = props.getProperty("buildAuthor", "unknown");
|
||||||
codename = props.getProperty("program.build.codename", "unknown");
|
codename = props.getProperty("buildCodeName", "unknown");
|
||||||
version = props.getProperty("program.build.version", "unknown");
|
version = props.getProperty("buildVersion", pluginVersion);
|
||||||
number = props.getProperty("program.build.number", "1");
|
number = props.getProperty("buildNumber", "1");
|
||||||
date = props.getProperty("program.build.date", "unknown");
|
date = props.getProperty("buildDate", "unknown");
|
||||||
head = props.getProperty("program.build.head", "unknown");
|
// Need to do this or it will display ${git.commit.id.abbrev}
|
||||||
|
head = props.getProperty("buildHead", "unknown").replace("${git.commit.id.abbrev}", "unknown");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FLog.severe("Could not load build properties! Did you compile with Netbeans/ANT?");
|
FLog.severe("Could not load build properties! Did you compile with NetBeans/Maven?");
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,16 +284,102 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TotalFreedomMod plugin()
|
/**
|
||||||
|
* This class is provided to please Codacy.
|
||||||
|
*/
|
||||||
|
private final class Initializer
|
||||||
{
|
{
|
||||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
public Initializer()
|
||||||
{
|
{
|
||||||
if (plugin.getName().equalsIgnoreCase(pluginName))
|
initServices();
|
||||||
{
|
initAdminUtils();
|
||||||
return (TotalFreedomMod) plugin;
|
initBridges();
|
||||||
}
|
initFun();
|
||||||
|
initHTTPD();
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
private void initServices()
|
||||||
|
{
|
||||||
|
// Start services
|
||||||
|
si = new ServerInterface();
|
||||||
|
sf = new SavedFlags();
|
||||||
|
wm = new WorldManager();
|
||||||
|
lv = new LogViewer();
|
||||||
|
sql = new SQLite();
|
||||||
|
al = new AdminList();
|
||||||
|
acl = new ActivityLog();
|
||||||
|
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();
|
||||||
|
sh = new Shop();
|
||||||
|
vo = new Votifier();
|
||||||
|
an = new Announcer();
|
||||||
|
cm = new ChatManager();
|
||||||
|
dc = new Discord();
|
||||||
|
pul = new PunishmentList();
|
||||||
|
bm = new BanManager();
|
||||||
|
im = new IndefiniteBanList();
|
||||||
|
pem = new PermissionManager();
|
||||||
|
gr = new GameRuleHandler();
|
||||||
|
snp = new SignBlocker();
|
||||||
|
ew = new EntityWiper();
|
||||||
|
st = new Sitter();
|
||||||
|
vh = new VanishHandler();
|
||||||
|
ptero = new Pterodactyl();
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
tfg = new TFGuildsBridge();
|
||||||
|
web = new WorldEditBridge();
|
||||||
|
wgb = new WorldGuardBridge();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initFun()
|
||||||
|
{
|
||||||
|
// Fun
|
||||||
|
cul = new CurseListener();
|
||||||
|
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,83 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
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();
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player) && plugin.al.isVanished(p.getName()))
|
||||||
|
{
|
||||||
|
player.hidePlayer(plugin, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(p) && plugin.al.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
p.hidePlayer(plugin, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
plugin.esb.setVanished(player.getName(), true);
|
||||||
|
FLog.info(player.getName() + " joined while still vanished.");
|
||||||
|
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||||
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!plugin.al.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 0L, 4L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLeave(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.al.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
FLog.info(player.getName() + " left while still vanished.");
|
||||||
|
plugin.al.messageAllAdmins(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,212 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class ActivityLog extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String FILENAME = "activitylog.yml";
|
||||||
|
|
||||||
|
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
|
||||||
|
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
|
||||||
|
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
|
||||||
|
|
||||||
|
private final YamlConfig config;
|
||||||
|
|
||||||
|
public ActivityLog()
|
||||||
|
{
|
||||||
|
this.config = new YamlConfig(plugin, FILENAME, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFILENAME()
|
||||||
|
{
|
||||||
|
return FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load()
|
||||||
|
{
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
allActivityLogs.clear();
|
||||||
|
nameTable.clear();
|
||||||
|
ipTable.clear();
|
||||||
|
for (String key : config.getKeys(false))
|
||||||
|
{
|
||||||
|
ConfigurationSection section = config.getConfigurationSection(key);
|
||||||
|
if (section == null)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid activity log format: " + key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityLogEntry activityLogEntry = new ActivityLogEntry(key);
|
||||||
|
activityLogEntry.loadFrom(section);
|
||||||
|
|
||||||
|
if (!activityLogEntry.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Could not load activity log: " + key + ". Missing details!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
allActivityLogs.put(key, activityLogEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTables();
|
||||||
|
FLog.info("Loaded " + allActivityLogs.size() + " activity logs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
// Clear the config
|
||||||
|
for (String key : config.getKeys(false))
|
||||||
|
{
|
||||||
|
config.set(key, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ActivityLogEntry activityLog : allActivityLogs.values())
|
||||||
|
{
|
||||||
|
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getActivityLog(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
return getActivityLog((Player)sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getEntryByName(sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getActivityLog(Player player)
|
||||||
|
{
|
||||||
|
ActivityLogEntry activityLog = getEntryByName(player.getName());
|
||||||
|
if (activityLog == null)
|
||||||
|
{
|
||||||
|
String ip = FUtil.getIp(player);
|
||||||
|
activityLog = getEntryByIp(ip);
|
||||||
|
if (activityLog != null)
|
||||||
|
{
|
||||||
|
// Set the new username
|
||||||
|
activityLog.setName(player.getName());
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activityLog = new ActivityLogEntry(player);
|
||||||
|
allActivityLogs.put(activityLog.getConfigKey(), activityLog);
|
||||||
|
updateTables();
|
||||||
|
|
||||||
|
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String ip = FUtil.getIp(player);
|
||||||
|
if (!activityLog.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
activityLog.addIp(ip);
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
return activityLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getEntryByName(String name)
|
||||||
|
{
|
||||||
|
return nameTable.get(name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getEntryByIp(String ip)
|
||||||
|
{
|
||||||
|
return ipTable.get(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTables()
|
||||||
|
{
|
||||||
|
nameTable.clear();
|
||||||
|
ipTable.clear();
|
||||||
|
|
||||||
|
for (ActivityLogEntry activityLog : allActivityLogs.values())
|
||||||
|
{
|
||||||
|
nameTable.put(activityLog.getName().toLowerCase(), activityLog);
|
||||||
|
|
||||||
|
for (String ip : activityLog.getIps())
|
||||||
|
{
|
||||||
|
ipTable.put(ip, activityLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
getActivityLog(event.getPlayer()).addLogin();
|
||||||
|
plugin.acl.save();
|
||||||
|
plugin.acl.updateTables();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
getActivityLog(event.getPlayer()).addLogout();
|
||||||
|
plugin.acl.save();
|
||||||
|
plugin.acl.updateTables();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, ActivityLogEntry> getAllActivityLogs()
|
||||||
|
{
|
||||||
|
return allActivityLogs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, ActivityLogEntry> getNameTable()
|
||||||
|
{
|
||||||
|
return nameTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, ActivityLogEntry> getIpTable()
|
||||||
|
{
|
||||||
|
return ipTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public YamlConfig getConfig()
|
||||||
|
{
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,176 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ActivityLogEntry implements IConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String FILENAME = "activitylog.yml";
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
private final List<String> timestamps = Lists.newArrayList();
|
||||||
|
private final List<String> durations = Lists.newArrayList();
|
||||||
|
private String configKey;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
public ActivityLogEntry(Player player)
|
||||||
|
{
|
||||||
|
this.configKey = player.getName().toLowerCase();
|
||||||
|
this.name = player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry(String configKey)
|
||||||
|
{
|
||||||
|
this.configKey = configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getFILENAME()
|
||||||
|
{
|
||||||
|
return FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFrom(Player player)
|
||||||
|
{
|
||||||
|
configKey = player.getName().toLowerCase();
|
||||||
|
name = player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFrom(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
name = cs.getString("username", configKey);
|
||||||
|
ips.clear();
|
||||||
|
ips.addAll(cs.getStringList("ips"));
|
||||||
|
timestamps.clear();
|
||||||
|
timestamps.addAll(cs.getStringList("timestamps"));
|
||||||
|
durations.clear();
|
||||||
|
durations.addAll(cs.getStringList("durations"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
Validate.isTrue(isValid(), "Could not save activity entry: " + name + ". Entry not valid!");
|
||||||
|
cs.set("username", name);
|
||||||
|
cs.set("ips", Lists.newArrayList(ips));
|
||||||
|
cs.set("timestamps", Lists.newArrayList(timestamps));
|
||||||
|
cs.set("durations", Lists.newArrayList(durations));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLogin()
|
||||||
|
{
|
||||||
|
Date currentTime = Date.from(Instant.now());
|
||||||
|
timestamps.add("Login: " + FUtil.dateToString(currentTime));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLogout()
|
||||||
|
{
|
||||||
|
// Fix of Array index out of bonds issue: FS-131
|
||||||
|
String lastLoginString;
|
||||||
|
if(timestamps.size() > 1)
|
||||||
|
{
|
||||||
|
lastLoginString = timestamps.get(timestamps.size() - 1);
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
lastLoginString = timestamps.get(0);
|
||||||
|
}
|
||||||
|
Date currentTime = Date.from(Instant.now());
|
||||||
|
timestamps.add("Logout: " + FUtil.dateToString(currentTime));
|
||||||
|
lastLoginString = lastLoginString.replace("Login: ", "");
|
||||||
|
Date lastLogin = FUtil.stringToDate(lastLoginString);
|
||||||
|
|
||||||
|
long duration = currentTime.getTime() - lastLogin.getTime();
|
||||||
|
long seconds = duration / 1000 % 60;
|
||||||
|
long minutes = duration / (60 * 1000) % 60;
|
||||||
|
long hours = duration / (60 * 60 * 1000);
|
||||||
|
durations.add(hours + " hours, " + minutes + " minutes, and " + seconds + " seconds");
|
||||||
|
}
|
||||||
|
|
||||||
|
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 int getTotalSecondsPlayed()
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
for (String duration : durations)
|
||||||
|
{
|
||||||
|
String[] spl = duration.split(" ");
|
||||||
|
result += Integer.parseInt(spl[0]) * 60 * 60;
|
||||||
|
result += Integer.parseInt(spl[2]) * 60;
|
||||||
|
result += Integer.parseInt(spl[5]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return configKey != null
|
||||||
|
&& name != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getConfigKey()
|
||||||
|
{
|
||||||
|
return configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigKey(String configKey)
|
||||||
|
{
|
||||||
|
this.configKey = configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getIps()
|
||||||
|
{
|
||||||
|
return ips;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getTimestamps()
|
||||||
|
{
|
||||||
|
return timestamps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDurations()
|
||||||
|
{
|
||||||
|
return durations;
|
||||||
|
}
|
||||||
|
}
|
@ -1,54 +1,68 @@
|
|||||||
package me.totalfreedom.totalfreedommod.admin;
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import lombok.Getter;
|
import java.util.Map;
|
||||||
import lombok.Setter;
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
import org.bukkit.Bukkit;
|
||||||
import net.pravian.aero.base.Validatable;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.apache.commons.lang3.Validate;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
public class Admin
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
private String configKey;
|
private final List<String> ips = new ArrayList<>();
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String name;
|
private String name;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
@Getter
|
private Rank rank = Rank.ADMIN;
|
||||||
@Setter
|
|
||||||
private Rank rank = Rank.SUPER_ADMIN;
|
|
||||||
@Getter
|
|
||||||
private final List<String> ips = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Date lastLogin = new Date();
|
private Date lastLogin = new Date();
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String loginMessage = null;
|
private Boolean commandSpy = false;
|
||||||
|
|
||||||
|
|
||||||
|
private Boolean potionSpy = false;
|
||||||
|
|
||||||
|
|
||||||
|
private String acFormat = null;
|
||||||
|
|
||||||
|
|
||||||
|
private String pteroID = null;
|
||||||
|
|
||||||
public Admin(Player player)
|
public Admin(Player player)
|
||||||
{
|
{
|
||||||
this.configKey = player.getName().toLowerCase();
|
|
||||||
this.name = player.getName();
|
this.name = player.getName();
|
||||||
this.ips.add(Ips.getIp(player));
|
this.ips.add(FUtil.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Admin(String configKey)
|
public Admin(ResultSet resultSet)
|
||||||
{
|
{
|
||||||
this.configKey = configKey;
|
try
|
||||||
|
{
|
||||||
|
this.name = resultSet.getString("username");
|
||||||
|
this.active = resultSet.getBoolean("active");
|
||||||
|
this.rank = Rank.findRank(resultSet.getString("rank"));
|
||||||
|
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");
|
||||||
|
this.pteroID = resultSet.getString("ptero_id");
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load admin: " + e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,53 +73,30 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
output.append("Admin: ").append(name).append("\n")
|
output.append("Admin: ").append(name).append("\n")
|
||||||
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
||||||
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
||||||
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
|
||||||
.append("- Rank: ").append(rank.getName()).append("\n")
|
.append("- Rank: ").append(rank.getName()).append("\n")
|
||||||
.append("- Is Active: ").append(active);
|
.append("- Is Active: ").append(active).append("\n")
|
||||||
|
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||||
|
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
||||||
|
.append("- Pterodactyl ID: ").append(pteroID).append("\n");
|
||||||
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFrom(Player player)
|
public Map<String, Object> toSQLStorable()
|
||||||
{
|
{
|
||||||
configKey = player.getName().toLowerCase();
|
Map<String, Object> map = new HashMap<String, Object>()
|
||||||
name = player.getName();
|
{{
|
||||||
ips.clear();
|
put("username", name);
|
||||||
ips.add(Ips.getIp(player));
|
put("active", active);
|
||||||
}
|
put("rank", rank.toString());
|
||||||
|
put("ips", FUtil.listToString(ips));
|
||||||
@Override
|
put("last_login", lastLogin.getTime());
|
||||||
public void loadFrom(ConfigurationSection cs)
|
put("command_spy", commandSpy);
|
||||||
{
|
put("potion_spy", potionSpy);
|
||||||
name = cs.getString("username", configKey);
|
put("ac_format", acFormat);
|
||||||
active = cs.getBoolean("active", true);
|
put("ptero_id", pteroID);
|
||||||
rank = Rank.findRank(cs.getString("rank"));
|
}};
|
||||||
ips.clear();
|
return map;
|
||||||
ips.addAll(cs.getStringList("ips"));
|
|
||||||
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
|
|
||||||
loginMessage = cs.getString("login_message", null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
Validate.isTrue(isValid(), "Could not save admin entry: " + name + ". Entry not valid!");
|
|
||||||
cs.set("username", name);
|
|
||||||
cs.set("active", active);
|
|
||||||
cs.set("rank", rank.toString());
|
|
||||||
cs.set("ips", Lists.newArrayList(ips));
|
|
||||||
cs.set("last_login", FUtil.dateToString(lastLogin));
|
|
||||||
cs.set("login_message", loginMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAtLeast(Rank pRank)
|
|
||||||
{
|
|
||||||
return rank.isAtLeast(pRank);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasLoginMessage()
|
|
||||||
{
|
|
||||||
return loginMessage != null && !loginMessage.isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Util IP methods
|
// Util IP methods
|
||||||
@ -127,10 +118,7 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
public void removeIp(String ip)
|
public void removeIp(String ip)
|
||||||
{
|
{
|
||||||
if (ips.contains(ip))
|
ips.remove(ip);
|
||||||
{
|
|
||||||
ips.remove(ip);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearIPs()
|
public void clearIPs()
|
||||||
@ -138,13 +126,118 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
ips.clear();
|
ips.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
return configKey != null
|
return name != null
|
||||||
&& name != null
|
|
||||||
&& rank != null
|
&& rank != null
|
||||||
&& !ips.isEmpty()
|
&& !ips.isEmpty()
|
||||||
&& lastLogin != null;
|
&& lastLogin != null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
if (getRank().isAtLeast(Rank.ADMIN))
|
||||||
|
{
|
||||||
|
if (plugin.btb != null)
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Rank getRank()
|
||||||
|
{
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRank(Rank 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPteroID()
|
||||||
|
{
|
||||||
|
return pteroID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPteroID(String pteroID)
|
||||||
|
{
|
||||||
|
this.pteroID = pteroID;
|
||||||
|
}
|
||||||
|
}
|
@ -1,117 +1,96 @@
|
|||||||
package me.totalfreedom.totalfreedommod.admin;
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
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.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
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.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
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;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
|
||||||
|
|
||||||
public class AdminList extends FreedomService
|
public class AdminList extends FreedomService
|
||||||
{
|
{
|
||||||
|
public static final List<String> vanished = new ArrayList<>();
|
||||||
public static final String CONFIG_FILENAME = "admins.yml";
|
public final List<String> verifiedNoAdmin = new ArrayList<>();
|
||||||
|
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
||||||
@Getter
|
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||||
private final Map<String, Admin> allAdmins = Maps.newHashMap(); // Includes disabled admins
|
|
||||||
// Only active admins below
|
// Only active admins below
|
||||||
@Getter
|
|
||||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||||
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
||||||
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||||
//
|
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
public AdminList(TotalFreedomMod plugin)
|
public static List<String> getVanished()
|
||||||
{
|
{
|
||||||
super(plugin);
|
return vanished;
|
||||||
|
|
||||||
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
|
|
||||||
server.getServicesManager().register(Function.class, new Function<Player, Boolean>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public Boolean apply(Player player)
|
|
||||||
{
|
|
||||||
return isAdmin(player);
|
|
||||||
}
|
|
||||||
}, plugin, ServicePriority.Normal);
|
|
||||||
|
|
||||||
deactivateOldEntries(false);
|
deactivateOldEntries(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
config.load();
|
|
||||||
|
|
||||||
allAdmins.clear();
|
allAdmins.clear();
|
||||||
for (String key : config.getKeys(false))
|
try
|
||||||
{
|
{
|
||||||
ConfigurationSection section = config.getConfigurationSection(key);
|
ResultSet adminSet = plugin.sql.getAdminList();
|
||||||
if (section == null)
|
|
||||||
{
|
{
|
||||||
logger.warning("Invalid admin list format: " + key);
|
while (adminSet.next())
|
||||||
continue;
|
{
|
||||||
|
Admin admin = new Admin(adminSet);
|
||||||
|
allAdmins.add(admin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Admin admin = new Admin(key);
|
catch (SQLException e)
|
||||||
admin.loadFrom(section);
|
{
|
||||||
|
FLog.severe("Failed to load admin list: " + e.getMessage());
|
||||||
if (!admin.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Could not load admin: " + key + ". Missing details!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
allAdmins.put(key, admin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTables();
|
updateTables();
|
||||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void messageAllAdmins(String message)
|
||||||
{
|
{
|
||||||
// Clear the config
|
for (Player player : server.getOnlinePlayers())
|
||||||
for (String key : config.getKeys(false))
|
|
||||||
{
|
{
|
||||||
config.set(key, null);
|
if (isAdmin(player))
|
||||||
|
{
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Admin admin : allAdmins.values())
|
public void potionSpyMessage(String message)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
admin.saveTo(config.createSection(admin.getConfigKey()));
|
Admin admin = getAdmin(player.getPlayer());
|
||||||
|
if (isAdmin(player) && admin.getPotionSpy())
|
||||||
|
{
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean isAdminSync(CommandSender sender)
|
public synchronized boolean isAdminSync(CommandSender sender)
|
||||||
@ -119,6 +98,16 @@ public class AdminList extends FreedomService
|
|||||||
return isAdmin(sender);
|
return isAdmin(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getActiveAdminNames()
|
||||||
|
{
|
||||||
|
List<String> names = new ArrayList();
|
||||||
|
for (Admin admin : activeAdmins)
|
||||||
|
{
|
||||||
|
names.add(admin.getName());
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAdmin(CommandSender sender)
|
public boolean isAdmin(CommandSender sender)
|
||||||
{
|
{
|
||||||
if (!(sender instanceof Player))
|
if (!(sender instanceof Player))
|
||||||
@ -126,7 +115,19 @@ public class AdminList extends FreedomService
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = getAdmin((Player) sender);
|
Admin admin = getAdmin((Player)sender);
|
||||||
|
|
||||||
|
return admin != null && admin.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdmin(Player player)
|
||||||
|
{
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin admin = getAdmin(player);
|
||||||
|
|
||||||
return admin != null && admin.isActive();
|
return admin != null && admin.isActive();
|
||||||
}
|
}
|
||||||
@ -146,7 +147,7 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
{
|
{
|
||||||
return getAdmin((Player) sender);
|
return getAdmin((Player)sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getEntryByName(sender.getName());
|
return getEntryByName(sender.getName());
|
||||||
@ -155,7 +156,7 @@ public class AdminList extends FreedomService
|
|||||||
public Admin getAdmin(Player player)
|
public Admin getAdmin(Player player)
|
||||||
{
|
{
|
||||||
// Find admin
|
// Find admin
|
||||||
String ip = Ips.getIp(player);
|
String ip = FUtil.getIp(player);
|
||||||
Admin admin = getEntryByName(player.getName());
|
Admin admin = getEntryByName(player.getName());
|
||||||
|
|
||||||
// Admin by name
|
// Admin by name
|
||||||
@ -169,13 +170,11 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
// Add the new IP if we have to
|
// Add the new IP if we have to
|
||||||
admin.addIp(ip);
|
admin.addIp(ip);
|
||||||
save();
|
save(admin);
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
return admin;
|
return admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Impostor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Admin by ip
|
// Admin by ip
|
||||||
@ -183,8 +182,9 @@ public class AdminList extends FreedomService
|
|||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
// Set the new username
|
// Set the new username
|
||||||
|
String oldName = admin.getName();
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
save();
|
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,12 +230,18 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
admin.setLastLogin(new Date());
|
admin.setLastLogin(new Date());
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
save();
|
save(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdminImpostor(Player player)
|
public boolean isAdminImpostor(Player player)
|
||||||
{
|
{
|
||||||
return getEntryByName(player.getName()) != null && !isAdmin(player);
|
return getEntryByName(player.getName()) != null && !isAdmin(player) && !isVerifiedAdmin(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVerifiedAdmin(Player player)
|
||||||
|
{
|
||||||
|
// Fix of issue FS-33
|
||||||
|
return !verifiedNoAdmin.contains(player.getName()) || verifiedNoAdminIps.containsKey(player.getName()) && !verifiedNoAdminIps.get(player.getName()).contains(FUtil.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIdentityMatched(Player player)
|
public boolean isIdentityMatched(Player player)
|
||||||
@ -246,42 +252,46 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = getAdmin(player);
|
Admin admin = getAdmin(player);
|
||||||
return admin == null ? false : admin.getName().equalsIgnoreCase(player.getName());
|
return admin != null && admin.getName().equalsIgnoreCase(player.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean addAdmin(Admin admin)
|
public boolean addAdmin(Admin admin)
|
||||||
{
|
{
|
||||||
if (!admin.isValid())
|
if (!admin.isValid())
|
||||||
{
|
{
|
||||||
logger.warning("Could not add admin: " + admin.getConfigKey() + " Admin is missing details!");
|
FLog.warning("Could not add admin: " + admin.getName() + ". Admin is missing details!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String key = admin.getConfigKey();
|
|
||||||
|
|
||||||
// Store admin, update views
|
// Store admin, update views
|
||||||
allAdmins.put(key, admin);
|
allAdmins.add(admin);
|
||||||
updateTables();
|
updateTables();
|
||||||
|
|
||||||
// Save admin
|
// Save admin
|
||||||
admin.saveTo(config.createSection(key));
|
plugin.sql.addAdmin(admin);
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeAdmin(Admin admin)
|
public boolean removeAdmin(Admin admin)
|
||||||
{
|
{
|
||||||
|
if (admin.getRank().isAtLeast(Rank.ADMIN))
|
||||||
|
{
|
||||||
|
if (plugin.btb != null)
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(admin.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove admin, update views
|
// Remove admin, update views
|
||||||
if (allAdmins.remove(admin.getConfigKey()) == null)
|
if (!allAdmins.remove(admin))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
updateTables();
|
updateTables();
|
||||||
|
|
||||||
// 'Unsave' admin
|
// Unsave admin
|
||||||
config.set(admin.getConfigKey(), null);
|
plugin.sql.removeAdmin(admin);
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -292,7 +302,7 @@ public class AdminList extends FreedomService
|
|||||||
nameTable.clear();
|
nameTable.clear();
|
||||||
ipTable.clear();
|
ipTable.clear();
|
||||||
|
|
||||||
for (Admin admin : allAdmins.values())
|
for (Admin admin : allAdmins)
|
||||||
{
|
{
|
||||||
if (!admin.isActive())
|
if (!admin.isActive())
|
||||||
{
|
{
|
||||||
@ -308,8 +318,6 @@ public class AdminList extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.wm.adminworld.wipeAccessCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getAdminNames()
|
public Set<String> getAdminNames()
|
||||||
@ -322,9 +330,29 @@ public class AdminList extends FreedomService
|
|||||||
return ipTable.keySet();
|
return ipTable.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(Admin admin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
|
||||||
|
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)
|
public void deactivateOldEntries(boolean verbose)
|
||||||
{
|
{
|
||||||
for (Admin admin : allAdmins.values())
|
for (Admin admin : allAdmins)
|
||||||
{
|
{
|
||||||
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
||||||
{
|
{
|
||||||
@ -341,14 +369,48 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedomMod", "Deactivating superadmin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.lv.deactivateSuperadmin(admin);
|
save(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public boolean isVanished(String player)
|
||||||
|
{
|
||||||
|
return vanished.contains(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getVerifiedNoAdmin()
|
||||||
|
{
|
||||||
|
return verifiedNoAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, List<String>> getVerifiedNoAdminIps()
|
||||||
|
{
|
||||||
|
return verifiedNoAdminIps;
|
||||||
|
}
|
||||||
|
}
|
@ -2,70 +2,68 @@ package me.totalfreedom.totalfreedommod.banning;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.time.Instant;
|
||||||
|
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 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 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,
|
||||||
expire,
|
expire,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String[] ips, String by, 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;
|
||||||
|
if (expire == null)
|
||||||
|
{
|
||||||
|
expire = FUtil.parseDateOffset("24h");
|
||||||
|
}
|
||||||
this.expiryUnix = FUtil.getUnixTime(expire);
|
this.expiryUnix = FUtil.getUnixTime(expire);
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
@ -79,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(), 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(), expiry, reason);
|
return new Ban(null, null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -100,8 +95,10 @@ 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()),
|
||||||
expiry,
|
expiry,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
@ -116,8 +113,10 @@ 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()),
|
||||||
expiry,
|
expiry,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
@ -125,17 +124,29 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
FUtil.getFuzzyIp(Ips.getIp(player)),
|
player.getUniqueId(),
|
||||||
|
FUtil.getFuzzyIp(FUtil.getIp(player)),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SimpleDateFormat getDateFormat()
|
||||||
|
{
|
||||||
|
return DATE_FORMAT;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasUsername()
|
public boolean hasUsername()
|
||||||
{
|
{
|
||||||
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);
|
||||||
@ -156,11 +167,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return expiryUnix > 0;
|
return expiryUnix > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getExpiryDate()
|
|
||||||
{
|
|
||||||
return FUtil.getUnixDate(expiryUnix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExpired()
|
public boolean isExpired()
|
||||||
{
|
{
|
||||||
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||||
@ -170,7 +176,20 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
{
|
{
|
||||||
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());
|
||||||
|
|
||||||
@ -186,6 +205,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
.append(by);
|
.append(by);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (at != null)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Issued: ").append(ChatColor.GOLD)
|
||||||
|
.append(DATE_FORMAT.format(at));
|
||||||
|
}
|
||||||
|
|
||||||
if (getExpiryUnix() != 0)
|
if (getExpiryUnix() != 0)
|
||||||
{
|
{
|
||||||
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
|
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
|
||||||
@ -208,9 +233,9 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Ban ban = (Ban) object;
|
final Ban ban = (Ban)object;
|
||||||
if (hasIps() != ban.hasIps()
|
if (hasIps() != ban.hasIps()
|
||||||
|| hasUsername() != hasUsername())
|
|| hasUsername() != ban.hasUsername())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -223,57 +248,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.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("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;
|
||||||
|
}
|
||||||
|
}
|
@ -3,20 +3,20 @@ package me.totalfreedom.totalfreedommod.banning;
|
|||||||
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 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.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,42 +27,43 @@ 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 Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
||||||
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||||
//
|
|
||||||
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,
|
||||||
@ -72,15 +73,13 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
// Load unbannable usernames
|
// Load unbannable usernames
|
||||||
unbannableUsernames.clear();
|
unbannableUsernames.clear();
|
||||||
unbannableUsernames.addAll((Collection<? extends String>) ConfigEntry.FAMOUS_PLAYERS.getList());
|
unbannableUsernames.addAll(ConfigEntry.FAMOUS_PLAYERS.getStringList());
|
||||||
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
saveAll();
|
|
||||||
logger.info("Saved " + bans.size() + " player bans");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Ban> getAllBans()
|
public Set<Ban> getAllBans()
|
||||||
@ -98,21 +97,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);
|
||||||
@ -136,7 +120,7 @@ public class BanManager extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ips.fuzzyIpMatch(ip, loopIp, 4))
|
if (FUtil.fuzzyIpMatch(ip, loopIp, 4))
|
||||||
{
|
{
|
||||||
return loopBan;
|
return loopBan;
|
||||||
}
|
}
|
||||||
@ -159,6 +143,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);
|
||||||
@ -166,7 +162,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -179,7 +174,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -195,51 +189,69 @@ 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())
|
||||||
@ -248,11 +260,10 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@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))
|
||||||
{
|
{
|
||||||
@ -260,28 +271,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)
|
||||||
{
|
{
|
||||||
@ -290,6 +308,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())
|
||||||
@ -299,5 +322,4 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -0,0 +1,88 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public IndefiniteBan()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@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);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,165 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
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 final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
||||||
|
|
||||||
|
|
||||||
|
private int nameBanCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private int uuidBanCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
private int ipBanCount = 0;
|
||||||
|
|
||||||
|
public static String getConfigFilename()
|
||||||
|
{
|
||||||
|
return CONFIG_FILENAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
indefBans.clear();
|
||||||
|
|
||||||
|
final YamlConfig 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
indefBans.add(indefBan);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCount();
|
||||||
|
|
||||||
|
FLog.info("Loaded " + nameBanCount + " indefinite name bans, " + uuidBanCount + " UUID bans, and " + ipBanCount + " ip bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
String kickMessage = ChatColor.RED + "Your " + bannedBy + " is indefinitely banned from this server.";
|
||||||
|
String reason = ban.getReason();
|
||||||
|
if (!Strings.isNullOrEmpty(reason))
|
||||||
|
{
|
||||||
|
kickMessage += "\nReason: " + ChatColor.GOLD + reason;
|
||||||
|
}
|
||||||
|
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,90 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.banning;
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
|
||||||
import java.util.Set;
|
|
||||||
import lombok.Getter;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
|
|
||||||
public class PermbanList extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "permbans.yml";
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Set<String> permbannedNames = Sets.newHashSet();
|
|
||||||
@Getter
|
|
||||||
private final Set<String> permbannedIps = Sets.newHashSet();
|
|
||||||
|
|
||||||
public PermbanList(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
permbannedNames.clear();
|
|
||||||
permbannedIps.clear();
|
|
||||||
|
|
||||||
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
for (String name : config.getKeys(false))
|
|
||||||
{
|
|
||||||
permbannedNames.add(name.toLowerCase().trim());
|
|
||||||
permbannedIps.addAll(config.getStringList(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
FLog.info("Loaded " + permbannedIps.size() + " perm IP bans and " + permbannedNames.size() + " perm username bans.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
|
||||||
{
|
|
||||||
final String username = event.getPlayer().getName();
|
|
||||||
final String ip = Ips.getIp(event);
|
|
||||||
|
|
||||||
// Permbanned IPs
|
|
||||||
for (String testIp : getPermbannedIps())
|
|
||||||
{
|
|
||||||
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
|
|
||||||
{
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
|
||||||
ChatColor.RED + "Your IP address is permanently banned from this server.\n"
|
|
||||||
+ "Release procedures are available at\n"
|
|
||||||
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Permbanned usernames
|
|
||||||
for (String testPlayer : getPermbannedNames())
|
|
||||||
{
|
|
||||||
if (testPlayer.equalsIgnoreCase(username))
|
|
||||||
{
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
|
||||||
ChatColor.RED + "Your username is permanently banned from this server.\n"
|
|
||||||
+ "Release procedures are available at\n"
|
|
||||||
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,36 +1,35 @@
|
|||||||
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.Groups;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
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.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;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
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")
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
@ -39,33 +38,18 @@ public class BlockBlocker extends FreedomService
|
|||||||
switch (event.getBlockPlaced().getType())
|
switch (event.getBlockPlaced().getType())
|
||||||
{
|
{
|
||||||
case LAVA:
|
case LAVA:
|
||||||
case STATIONARY_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())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
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.");
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WATER:
|
case WATER:
|
||||||
case STATIONARY_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())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
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.");
|
||||||
@ -75,40 +59,130 @@ 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())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
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.");
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TNT:
|
case STRUCTURE_BLOCK:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case JIGSAW:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_JIGSAWS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GRINDSTONE:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Grindstones are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case JUKEBOX:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_JUKEBOXES.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Jukeboxes are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SPAWNER:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_SPAWNERS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Spawners are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BEEHIVE:
|
||||||
|
case BEE_NEST:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Beehives are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PLAYER_HEAD:
|
||||||
|
case PLAYER_WALL_HEAD:
|
||||||
|
{
|
||||||
|
Skull skull = (Skull)event.getBlockPlaced().getState();
|
||||||
|
if (skull.getOwner() != null)
|
||||||
|
{
|
||||||
|
if (skull.getOwner().contains("\u00A7"))
|
||||||
|
{
|
||||||
|
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
|
||||||
|
SkullMeta meta = (SkullMeta)event.getItemInHand().getItemMeta();
|
||||||
|
if (meta != null)
|
||||||
|
{
|
||||||
|
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
|
ItemMeta headMeta = newHead.getItemMeta();
|
||||||
|
assert headMeta != null;
|
||||||
|
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
|
||||||
|
newHead.setItemMeta(headMeta);
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
|
||||||
|
player.sendMessage(ChatColor.GRAY + "The player head you are attempting to place has a section symbol. Your player head has been C-sectioned.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skull.getOwner().length() > 100)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Instead of using Pi to crash players, be useful with your life and use it to discover things.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case RESPAWN_ANCHOR:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Respawn anchors are disabled.");
|
||||||
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 + "TNT is currently disabled.");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
||||||
|
{
|
||||||
|
Banner banner = (Banner)event.getBlockPlaced().getState();
|
||||||
|
List<Pattern> patterns = banner.getPatterns();
|
||||||
|
|
||||||
|
if (patterns.size() >= 2)
|
||||||
|
{
|
||||||
|
banner.setPatterns(patterns.subList(0, 2));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
public class EditBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
|
if (!fPlayer.isEditBlocked())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
|
{
|
||||||
|
fPlayer.setEditBlocked(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
|
if (!fPlayer.isEditBlocked())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
|
{
|
||||||
|
fPlayer.setEditBlocked(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
@ -1,41 +1,64 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
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.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
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.EntityType;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
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.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
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.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.FireworkExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +94,7 @@ public class EventBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.blockList().clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,32 +131,14 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onProjectileHit(ProjectileHitEvent event)
|
|
||||||
{
|
|
||||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
||||||
{
|
|
||||||
Projectile entity = event.getEntity();
|
|
||||||
if (event.getEntityType() == EntityType.ARROW)
|
|
||||||
{
|
|
||||||
entity.getWorld().createExplosion(entity.getLocation(), 2F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@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())
|
||||||
@ -141,7 +146,7 @@ public class EventBlocker extends FreedomService
|
|||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if (entity instanceof Tameable)
|
if (entity instanceof Tameable)
|
||||||
{
|
{
|
||||||
if (((Tameable) entity).isTamed())
|
if (((Tameable)entity).isTamed())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -152,6 +157,11 @@ public class EventBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
|
if (!plugin.al.isAdmin(event.getPlayer()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -169,4 +179,79 @@ public class EventBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onBlockGrowth(BlockGrowEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onFireworkExplode(FireworkExplodeEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPistonExtend(BlockPistonExtendEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
// 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)
|
||||||
|
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||||
|
{
|
||||||
|
double maxHealth = Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getValue();
|
||||||
|
if (maxHealth < 1)
|
||||||
|
{
|
||||||
|
for (AttributeModifier attributeModifier : Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getModifiers())
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH)).removeModifier(attributeModifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onBlockDispense(BlockDispenseEvent event)
|
||||||
|
{
|
||||||
|
List<Material> banned = Arrays.asList(Material.TNT_MINECART, Material.MINECART);
|
||||||
|
if (Groups.SPAWN_EGGS.contains(event.getItem().getType()) || banned.contains(event.getItem().getType()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent event)
|
||||||
|
{
|
||||||
|
FUtil.fixCommandVoid(event.getEntity());
|
||||||
|
event.setDeathMessage(event.getDeathMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,41 +1,32 @@
|
|||||||
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.player.FPlayer;
|
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.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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
|
|
||||||
switch (event.getAction())
|
switch (event.getAction())
|
||||||
{
|
{
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
@ -54,10 +45,47 @@ public class InteractBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onRightClickBell(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.BELL) && !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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleRightClick(PlayerInteractEvent event)
|
private void handleRightClick(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (event.getClickedBlock() != null)
|
||||||
|
{
|
||||||
|
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW) || event.getClickedBlock().getType().equals(Material.RESPAWN_ANCHOR))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().closeInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.getMaterial())
|
switch (event.getMaterial())
|
||||||
{
|
{
|
||||||
case WATER_BUCKET:
|
case WATER_BUCKET:
|
||||||
@ -86,7 +114,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EXPLOSIVE_MINECART:
|
case TNT_MINECART:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||||
{
|
{
|
||||||
@ -98,6 +126,38 @@ public class InteractBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ARMOR_STAND:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_ARMOR_STANDS.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Armor stands are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MINECART:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_MINECARTS.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Minecarts are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WRITTEN_BOOK:
|
||||||
|
{
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Books are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,37 +1,59 @@
|
|||||||
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 org.bukkit.attribute.Attributable;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.entity.Bat;
|
import org.bukkit.entity.Bat;
|
||||||
import org.bukkit.entity.EnderDragon;
|
import org.bukkit.entity.EnderDragon;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Ghast;
|
import org.bukkit.entity.Ghast;
|
||||||
import org.bukkit.entity.Giant;
|
import org.bukkit.entity.Giant;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Slime;
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.Wither;
|
||||||
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.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fixes crash mobs, credit to Mafrans
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onEntitySpawn(EntitySpawnEvent e)
|
||||||
|
{
|
||||||
|
if (!(e instanceof LivingEntity))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity entity = e.getEntity();
|
||||||
|
if (entity instanceof Attributable)
|
||||||
|
{
|
||||||
|
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).getBaseValue() > 255.0)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE)).setBaseValue(255.0);
|
||||||
|
}
|
||||||
|
if (Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).getBaseValue() > 10.0)
|
||||||
|
{
|
||||||
|
Objects.requireNonNull(((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED)).setBaseValue(10.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
{
|
{
|
||||||
@ -41,6 +63,7 @@ public class MobBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Entity spawned = event.getEntity();
|
final Entity spawned = event.getEntity();
|
||||||
|
|
||||||
if (spawned instanceof EnderDragon)
|
if (spawned instanceof EnderDragon)
|
||||||
{
|
{
|
||||||
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||||
@ -65,6 +88,14 @@ public class MobBlocker extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (spawned instanceof Wither)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (spawned instanceof Giant)
|
else if (spawned instanceof Giant)
|
||||||
{
|
{
|
||||||
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
|
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
|
||||||
@ -87,9 +118,9 @@ 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))
|
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
||||||
{
|
{
|
||||||
mobcount++;
|
mobcount++;
|
||||||
}
|
}
|
||||||
@ -100,5 +131,4 @@ public class MobBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -0,0 +1,97 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
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.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
public class PVPBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||||
|
{
|
||||||
|
Player player = null;
|
||||||
|
Player target = null;
|
||||||
|
if (event.getEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
target = (Player)event.getEntity();
|
||||||
|
if (event.getDamager() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)event.getDamager();
|
||||||
|
}
|
||||||
|
else if (event.getDamager() instanceof Arrow)
|
||||||
|
{
|
||||||
|
Arrow arrow = (Arrow)event.getDamager();
|
||||||
|
if (arrow.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
Trident trident = (Trident)event.getDamager();
|
||||||
|
if (trident.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)trident.getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.getDamager() instanceof FishHook)
|
||||||
|
{
|
||||||
|
FishHook fishhook = (FishHook)event.getDamager();
|
||||||
|
if (fishhook.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)fishhook.getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null & !plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "Creative PvP is not allowed!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else if (plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "God mode PvP is not allowed!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else if (plugin.pl.getPlayer(target).isPvpBlocked())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + target.getName() + " has PvP disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else if (plugin.pl.getPlayer(player).isPvpBlocked())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You have PvP disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,16 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
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.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
public class PotionBlocker extends FreedomService
|
public class PotionBlocker extends FreedomService
|
||||||
@ -14,49 +18,68 @@ 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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onThrowPotion(PotionSplashEvent event)
|
public void onThrowPotion(PotionSplashEvent event)
|
||||||
{
|
{
|
||||||
ProjectileSource source = event.getEntity().getShooter();
|
ThrownPotion potion = event.getEntity();
|
||||||
|
ProjectileSource projectileSource = potion.getShooter();
|
||||||
if (!(source instanceof Player))
|
Player player = null;
|
||||||
|
if (projectileSource instanceof Player)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
player = (Player)projectileSource;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Player thrower = (Player) source;
|
if (isDeathPotion(potion.getEffects()))
|
||||||
|
|
||||||
if (plugin.al.isAdmin(thrower))
|
|
||||||
{
|
{
|
||||||
return;
|
if (player != null)
|
||||||
}
|
|
||||||
|
|
||||||
for (Player player : thrower.getWorld().getPlayers())
|
|
||||||
{
|
|
||||||
if (thrower.getLocation().distanceSquared(player.getLocation()) < POTION_BLOCK_RADIUS_SQUARED)
|
|
||||||
{
|
{
|
||||||
thrower.sendMessage(ChatColor.RED + "You cannot use splash potions close to other players.");
|
player.sendMessage(ChatColor.RED + "You are not allowed to use death potions.");
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onThrowLingeringPotion(LingeringPotionSplashEvent event)
|
||||||
|
{
|
||||||
|
ThrownPotion potion = event.getEntity();
|
||||||
|
ProjectileSource projectileSource = potion.getShooter();
|
||||||
|
Player player = null;
|
||||||
|
if (projectileSource instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)projectileSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDeathPotion(potion.getEffects()))
|
||||||
|
{
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You are not allowed to use death potions.");
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDeathPotion(Collection<PotionEffect> effects)
|
||||||
|
{
|
||||||
|
for (PotionEffect effect : effects)
|
||||||
|
{
|
||||||
|
int amplifier = effect.getAmplifier();
|
||||||
|
if (effect.getType().equals(PotionEffectType.HEAL) && (amplifier == 29 || amplifier == 61 || amplifier == 93 || amplifier == 125))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import net.minecraft.server.v1_16_R3.NBTTagCompound;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Tag;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
|
||||||
|
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.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
//codebeat:disable[LOC,ABC]
|
||||||
|
|
||||||
|
public class SignBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerPlaceBlock(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||||
|
{
|
||||||
|
ItemStack sign = event.getItemInHand();
|
||||||
|
net.minecraft.server.v1_16_R3.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||||
|
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||||
|
assert compound != null;
|
||||||
|
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||||
|
String line1 = bet.getString("Text1");
|
||||||
|
String line2 = bet.getString("Text2");
|
||||||
|
String line3 = bet.getString("Text3");
|
||||||
|
String line4 = bet.getString("Text4");
|
||||||
|
if (line1.contains("run_command") || line2.contains("run_command") || line3.contains("run_command") || line4.contains("run_command"))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerInteractSign(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getClickedBlock() != null && Tag.SIGNS.getValues().contains(event.getClickedBlock().getType()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,23 +2,25 @@ 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.lang3.StringUtils;
|
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
|
||||||
{
|
{
|
||||||
@ -28,19 +30,32 @@ public class CommandBlocker extends FreedomService
|
|||||||
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();
|
||||||
}
|
}
|
||||||
@ -50,15 +65,10 @@ public class CommandBlocker extends FreedomService
|
|||||||
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();
|
||||||
for (String rawEntry : blockedCommands)
|
for (String rawEntry : blockedCommands)
|
||||||
{
|
{
|
||||||
final String[] parts = rawEntry.split(":");
|
final String[] parts = rawEntry.split(":");
|
||||||
@ -73,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;
|
||||||
@ -87,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
|
||||||
@ -105,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())
|
||||||
@ -160,6 +171,11 @@ public class CommandBlocker extends FreedomService
|
|||||||
|
|
||||||
for (String part : commandParts)
|
for (String part : commandParts)
|
||||||
{
|
{
|
||||||
|
if (command.startsWith("/") && !plugin.al.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Matcher matcher = flagPattern.matcher(part);
|
Matcher matcher = flagPattern.matcher(part);
|
||||||
if (!matcher.matches())
|
if (!matcher.matches())
|
||||||
{
|
{
|
||||||
@ -207,4 +223,4 @@ public class CommandBlocker extends FreedomService
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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,24 +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.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)
|
||||||
@ -31,25 +31,48 @@ public class CommandBlockerEntry
|
|||||||
this.rank = rank;
|
this.rank = rank;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.subCommand = (subCommand == null ? null : subCommand.toLowerCase().trim());
|
this.subCommand = ((subCommand == null) ? null : subCommand.toLowerCase().trim());
|
||||||
this.message = (message == null || message.equals("_") ? "That command is blocked." : message);
|
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doActions(CommandSender sender)
|
public void doActions(CommandSender sender)
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
|
sender.sendMessage(SpigotConfig.unknownCommandMessage);
|
||||||
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;
|
||||||
|
}
|
||||||
|
}
|
@ -4,50 +4,32 @@ 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.Rank;
|
||||||
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() == Rank.SENIOR_ADMIN)
|
||||||
{
|
{
|
||||||
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,33 +1,34 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
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.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.Rank;
|
||||||
|
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;
|
||||||
|
|
||||||
public class BukkitTelnetBridge extends FreedomService
|
public class BukkitTelnetBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,10 +65,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();
|
||||||
|
|
||||||
@ -82,7 +81,7 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
|
|
||||||
isAdmin = active;
|
isAdmin = active;
|
||||||
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
||||||
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.TELNET_ADMIN);
|
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||||
@ -94,4 +93,85 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public BukkitTelnet getBukkitTelnetPlugin()
|
||||||
|
{
|
||||||
|
if (bukkitTelnetPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
||||||
|
if (bukkitTelnet != null)
|
||||||
|
{
|
||||||
|
if (bukkitTelnet instanceof BukkitTelnet)
|
||||||
|
{
|
||||||
|
bukkitTelnetPlugin = (BukkitTelnet)bukkitTelnet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final List<ClientSession> sessionsToRemove = new ArrayList<>();
|
||||||
|
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
for (ClientSession session : telnet.appender.getSessions())
|
||||||
|
{
|
||||||
|
if (name != null && name.equalsIgnoreCase(session.getUserName()))
|
||||||
|
{
|
||||||
|
sessionsToRemove.add(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final ClientSession session : sessionsToRemove)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
telnet.appender.removeSession(session);
|
||||||
|
session.syncTerminateSession();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Error removing single telnet session: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info(sessionsToRemove.size() + " telnet session(s) removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Error removing telnet sessions: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,457 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.coreprotect.CoreProtect;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
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.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class CoreProtectBridge extends FreedomService
|
||||||
|
{
|
||||||
|
public static Map<Player, FUtil.PaginationList<String>> HISTORY_MAP = new HashMap<>();
|
||||||
|
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
||||||
|
|
||||||
|
private final HashMap<String, Long> cooldown = new HashMap<>();
|
||||||
|
private CoreProtectAPI coreProtectAPI = null;
|
||||||
|
private BukkitTask wiper;
|
||||||
|
|
||||||
|
public static Long getSecondsLeft(long prevTime, int timeAdd)
|
||||||
|
{
|
||||||
|
return prevTime / 1000L + timeAdd - System.currentTimeMillis() / 1000L;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unix timestamp converter taken from Functions class in CoreProtect, not my code
|
||||||
|
public static String getTimeAgo(int logTime, int currentTime)
|
||||||
|
{
|
||||||
|
StringBuilder message = new StringBuilder();
|
||||||
|
double timeSince = (double)currentTime - ((double)logTime + 0.0D);
|
||||||
|
timeSince /= 60.0D;
|
||||||
|
if (timeSince < 60.0D)
|
||||||
|
{
|
||||||
|
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/m ago");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.length() == 0)
|
||||||
|
{
|
||||||
|
timeSince /= 60.0D;
|
||||||
|
if (timeSince < 24.0D)
|
||||||
|
{
|
||||||
|
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/h ago");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.length() == 0)
|
||||||
|
{
|
||||||
|
timeSince /= 24.0D;
|
||||||
|
message.append((new DecimalFormat("0.00")).format(timeSince)).append("/d ago");
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreProtect getCoreProtect()
|
||||||
|
{
|
||||||
|
CoreProtect coreProtect = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin coreProtectPlugin = Bukkit.getServer().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()
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
coreProtect.performRestore(86400, Collections.singletonList(name), null, null, null, null, 0, null);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getDatabase()
|
||||||
|
{
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new File(getCoreProtect().getDataFolder(), "database.db"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDBSize()
|
||||||
|
{
|
||||||
|
double bytes = getDatabase().length();
|
||||||
|
double kilobytes = (bytes / 1024);
|
||||||
|
double megabytes = (kilobytes / 1024);
|
||||||
|
return (megabytes / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wipes DB for the specified world
|
||||||
|
public void clearDatabase(World world)
|
||||||
|
{
|
||||||
|
clearDatabase(world, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wipes DB for the specified world
|
||||||
|
public void clearDatabase(World world, Boolean shutdown)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.COREPROTECT_MYSQL_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final CoreProtect coreProtect = getCoreProtect();
|
||||||
|
|
||||||
|
if (coreProtect == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
|
||||||
|
we have to do this manually via SQL */
|
||||||
|
Connection connection;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
|
||||||
|
String port = ConfigEntry.COREPROTECT_MYSQL_PORT.getString();
|
||||||
|
String username = ConfigEntry.COREPROTECT_MYSQL_USERNAME.getString();
|
||||||
|
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
||||||
|
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||||
|
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||||
|
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
||||||
|
final Statement statement = connection.createStatement();
|
||||||
|
statement.setQueryTimeout(30);
|
||||||
|
|
||||||
|
// Obtain world ID from CoreProtect database
|
||||||
|
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'");
|
||||||
|
String worldID = null;
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
worldID = String.valueOf(resultSet.getInt("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the world ID is not null
|
||||||
|
|
||||||
|
if (worldID == null)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate through each table and delete their data if the world ID matches
|
||||||
|
for (String table : tables)
|
||||||
|
{
|
||||||
|
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID);
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to delete the CoreProtect data for the " + world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// This exits for flatlands wipes
|
||||||
|
if (shutdown)
|
||||||
|
{
|
||||||
|
server.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
|
if (data.hasInspection())
|
||||||
|
{
|
||||||
|
if (event.getAction() == Action.LEFT_CLICK_BLOCK)
|
||||||
|
{
|
||||||
|
if (block != null)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
List<String[]> lookup = coreProtect.blockLookup(block, -1);
|
||||||
|
|
||||||
|
int cooldownTime = 3;
|
||||||
|
|
||||||
|
if (cooldown.containsKey(player.getName()))
|
||||||
|
{
|
||||||
|
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
||||||
|
if (secondsLeft > 0L)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
cooldown.put(player.getName(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lookup != null)
|
||||||
|
{
|
||||||
|
if (lookup.isEmpty())
|
||||||
|
{
|
||||||
|
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HISTORY_MAP.remove(event.getPlayer());
|
||||||
|
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
||||||
|
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
||||||
|
|
||||||
|
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
||||||
|
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||||
|
|
||||||
|
for (String[] value : lookup)
|
||||||
|
{
|
||||||
|
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
||||||
|
BlockData bl = result.getBlockData();
|
||||||
|
|
||||||
|
String s;
|
||||||
|
String st = "";
|
||||||
|
|
||||||
|
if (result.getActionString().equals("Placement"))
|
||||||
|
{
|
||||||
|
s = " placed ";
|
||||||
|
}
|
||||||
|
else if (result.getActionString().equals("Removal"))
|
||||||
|
{
|
||||||
|
s = " broke ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = " interacted with ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.isRolledBack())
|
||||||
|
{
|
||||||
|
st += "§m";
|
||||||
|
}
|
||||||
|
|
||||||
|
int time = (int)(System.currentTimeMillis() / 1000L);
|
||||||
|
|
||||||
|
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
||||||
|
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> page = paged.getPage(1);
|
||||||
|
for (String entries : page)
|
||||||
|
{
|
||||||
|
player.sendMessage(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
|
||||||
|
{
|
||||||
|
if (block != null)
|
||||||
|
{
|
||||||
|
if (data.hasInspection())
|
||||||
|
{
|
||||||
|
BlockState blockState = block.getRelative(event.getBlockFace()).getState();
|
||||||
|
Block placedBlock = blockState.getBlock();
|
||||||
|
event.setCancelled(true);
|
||||||
|
List<String[]> lookup = coreProtect.blockLookup(placedBlock, -1);
|
||||||
|
|
||||||
|
if (lookup.isEmpty())
|
||||||
|
{
|
||||||
|
lookup = coreProtect.blockLookup(block, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int cooldownTime = 3;
|
||||||
|
|
||||||
|
if (cooldown.containsKey(player.getName()))
|
||||||
|
{
|
||||||
|
long secondsLeft = getSecondsLeft(cooldown.get(player.getName()), cooldownTime);
|
||||||
|
if (secondsLeft > 0L)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.sendMessage(ChatColor.RED + String.valueOf(secondsLeft) + " seconds left before next query.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
cooldown.put(player.getName(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lookup != null)
|
||||||
|
{
|
||||||
|
if (lookup.isEmpty())
|
||||||
|
{
|
||||||
|
player.sendMessage(net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector " + ChatColor.WHITE + "- " + "No block data found for this location");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HISTORY_MAP.remove(event.getPlayer());
|
||||||
|
HISTORY_MAP.put(event.getPlayer(), new FUtil.PaginationList<>(10));
|
||||||
|
FUtil.PaginationList<String> paged = HISTORY_MAP.get(event.getPlayer());
|
||||||
|
|
||||||
|
player.sendMessage("---- " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "Block Inspector" + ChatColor.WHITE + " ---- " +
|
||||||
|
ChatColor.GRAY + "(x" + block.getX() + "/" + "y" + block.getY() + "/" + "z" + block.getZ() + ")");
|
||||||
|
|
||||||
|
for (String[] value : lookup)
|
||||||
|
{
|
||||||
|
CoreProtectAPI.ParseResult result = coreProtect.parseResult(value);
|
||||||
|
BlockData bl = result.getBlockData();
|
||||||
|
|
||||||
|
String s;
|
||||||
|
String st = "";
|
||||||
|
|
||||||
|
if (result.getActionString().equals("Placement"))
|
||||||
|
{
|
||||||
|
s = " placed ";
|
||||||
|
}
|
||||||
|
else if (result.getActionString().equals("Removal"))
|
||||||
|
{
|
||||||
|
s = " broke ";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
s = " interacted with ";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.isRolledBack())
|
||||||
|
{
|
||||||
|
st += "§m";
|
||||||
|
}
|
||||||
|
|
||||||
|
int time = (int)(System.currentTimeMillis() / 1000L);
|
||||||
|
|
||||||
|
paged.add(ChatColor.GRAY + getTimeAgo(result.getTime(), time) + ChatColor.WHITE + " - " + net.md_5.bungee.api.ChatColor.of("#30ade4") +
|
||||||
|
st + result.getPlayer() + ChatColor.WHITE + st + s + net.md_5.bungee.api.ChatColor.of("#30ade4") + st + bl.getMaterial().toString().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> page = paged.getPage(1);
|
||||||
|
for (String entries : page)
|
||||||
|
{
|
||||||
|
player.sendMessage(entries);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage("Page 1/" + paged.getPageCount() + " | To index through the pages, type " + net.md_5.bungee.api.ChatColor.of("#30ade4") + "/ins history <page>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,29 +3,35 @@ 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.rank.Rank;
|
||||||
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.Bukkit;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class EssentialsBridge extends FreedomService
|
public class EssentialsBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
private Essentials essentialsPlugin = null;
|
private Essentials essentialsPlugin = null;
|
||||||
|
|
||||||
public EssentialsBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,13 +41,11 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
|
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
||||||
if (essentials != null)
|
assert essentials != null;
|
||||||
|
if (essentials instanceof Essentials)
|
||||||
{
|
{
|
||||||
if (essentials instanceof Essentials)
|
essentialsPlugin = (Essentials)essentials;
|
||||||
{
|
|
||||||
essentialsPlugin = (Essentials) essentials;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -56,7 +60,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Essentials essentials = getEssentialsPlugin();
|
Essentials essentials = getEssentialsPlugin();
|
||||||
if (essentials != null)
|
if (essentials != null)
|
||||||
{
|
{
|
||||||
return essentials.getUserMap().getUser(username);
|
return essentials.getUserMap().getUser(username);
|
||||||
@ -73,7 +77,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
user.setNickname(nickname);
|
user.setNickname(nickname);
|
||||||
@ -90,7 +94,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return user.getNickname();
|
return user.getNickname();
|
||||||
@ -107,10 +111,11 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return FUtil.<Long>getField(user, "lastActivity"); // This is weird
|
Long l = FUtil.getField(user, "lastActivity");
|
||||||
|
return (l != null) ? l : 0L;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -120,20 +125,97 @@ public class EssentialsBridge extends FreedomService
|
|||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEssentialsEnabled()
|
public void setVanished(String username, boolean vanished)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Essentials essentials = getEssentialsPlugin();
|
User user = getEssentialsUser(username);
|
||||||
if (essentials != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return essentials.isEnabled();
|
user.setVanished(vanished);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onInventoryClick(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
Player refreshPlayer = null;
|
||||||
|
Inventory inventory = event.getView().getTopInventory();
|
||||||
|
InventoryType inventoryType = inventory.getType();
|
||||||
|
Player player = (Player)event.getWhoClicked();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||||
|
{
|
||||||
|
final InventoryHolder inventoryHolder = inventory.getHolder();
|
||||||
|
if (inventoryHolder instanceof HumanEntity)
|
||||||
|
{
|
||||||
|
Player invOwner = (Player)inventoryHolder;
|
||||||
|
Rank recieverRank = plugin.rm.getRank(player);
|
||||||
|
Rank playerRank = plugin.rm.getRank(invOwner);
|
||||||
|
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
refreshPlayer = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (refreshPlayer != null)
|
||||||
|
{
|
||||||
|
final Player p = refreshPlayer;
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
p.updateInventory();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 20L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onInventoryClose(InventoryCloseEvent event)
|
||||||
|
{
|
||||||
|
Player refreshPlayer = null;
|
||||||
|
Inventory inventory = event.getView().getTopInventory();
|
||||||
|
InventoryType inventoryType = inventory.getType();
|
||||||
|
Player player = (Player)event.getPlayer();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||||
|
{
|
||||||
|
fPlayer.setInvSee(false);
|
||||||
|
refreshPlayer = player;
|
||||||
|
}
|
||||||
|
if (refreshPlayer != null)
|
||||||
|
{
|
||||||
|
final Player p = refreshPlayer;
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
p.updateInventory();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 20L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Actually use this for something or remove it.
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
final Essentials ess = getEssentialsPlugin();
|
||||||
|
|
||||||
|
return ess != null && ess.isEnabled();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.BlockedDisguises;
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class LibsDisguisesBridge extends FreedomService
|
||||||
|
{
|
||||||
|
private LibsDisguises libsDisguisesPlugin = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public LibsDisguises getLibsDisguisesPlugin()
|
||||||
|
{
|
||||||
|
if (libsDisguisesPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises");
|
||||||
|
if (libsDisguises != null)
|
||||||
|
{
|
||||||
|
if (libsDisguises instanceof LibsDisguises)
|
||||||
|
{
|
||||||
|
libsDisguisesPlugin = (LibsDisguises)libsDisguises;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return libsDisguisesPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void undisguiseAll(boolean admin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
if (libsDisguises == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (DisguiseAPI.isDisguised(player))
|
||||||
|
{
|
||||||
|
if (!admin && plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DisguiseAPI.undisguiseToAll(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisguisesEnabled()
|
||||||
|
{
|
||||||
|
return !BlockedDisguises.disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisguisesEnabled(boolean state)
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
if (libsDisguises == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockedDisguises.disabled = !state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
return libsDisguises != null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.totalfreedom.tfguilds.Common;
|
||||||
|
import me.totalfreedom.tfguilds.TFGuilds;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class TFGuildsBridge extends FreedomService
|
||||||
|
{
|
||||||
|
public boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTFGuildsEnabled()
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds");
|
||||||
|
if (tfGuilds != null && tfGuilds.isEnabled())
|
||||||
|
{
|
||||||
|
if (tfGuilds instanceof TFGuilds)
|
||||||
|
{
|
||||||
|
enabled = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoClassDefFoundError ex)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inGuildChat(Player player)
|
||||||
|
{
|
||||||
|
if (!isTFGuildsEnabled())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Common.IN_GUILD_CHAT.contains(player);
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
@ -12,26 +11,41 @@ import org.bukkit.plugin.Plugin;
|
|||||||
public class WorldEditBridge extends FreedomService
|
public class WorldEditBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
private final WorldEditListener listener;
|
|
||||||
//
|
//
|
||||||
private WorldEditPlugin worldedit = null;
|
private WorldEditPlugin worldeditPlugin = null;
|
||||||
|
|
||||||
public WorldEditBridge(TotalFreedomMod plugin)
|
@Override
|
||||||
|
public void onStart()
|
||||||
{
|
{
|
||||||
super(plugin);
|
|
||||||
listener = new WorldEditListener(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStop()
|
||||||
{
|
{
|
||||||
listener.register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public WorldEditPlugin getWorldEditPlugin()
|
||||||
protected void onStop()
|
|
||||||
{
|
{
|
||||||
listener.unregister();
|
if (worldeditPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
|
||||||
|
if (we != null)
|
||||||
|
{
|
||||||
|
if (we instanceof WorldEditPlugin)
|
||||||
|
{
|
||||||
|
worldeditPlugin = (WorldEditPlugin)we;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return worldeditPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undo(Player player, int count)
|
public void undo(Player player, int count)
|
||||||
@ -57,28 +71,27 @@ public class WorldEditBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorldEditPlugin getWorldEditPlugin()
|
public void redo(Player player, int count)
|
||||||
{
|
{
|
||||||
if (worldedit == null)
|
try
|
||||||
{
|
{
|
||||||
try
|
LocalSession session = getPlayerSession(player);
|
||||||
|
if (session != null)
|
||||||
{
|
{
|
||||||
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
|
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
||||||
if (we != null)
|
if (bukkitPlayer != null)
|
||||||
{
|
{
|
||||||
if (we instanceof WorldEditPlugin)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
worldedit = (WorldEditPlugin) we;
|
session.redo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
return worldedit;
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLimit(Player player, int limit)
|
public void setLimit(Player player, int limit)
|
||||||
@ -98,6 +111,30 @@ public class WorldEditBridge extends FreedomService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDefaultLimit()
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wep.getLocalConfiguration().defaultChangeLimit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxLimit()
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wep.getLocalConfiguration().maxChangeLimit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private LocalSession getPlayerSession(Player player)
|
private LocalSession getPlayerSession(Player player)
|
||||||
{
|
{
|
||||||
final WorldEditPlugin wep = getWorldEditPlugin();
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import me.totalfreedom.worldedit.LimitChangedEvent;
|
|
||||||
import me.totalfreedom.worldedit.SelectionChangedEvent;
|
|
||||||
import net.pravian.aero.component.PluginListener;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
public class WorldEditListener extends PluginListener<TotalFreedomMod>
|
|
||||||
{
|
|
||||||
|
|
||||||
public WorldEditListener(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onSelectionChange(final SelectionChangedEvent event)
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.pa.isInProtectedArea(
|
|
||||||
event.getMinVector(),
|
|
||||||
event.getMaxVector(),
|
|
||||||
event.getWorld().getName()))
|
|
||||||
{
|
|
||||||
|
|
||||||
player.sendMessage(ChatColor.RED + "The region that you selected contained a protected area. Selection cleared.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onLimitChanged(LimitChangedEvent event)
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event.getPlayer().equals(event.getTarget()))
|
|
||||||
{
|
|
||||||
player.sendMessage(ChatColor.RED + "Only admins can change the limit for other players!");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getLimit() < 0 || event.getLimit() > 10000)
|
|
||||||
{
|
|
||||||
player.setOp(false);
|
|
||||||
FUtil.bcastMsg(event.getPlayer().getName() + " tried to set their WorldEdit limit to " + event.getLimit() + " and has been de-opped", ChatColor.RED);
|
|
||||||
event.setCancelled(true);
|
|
||||||
player.sendMessage(ChatColor.RED + "You cannot set your limit higher than 10000 or to -1!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,55 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class WorldGuardBridge extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
|
||||||
|
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionManager getRegionManager(World world)
|
||||||
|
{
|
||||||
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
return container.get(BukkitAdapter.adapt(world));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int wipeRegions(World world)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
RegionManager regionManager = getRegionManager(world);
|
||||||
|
if (regionManager != null)
|
||||||
|
{
|
||||||
|
Map<String, ProtectedRegion> regions = regionManager.getRegions();
|
||||||
|
for (ProtectedRegion region : regions.values())
|
||||||
|
{
|
||||||
|
regionManager.removeRegion(region.getId());
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
Plugin plugin = server.getPluginManager().getPlugin("WorldGuard");
|
||||||
|
|
||||||
|
return plugin != null && plugin.isEnabled();
|
||||||
|
}
|
||||||
|
}
|
@ -2,28 +2,23 @@ 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;
|
||||||
import org.bukkit.SkullType;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Skull;
|
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;
|
||||||
|
|
||||||
public CageData(FPlayer player)
|
public CageData(FPlayer player)
|
||||||
@ -31,19 +26,91 @@ public class CageData
|
|||||||
this.fPlayer = player;
|
this.fPlayer = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCaged(boolean cage)
|
// Util methods
|
||||||
|
public static void generateCube(Location location, int length, Material material)
|
||||||
{
|
{
|
||||||
if (cage)
|
final Block center = location.getBlock();
|
||||||
|
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||||
{
|
{
|
||||||
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||||
}
|
{
|
||||||
else
|
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||||
{
|
{
|
||||||
this.caged = false;
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
regenerateHistory();
|
if (block.getType() != material)
|
||||||
clearHistory();
|
{
|
||||||
|
block.setType(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static void generateHollowCube(Location location, int length, Material material)
|
||||||
|
{
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
// Hollow
|
||||||
|
if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
|
||||||
|
if (material != Material.PLAYER_HEAD)
|
||||||
|
{
|
||||||
|
// Glowstone light
|
||||||
|
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
|
||||||
|
{
|
||||||
|
block.setType(Material.GLOWSTONE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.setType(material);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
|
||||||
|
{
|
||||||
|
block.setType(Material.GLOWSTONE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.setType(Material.PLAYER_HEAD);
|
||||||
|
if (input != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Skull skull = (Skull)block.getState();
|
||||||
|
// This may or may not work in future versions of spigot
|
||||||
|
skull.setOwner(input);
|
||||||
|
skull.update();
|
||||||
|
}
|
||||||
|
catch (ClassCastException ignored)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getInput()
|
||||||
|
{
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setInput(String input)
|
||||||
|
{
|
||||||
|
CageData.input = input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cage(Location location, Material outer, Material inner)
|
public void cage(Location location, Material outer, Material inner)
|
||||||
@ -57,8 +124,26 @@ public class CageData
|
|||||||
this.location = location;
|
this.location = location;
|
||||||
this.outerMaterial = outer;
|
this.outerMaterial = outer;
|
||||||
this.innerMaterial = inner;
|
this.innerMaterial = inner;
|
||||||
|
input = null;
|
||||||
|
|
||||||
buildHistory(location, 2, fPlayer);
|
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;
|
||||||
|
|
||||||
|
buildHistory(location);
|
||||||
regenerate();
|
regenerate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +162,7 @@ public class CageData
|
|||||||
generateCube(location, 1, innerMaterial);
|
generateCube(location, 1, innerMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: EventHandlerize this?
|
// TODO: EventHandler this?
|
||||||
public void playerJoin()
|
public void playerJoin()
|
||||||
{
|
{
|
||||||
if (!isCaged())
|
if (!isCaged())
|
||||||
@ -85,7 +170,7 @@ public class CageData
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial);
|
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerQuit()
|
public void playerQuit()
|
||||||
@ -112,14 +197,14 @@ public class CageData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buildHistory(Location location, int length, FPlayer playerdata)
|
private void buildHistory(Location location)
|
||||||
{
|
{
|
||||||
final Block center = location.getBlock();
|
final Block center = location.getBlock();
|
||||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
for (int xOffset = -2; xOffset <= 2; xOffset++)
|
||||||
{
|
{
|
||||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
for (int yOffset = -2; yOffset <= 2; yOffset++)
|
||||||
{
|
{
|
||||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
for (int zOffset = -2; zOffset <= 2; zOffset++)
|
||||||
{
|
{
|
||||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
insertHistoryBlock(block.getLocation(), block.getType());
|
insertHistoryBlock(block.getLocation(), block.getType());
|
||||||
@ -128,71 +213,64 @@ public class CageData
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Util methods
|
public FPlayer getfPlayer()
|
||||||
public static void generateCube(Location location, int length, Material material)
|
|
||||||
{
|
{
|
||||||
final Block center = location.getBlock();
|
return fPlayer;
|
||||||
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);
|
|
||||||
if (block.getType() != material)
|
|
||||||
{
|
|
||||||
block.setType(material);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void generateHollowCube(Location location, int length, Material material)
|
public List<BlockData> getCageHistory()
|
||||||
{
|
{
|
||||||
final Block center = location.getBlock();
|
return cageHistory;
|
||||||
for (int xOffset = -length; xOffset <= length; xOffset++)
|
}
|
||||||
|
|
||||||
|
public boolean isCaged()
|
||||||
|
{
|
||||||
|
return caged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaged(boolean cage)
|
||||||
|
{
|
||||||
|
if (cage)
|
||||||
{
|
{
|
||||||
for (int yOffset = -length; yOffset <= length; yOffset++)
|
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
||||||
{
|
|
||||||
for (int zOffset = -length; zOffset <= length; zOffset++)
|
|
||||||
{
|
|
||||||
// Hollow
|
|
||||||
if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
|
||||||
|
|
||||||
if (material != Material.SKULL)
|
|
||||||
{
|
|
||||||
// Glowstone light
|
|
||||||
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
|
|
||||||
{
|
|
||||||
block.setType(Material.GLOWSTONE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
block.setType(material);
|
|
||||||
}
|
|
||||||
else // Darth mode
|
|
||||||
{
|
|
||||||
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
|
|
||||||
{
|
|
||||||
block.setType(Material.GLOWSTONE);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
block.setType(Material.SKULL);
|
|
||||||
final Skull skull = (Skull) block.getState();
|
|
||||||
skull.setSkullType(SkullType.PLAYER);
|
|
||||||
skull.setOwner("Prozza");
|
|
||||||
skull.update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
@ -11,24 +12,19 @@ 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.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
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()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,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;
|
||||||
}
|
}
|
||||||
@ -66,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;
|
||||||
}
|
}
|
||||||
@ -77,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();
|
||||||
}
|
}
|
||||||
@ -95,6 +90,18 @@ public class Cager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
cage.playerQuit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
@ -106,5 +113,4 @@ public class Cager extends FreedomService
|
|||||||
cage.playerJoin();
|
cage.playerJoin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -10,4 +10,4 @@ public class CommandFailException extends RuntimeException
|
|||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,45 +1,85 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import lombok.Getter;
|
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.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import net.pravian.aero.command.handler.SimpleCommandHandler;
|
import org.reflections.Reflections;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CommandLoader extends FreedomService
|
public class CommandLoader extends FreedomService
|
||||||
{
|
{
|
||||||
|
private final List<FreedomCommand> commands;
|
||||||
|
|
||||||
@Getter
|
public CommandLoader()
|
||||||
private final SimpleCommandHandler<TotalFreedomMod> handler;
|
|
||||||
|
|
||||||
public CommandLoader(TotalFreedomMod plugin)
|
|
||||||
{
|
{
|
||||||
super(plugin);
|
commands = new ArrayList<>();
|
||||||
|
|
||||||
handler = new SimpleCommandHandler<>(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
handler.clearCommands();
|
|
||||||
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
|
|
||||||
handler.setCommandClassPrefix("Command_");
|
|
||||||
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
|
|
||||||
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
|
|
||||||
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
|
|
||||||
|
|
||||||
handler.loadFrom(FreedomCommand.class.getPackage());
|
|
||||||
handler.registerAll("TotalFreedomMod", true);
|
|
||||||
|
|
||||||
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
handler.clearCommands();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
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);
|
||||||
|
|
||||||
|
for (Class<? extends FreedomCommand> commandClass : commandClasses)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -12,4 +12,4 @@ public @interface CommandParameters
|
|||||||
String usage();
|
String usage();
|
||||||
|
|
||||||
String aliases() default ""; // "alias1,alias2,alias3" - no spaces
|
String aliases() default ""; // "alias1,alias2,alias3" - no spaces
|
||||||
}
|
}
|
@ -8,9 +8,11 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
|||||||
public @interface CommandPermissions
|
public @interface CommandPermissions
|
||||||
{
|
{
|
||||||
|
|
||||||
Rank level();
|
Rank level() default Rank.NON_OP;
|
||||||
|
|
||||||
SourceType source();
|
SourceType source() default SourceType.BOTH;
|
||||||
|
|
||||||
boolean blockHostConsole() default false;
|
boolean blockHostConsole() default false;
|
||||||
}
|
|
||||||
|
int cooldown() default 0;
|
||||||
|
}
|
@ -2,17 +2,13 @@ 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.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.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(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(
|
@CommandParameters(description = "Talk privately with other admins on the server.", usage = "/<command> [message]", aliases = "o,sc,ac,staffchat")
|
||||||
description = "AdminChat - Talk privately with other admins. Using <command> itself will toggle AdminChat on and off for all messages.",
|
|
||||||
usage = "/<command> [message...]",
|
|
||||||
aliases = "o,ac")
|
|
||||||
public class Command_adminchat extends FreedomCommand
|
public class Command_adminchat extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -23,19 +19,18 @@ public class Command_adminchat extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("Only in-game players can toggle AdminChat.");
|
msg("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 Admin Chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
msg("Admin chat turned " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
|
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
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.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "si,ai,staffinfo")
|
||||||
|
public class Command_admininfo extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
List<String> adminInfo = ConfigEntry.ADMIN_INFO.getStringList();
|
||||||
|
|
||||||
|
if (adminInfo.isEmpty())
|
||||||
|
{
|
||||||
|
msg("The admin information section of the config.yml file has not been configured.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg(FUtil.colorize(StringUtils.join(adminInfo, "\n")));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
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.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -7,8 +10,8 @@ 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.ONLY_CONSOLE, blockHostConsole = true)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Close server to non-superadmins.", 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
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -23,18 +26,18 @@ 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-superadmins.", true);
|
FUtil.adminAction(sender.getName(), "Closing the server to non-admins", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!isAdmin(player))
|
if (!isAdmin(player))
|
||||||
{
|
{
|
||||||
player.kickPlayer("Server is now closed to non-superadmins.");
|
player.kickPlayer("Server is now closed to non-admins.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -42,4 +45,15 @@ public class Command_adminmode extends FreedomCommand
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1 && plugin.al.isAdmin(sender) && !(sender instanceof Player))
|
||||||
|
{
|
||||||
|
return Arrays.asList("on", "off");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
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.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -10,17 +13,12 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Go to the AdminWorld.",
|
@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> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]")
|
usage = "/<command> [time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
||||||
|
aliases = "sw,aw,staffworld")
|
||||||
public class Command_adminworld extends FreedomCommand
|
public class Command_adminworld extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private enum CommandMode
|
|
||||||
{
|
|
||||||
|
|
||||||
TELEPORT, GUEST, TIME, WEATHER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@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)
|
||||||
{
|
{
|
||||||
@ -32,11 +30,7 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
}
|
}
|
||||||
else if (args.length >= 2)
|
else if (args.length >= 2)
|
||||||
{
|
{
|
||||||
if ("guest".equalsIgnoreCase(args[0]))
|
if ("time".equalsIgnoreCase(args[0]))
|
||||||
{
|
|
||||||
commandMode = CommandMode.GUEST;
|
|
||||||
}
|
|
||||||
else if ("time".equalsIgnoreCase(args[0]))
|
|
||||||
{
|
{
|
||||||
commandMode = CommandMode.TIME;
|
commandMode = CommandMode.TIME;
|
||||||
}
|
}
|
||||||
@ -59,7 +53,7 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!(sender instanceof Player) || playerSender == null)
|
if (!(sender instanceof Player) || playerSender == null)
|
||||||
{
|
{
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
World adminWorld = null;
|
World adminWorld = null;
|
||||||
@ -67,90 +61,20 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
{
|
{
|
||||||
adminWorld = plugin.wm.adminworld.getWorld();
|
adminWorld = plugin.wm.adminworld.getWorld();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adminWorld == null || playerSender.getWorld() == adminWorld)
|
if (adminWorld == null || playerSender.getWorld() == adminWorld)
|
||||||
{
|
{
|
||||||
msg("Going to the main world.");
|
msg("Going to the main world.");
|
||||||
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
PaperLib.teleportAsync(playerSender, server.getWorlds().get(0).getSpawnLocation());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.wm.adminworld.canAccessWorld(playerSender))
|
msg("Going to the AdminWorld.");
|
||||||
{
|
plugin.wm.adminworld.sendToWorld(playerSender);
|
||||||
msg("Going to the AdminWorld.");
|
|
||||||
plugin.wm.adminworld.sendToWorld(playerSender);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("You don't have permission to access the AdminWorld.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GUEST:
|
|
||||||
{
|
|
||||||
if (args.length == 2)
|
|
||||||
{
|
|
||||||
if ("list".equalsIgnoreCase(args[1]))
|
|
||||||
{
|
|
||||||
msg("AdminWorld guest list: " + plugin.wm.adminworld.guestListToString());
|
|
||||||
}
|
|
||||||
else if ("purge".equalsIgnoreCase(args[1]))
|
|
||||||
{
|
|
||||||
assertCommandPerms(sender, playerSender);
|
|
||||||
plugin.wm.adminworld.purgeGuestList();
|
|
||||||
FUtil.adminAction(sender.getName(), "AdminWorld guest list purged.", false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.length == 3)
|
|
||||||
{
|
|
||||||
assertCommandPerms(sender, playerSender);
|
|
||||||
|
|
||||||
if ("add".equalsIgnoreCase(args[1]))
|
|
||||||
{
|
|
||||||
final Player player = getPlayer(args[2]);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.wm.adminworld.addGuest(player, playerSender))
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "AdminWorld guest added: " + player.getName(), false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Could not add player to guest list.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ("remove".equals(args[1]))
|
|
||||||
{
|
|
||||||
final Player player = plugin.wm.adminworld.removeGuest(args[2]);
|
|
||||||
if (player != null)
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "AdminWorld guest removed: " + player.getName(), false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Can't find guest entry for: " + args[2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TIME:
|
case TIME:
|
||||||
@ -229,7 +153,37 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PermissionDeniedException extends Exception
|
@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 static final long serialVersionUID = 1L;
|
||||||
@ -244,5 +198,4 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
super(string);
|
super(string);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -0,0 +1,58 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Quickly change your own gamemode to adventure, define someone's username to change theirs, or change everyone's gamemode on the server.", usage = "/<command> <[partialname] | -a>", aliases = "gma")
|
||||||
|
public class Command_adventure extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
if (isConsole())
|
||||||
|
{
|
||||||
|
sender.sendMessage("When used from the console, you must define a target player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSender.setGameMode(GameMode.ADVENTURE);
|
||||||
|
msg("Your gamemode has been set to adventure.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRank(Rank.ADMIN);
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
for (Player targetPlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
||||||
|
msg("Your gamemode has been set to adventure.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Setting " + player.getName() + " to game mode adventure.");
|
||||||
|
msg(player, sender.getName() + " set your game mode to adventure.");
|
||||||
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.AreaEffectCloud;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
||||||
|
public class Command_aeclear extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Removing all area effect clouds", true);
|
||||||
|
int removed = 0;
|
||||||
|
for (World world : server.getWorlds())
|
||||||
|
{
|
||||||
|
for (Entity entity : world.getEntities())
|
||||||
|
{
|
||||||
|
if (entity instanceof AreaEffectCloud)
|
||||||
|
{
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg(removed + " area effect clouds removed.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,18 +1,18 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.apache.commons.lang3.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(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Make an announcement", 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 +22,4 @@ public class Command_announce extends FreedomCommand
|
|||||||
plugin.an.announce(StringUtils.join(args, " "));
|
plugin.an.announce(StringUtils.join(args, " "));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -0,0 +1,30 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
|
||||||
|
public class Command_attributelist extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
StringBuilder list = new StringBuilder("All possible attributes: ");
|
||||||
|
|
||||||
|
for (Attribute attribute : Attribute.values())
|
||||||
|
{
|
||||||
|
list.append(attribute.name()).append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove extra comma at the end of the list
|
||||||
|
list = new StringBuilder(list.substring(0, list.length() - 2));
|
||||||
|
|
||||||
|
msg(list.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
|
@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
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean enabled = plugin.lp.CLEAR_ON_JOIN.contains(args[0]);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
plugin.lp.CLEAR_ON_JOIN.remove(args[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " have their inventory cleared when they join.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
||||||
|
public class Command_autotp 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 enabled = plugin.lp.TELEPORT_ON_JOIN.contains(args[0]);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
plugin.lp.TELEPORT_ON_JOIN.remove(args[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " be automatically teleported when they join.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,179 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
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.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
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(level = Rank.ADMIN, 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 List<String> ips = new ArrayList<>();
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||||
|
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
username = entry.getName();
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(player);
|
||||||
|
username = player.getName();
|
||||||
|
//ips.addAll(entry.getIps());/
|
||||||
|
ips.add(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
|
||||||
|
{
|
||||||
|
msg("Banned " + player.getName() + " quietly.");
|
||||||
|
}
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
ban.addIp(ip);
|
||||||
|
ban.addIp(FUtil.getFuzzyIp(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);
|
||||||
|
}
|
||||||
|
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||||
|
FUtil.adminAction(sender.getName(), bcast.toString(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick player and handle others on IP
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
||||||
|
{
|
||||||
|
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log ban
|
||||||
|
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, reason));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, 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))
|
||||||
|
{
|
||||||
|
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.bm.getByIp(ip) != null)
|
||||||
|
{
|
||||||
|
msg("The IP " + ip + " is already banned", ChatColor.RED);
|
||||||
|
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
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (FUtil.getIp(player).equals(ip))
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
// Broadcast
|
||||||
|
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
||||||
|
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.al.isAdmin(player) ? "the IP " + ip : "an IP");
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -2,36 +2,35 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
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(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
@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 {
|
public class Command_banlist 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 (args.length > 0) {
|
{
|
||||||
if (args[0].equalsIgnoreCase("purge")) {
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
|
{
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
checkRank(Rank.SENIOR_ADMIN);
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||||
int amount = plugin.bm.purge();
|
int amount = plugin.bm.purge();
|
||||||
sender.sendMessage(ChatColor.GRAY + "Purged " + amount + " player bans.");
|
msg("Purged " + amount + " player bans.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(plugin.bm.getAllBans().size() + " player bans ("
|
msg(plugin.bm.getAllBans().size() + " player bans ("
|
||||||
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
||||||
+ plugin.bm.getIpBans().size() + " IPs)");
|
+ plugin.bm.getIpBans().size() + " IPs)");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, 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)
|
||||||
|
{
|
||||||
|
msg("The name " + name + " is already banned", ChatColor.RED);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.SplittableRandom;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
||||||
|
public class Command_bird extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
||||||
|
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
||||||
|
msg(":goodbird:");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityType getRandomFish()
|
||||||
|
{
|
||||||
|
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
||||||
|
SplittableRandom random = new SplittableRandom();
|
||||||
|
return fishTypes.get(random.nextInt(fishTypes.size()));
|
||||||
|
}
|
||||||
|
}
|
@ -8,8 +8,8 @@ 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(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Block all commands for 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
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -68,17 +68,21 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (isAdmin(player))
|
if (isAdmin(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
|
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
if (!playerdata.allCommandsBlocked())
|
||||||
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
|
{
|
||||||
|
playerdata.setCommandsBlocked(true);
|
||||||
FUtil.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||||
msg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
|
msg("Blocked commands for " + player.getName() + ".");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("That players commands are already blocked.", ChatColor.RED);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Restricts/unrestricts block modification abilities for everyone on the server or a certain player.", usage = "/<command> [[-s] <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)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("list"))
|
||||||
|
{
|
||||||
|
msg("The following have block modification abilities restricted:");
|
||||||
|
int count = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isEditBlocked())
|
||||||
|
{
|
||||||
|
msg("- " + player.getName());
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
msg("- none");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players", true);
|
||||||
|
int count = 0;
|
||||||
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isEditBlocked())
|
||||||
|
{
|
||||||
|
info.setEditBlocked(false);
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg("Unblocked all block modification abilities for " + count + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("all"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins", true);
|
||||||
|
int counter = 0;
|
||||||
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
playerdata.setEditBlocked(true);
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Blocked block modification abilities for " + counter + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean smite = args[0].equals("-s");
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
args = (String[])ArrayUtils.subarray(args, 1, args.length);
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player2 = getPlayer(args[0]);
|
||||||
|
if (player2 == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
final FPlayer pd = plugin.pl.getPlayer(player2);
|
||||||
|
if (pd.isEditBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
||||||
|
pd.setEditBlocked(false);
|
||||||
|
msg("Unblocking block modification abilities for " + player2.getName());
|
||||||
|
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player2))
|
||||||
|
{
|
||||||
|
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
||||||
|
pd.setEditBlocked(true);
|
||||||
|
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
Command_smite.smite(sender, player2, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(player2, "Your block modification abilities have been blocked.", ChatColor.RED);
|
||||||
|
msg("Blocked all block modification abilities for " + player2.getName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [[-s] <player> [reason] | 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("list"))
|
||||||
|
{
|
||||||
|
msg("PVP is blocked for players:");
|
||||||
|
int count = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isPvpBlocked())
|
||||||
|
{
|
||||||
|
msg(" - " + player.getName());
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
msg(" - none");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
|
||||||
|
int count = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isPvpBlocked())
|
||||||
|
{
|
||||||
|
info.setPvpBlocked(false);
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Enabled PVP for " + count + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("all"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
|
||||||
|
int counter = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
playerdata.setPvpBlocked(true);
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Disabling PVP for " + counter + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean smite = args[0].equals("-s");
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
args = ArrayUtils.subarray(args, 1, args.length);
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player p = getPlayer(args[0]);
|
||||||
|
if (p == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||||
|
if (pd.isPvpBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
||||||
|
pd.setPvpBlocked(false);
|
||||||
|
msg("Enabling PVP for " + p.getName());
|
||||||
|
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(p))
|
||||||
|
{
|
||||||
|
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
||||||
|
pd.setPvpBlocked(true);
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
Command_smite.smite(sender, p, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(p, "Your PVP has been disabled.", ChatColor.RED);
|
||||||
|
msg("Disabled PVP for " + p.getName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
||||||
|
public class Command_blockredstone extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking all redstone", true);
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
FUtil.adminAction("TotalFreedom", "Unblocking all redstone", false);
|
||||||
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 6000L);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
|
FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
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.rank.Rank;
|
||||||
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;
|
||||||
@ -10,101 +15,135 @@ 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(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [outermaterial] [innermaterial]>")
|
@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(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("off".equals(args[0]) && sender instanceof Player)
|
String skullName = null;
|
||||||
{
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
|
||||||
|
|
||||||
playerdata.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else 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())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
playerdata.getCageData().setCaged(false);
|
fPlayer.getCageData().setCaged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
if (fPlayer.getCageData().isCaged())
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.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)
|
|
||||||
{
|
{
|
||||||
if ("off".equals(args[1]))
|
final String s = args[1];
|
||||||
|
switch (s)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
case "head":
|
||||||
playerdata.getCageData().setCaged(false);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ("darth".equalsIgnoreCase(args[1]))
|
|
||||||
{
|
{
|
||||||
outerMaterial = Material.SKULL;
|
outerMaterial = Material.PLAYER_HEAD;
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
skullName = args[2];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outerMaterial = Material.SKELETON_SKULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (Material.matchMaterial(args[1]) != null)
|
case "block":
|
||||||
{
|
{
|
||||||
outerMaterial = Material.matchMaterial(args[1]);
|
if (Material.matchMaterial(args[2]) != null)
|
||||||
|
{
|
||||||
|
outerMaterial = Material.matchMaterial(args[2]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sender.sendMessage(ChatColor.RED + "Invalid block!");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 3)
|
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
||||||
|
|
||||||
|
if (skullName != null)
|
||||||
{
|
{
|
||||||
if (args[2].equalsIgnoreCase("water"))
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
||||||
{
|
|
||||||
innerMaterial = Material.STATIONARY_WATER;
|
|
||||||
}
|
|
||||||
else if (args[2].equalsIgnoreCase("lava"))
|
|
||||||
{
|
|
||||||
innerMaterial = Material.STATIONARY_LAVA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
|
||||||
playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
|
|
||||||
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
|
||||||
|
|
||||||
if (outerMaterial != Material.SKULL)
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
if (outerMaterial == Material.PLAYER_HEAD)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
List<String> arguments = new ArrayList<>();
|
||||||
|
arguments.add("purge");
|
||||||
|
arguments.addAll(FUtil.getPlayerList());
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
else if (args.length == 2)
|
||||||
|
{
|
||||||
|
if (!args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("head", "block");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length == 3)
|
||||||
|
{
|
||||||
|
if (args[1].equals("block"))
|
||||||
|
{
|
||||||
|
return FUtil.getAllMaterialNames();
|
||||||
|
}
|
||||||
|
else if (args[1].equals("head"))
|
||||||
|
{
|
||||||
|
return FUtil.getPlayerList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
@ -1,9 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Achievement;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -12,43 +10,39 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
|
@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
|
public class Command_cake extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
||||||
private final Random random = new Random();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
final StringBuilder output = new StringBuilder();
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
final String[] words = CAKE_LYRICS.split(" ");
|
for (final String word : CAKE_LYRICS.split(" "))
|
||||||
for (final String word : words)
|
|
||||||
{
|
{
|
||||||
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
|
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString());
|
assert heldItemMeta != null;
|
||||||
|
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
for (final Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final int firstEmpty = player.getInventory().firstEmpty();
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
if (firstEmpty >= 0)
|
if (firstEmpty >= 0)
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(firstEmpty, heldItem);
|
player.getInventory().setItem(firstEmpty, heldItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.awardAchievement(Achievement.BAKE_CAKE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.bcastMsg(output.toString());
|
FUtil.bcastMsg(output.toString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
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;
|
||||||
@ -16,9 +17,8 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Player targetPlayer = playerSender;
|
Player targetPlayer = playerSender;
|
||||||
|
|
||||||
if (args.length == 1)
|
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
|
|
||||||
targetPlayer = getPlayer(args[0]);
|
targetPlayer = getPlayer(args[0]);
|
||||||
|
|
||||||
if (targetPlayer == null)
|
if (targetPlayer == null)
|
||||||
@ -36,15 +36,10 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (targetPlayer != playerSender && !isAdmin(sender))
|
|
||||||
{
|
|
||||||
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetPlayer.isInsideVehicle())
|
if (targetPlayer.isInsideVehicle())
|
||||||
{
|
{
|
||||||
targetPlayer.getVehicle().eject();
|
Objects.requireNonNull(targetPlayer.getVehicle()).eject();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -69,14 +64,14 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
|
|
||||||
if (nearest_cart != null)
|
if (nearest_cart != null)
|
||||||
{
|
{
|
||||||
nearest_cart.setPassenger(targetPlayer);
|
nearest_cart.addPassenger(targetPlayer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage("There are no empty minecarts in the target world.");
|
msg("There are no empty minecarts in the target world.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,218 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
|
||||||
@CommandParameters(description = "No Description Yet", usage = "/<command>")
|
|
||||||
public class Command_cbtool extends FreedomCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
if (args.length < 1)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ("targetblock".equalsIgnoreCase(args[0]) && sender instanceof Player)
|
|
||||||
{
|
|
||||||
Block targetBlock = DepreciationAggregator.getTargetBlock(playerSender, null, 100);
|
|
||||||
msg("Your target block: " + targetBlock.getLocation().toString());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final StringBuffer generatedCommand = new StringBuffer();
|
|
||||||
|
|
||||||
final Matcher matcher = Pattern.compile("\\[(.+?)\\]").matcher(StringUtils.join(args, " ").trim());
|
|
||||||
while (matcher.find())
|
|
||||||
{
|
|
||||||
matcher.appendReplacement(generatedCommand, processSubCommand(matcher.group(1)));
|
|
||||||
}
|
|
||||||
matcher.appendTail(generatedCommand);
|
|
||||||
|
|
||||||
if (plugin.cb.isCommandBlocked(generatedCommand.toString(), sender, false))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
server.dispatchCommand(sender, generatedCommand.toString());
|
|
||||||
}
|
|
||||||
catch (SubCommandFailureException ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String processSubCommand(final String subcommand) throws SubCommandFailureException
|
|
||||||
{
|
|
||||||
final String[] args = StringUtils.split(subcommand, " ");
|
|
||||||
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
throw new SubCommandFailureException("Invalid subcommand name.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return SubCommand.getByName(args[0]).getExecutable().execute(ArrayUtils.remove(args, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static enum SubCommand
|
|
||||||
{
|
|
||||||
|
|
||||||
PLAYER_DETECT("playerdetect", new SubCommandExecutable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public String execute(String[] args) throws SubCommandFailureException
|
|
||||||
{
|
|
||||||
if (args.length != 5)
|
|
||||||
{
|
|
||||||
throw new SubCommandFailureException("Invalid # of arguments.");
|
|
||||||
}
|
|
||||||
|
|
||||||
double x, y, z;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
x = Double.parseDouble(args[0].trim());
|
|
||||||
y = Double.parseDouble(args[1].trim());
|
|
||||||
z = Double.parseDouble(args[2].trim());
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ex)
|
|
||||||
{
|
|
||||||
throw new SubCommandFailureException("Invalid coordinates.");
|
|
||||||
}
|
|
||||||
|
|
||||||
World world = null;
|
|
||||||
final String needleWorldName = args[3].trim();
|
|
||||||
final List<World> worlds = Bukkit.getWorlds();
|
|
||||||
for (final World testWorld : worlds)
|
|
||||||
{
|
|
||||||
if (testWorld.getName().trim().equalsIgnoreCase(needleWorldName))
|
|
||||||
{
|
|
||||||
world = testWorld;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world == null)
|
|
||||||
{
|
|
||||||
throw new SubCommandFailureException("Invalid world name.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final Location testLocation = new Location(world, x, y, z);
|
|
||||||
|
|
||||||
double radius;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
radius = Double.parseDouble(args[4].trim());
|
|
||||||
}
|
|
||||||
catch (NumberFormatException ex)
|
|
||||||
{
|
|
||||||
throw new SubCommandFailureException("Invalid radius.");
|
|
||||||
}
|
|
||||||
|
|
||||||
final double radiusSq = radius * radius;
|
|
||||||
|
|
||||||
final List<Player> worldPlayers = testLocation.getWorld().getPlayers();
|
|
||||||
for (final Player testPlayer : worldPlayers)
|
|
||||||
{
|
|
||||||
if (testPlayer.getLocation().distanceSquared(testLocation) < radiusSq)
|
|
||||||
{
|
|
||||||
return testPlayer.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
throw new SubCommandFailureException("No player found in range.");
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
PLAYER_DETECT_BOOLEAN("playerdetectboolean", new SubCommandExecutable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public String execute(String[] args) throws SubCommandFailureException
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
PLAYER_DETECT.getExecutable().execute(args);
|
|
||||||
}
|
|
||||||
catch (SubCommandFailureException ex)
|
|
||||||
{
|
|
||||||
return "0";
|
|
||||||
}
|
|
||||||
|
|
||||||
return "1";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//
|
|
||||||
private final String name;
|
|
||||||
private final SubCommandExecutable executable;
|
|
||||||
|
|
||||||
private SubCommand(String subCommandName, SubCommandExecutable subCommandImpl)
|
|
||||||
{
|
|
||||||
this.name = subCommandName;
|
|
||||||
this.executable = subCommandImpl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubCommandExecutable getExecutable()
|
|
||||||
{
|
|
||||||
return executable;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SubCommand getByName(String needle) throws SubCommandFailureException
|
|
||||||
{
|
|
||||||
needle = needle.trim();
|
|
||||||
for (SubCommand subCommand : values())
|
|
||||||
{
|
|
||||||
if (subCommand.getName().equalsIgnoreCase(needle))
|
|
||||||
{
|
|
||||||
return subCommand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new SubCommandFailureException("Invalid subcommand name.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private interface SubCommandExecutable
|
|
||||||
{
|
|
||||||
|
|
||||||
public String execute(String[] args) throws SubCommandFailureException;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class SubCommandFailureException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
public SubCommandFailureException()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public SubCommandFailureException(String message)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,30 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
||||||
|
public class Command_clearchat extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 100; i++)
|
||||||
|
{
|
||||||
|
player.sendMessage("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
|
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
|
||||||
|
public class Command_cleardiscordqueue extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
plugin.dc.clearQueue();
|
||||||
|
msg("Cleared the discord message queue.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Clear your inventory.", usage = "/<command> [player]", aliases = "ci,clear")
|
||||||
|
public class Command_clearinventory extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSender.getInventory().clear();
|
||||||
|
msg("Your inventory has been cleared.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
player.getInventory().clear();
|
||||||
|
}
|
||||||
|
msg("Sucessfully cleared everyone's inventory.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear();
|
||||||
|
msg("Cleared " + player.getName() + "'s inventory.");
|
||||||
|
player.sendMessage(sender.getName() + " has cleared your inventory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
List<String> players = FUtil.getPlayerList();
|
||||||
|
players.add("-a");
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user