mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 12:36:41 +00:00
Compare commits
1389 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
e8e0e9988a | |||
1a16f06ac6 | |||
aca3398d21 | |||
924f718d5a | |||
6edb6be7d9 | |||
055973aa37 | |||
19ced05110 | |||
e93ac11172 | |||
7328d20c84 | |||
4586b7519f | |||
a0058869c9 | |||
89a317b7df | |||
0c3bc40b03 | |||
848f103afa | |||
a7a2db15d6 | |||
6aeb56de07 | |||
400038265b | |||
3b87323c41 | |||
cdf2dc6760 | |||
bf1d779b95 | |||
27004da544 | |||
c0c4c25875 | |||
adbaf9341d | |||
b5c5e60c12 | |||
1ed1b352f3 | |||
53c898fd76 | |||
acc8f3e2b8 | |||
157eeef867 | |||
21c0833f14 | |||
c002fbc537 | |||
a4d8f4646e | |||
f2dc46d4ef | |||
901a327b1e | |||
580ba0a357 | |||
abf52870dd | |||
d48bfde128 | |||
7ac7b75ae6 | |||
b66614cad9 | |||
ff70f13e05 | |||
ea110c01dd | |||
632f3647a8 | |||
80287433eb | |||
b18aeb2d38 | |||
68f972c562 | |||
994056047a | |||
f115315341 | |||
57e5395143 | |||
17f3a4ca3d | |||
e2d0e9e754 | |||
b167540ad7 | |||
0d1ce072dc | |||
887a5c6b16 | |||
ea6bfa8387 | |||
42266c37ea | |||
2dd8e00201 | |||
46cd88a18a | |||
2ff0f6f5d6 | |||
9ff6325469 | |||
ea404985fd | |||
8fc25111e2 | |||
4fce1109a1 | |||
916fd75003 | |||
aa35aae58f | |||
6849fb2784 | |||
313577d083 | |||
53efcfd06b | |||
edaaeef65f | |||
d6eb5bdcda | |||
7d675923db | |||
87fd8a165c | |||
1205252450 | |||
1ed45b1a20 | |||
822f55d9f2 | |||
aacf37aa56 | |||
a15e39d7dd | |||
72fa8532d3 | |||
f4aa0c324c | |||
73ee1f3624 | |||
4ca3593653 | |||
af52dec24a | |||
34ebb3586c | |||
eee8682959 | |||
af1dd2e9ff | |||
ade60ad611 | |||
e699ad1663 | |||
e2308ee904 | |||
d14a595ac4 | |||
5190af0a6b | |||
a11b87ec83 | |||
c7a0604afc | |||
9970277134 | |||
49f6879ccb | |||
794b76321a | |||
e5b4ae0e3e | |||
310ce4f75a | |||
cf072dc0d5 | |||
7fe0b562ee | |||
6f6fdb28bf | |||
524d4da9d8 | |||
0aa0bae0ad | |||
fcf52ba02a | |||
8a92ff132b | |||
99043a7c49 | |||
2a71be4050 | |||
b43ef812a2 | |||
7981adaf85 | |||
1bc22a817a | |||
57a6b35457 | |||
8b45482d0a | |||
af64a77268 | |||
5c50069f21 | |||
3c329667a4 | |||
1565c9643d | |||
84ef49bf65 | |||
878075c898 | |||
c74763c96a | |||
d01f9d0b2f | |||
e780c4ffec | |||
3968dbe0a2 | |||
ff9164714c | |||
72e105eb34 | |||
f4440fd262 | |||
587b84a489 | |||
107952f0ba | |||
8cae042857 | |||
d1b73592af | |||
b7175d73ab | |||
9c976b381b | |||
0c99862793 | |||
0240b65fad | |||
b6d3e5baca | |||
15650b84cf | |||
9233bcfedc | |||
b0aa4a850d | |||
af97481d11 | |||
3c6e706c98 | |||
aca62caec1 | |||
eaa23985bd | |||
e3f9452b9f | |||
755080d0a4 | |||
0f764b976b | |||
d0a435a5d6 | |||
b02764ddca | |||
b3c28d33f2 | |||
6ad1187eef | |||
1bf1267b49 | |||
d2f6f7f51a | |||
dc2c996516 | |||
f502e44764 | |||
c490a3d62e | |||
9a2dc52e87 | |||
a1c11f4e0f | |||
48fd4c590d | |||
97cde0cfd4 | |||
429269d8d2 | |||
1a50c16d9a | |||
891d8d178f | |||
fc1c487dce | |||
e2cc14370a | |||
d5d6f18fb4 | |||
00e22dc56e | |||
40b475ea0c | |||
65eabbdba4 | |||
cb4a47d812 | |||
ecbd70493b | |||
4988140268 | |||
57b0aadb9b | |||
ef9ce2a9a7 | |||
2c92b0874e | |||
927560ad75 | |||
c8dbc8a623 | |||
11eef83a65 | |||
a2439a7093 | |||
d8697590a7 | |||
6d98604cf0 | |||
3d6be1cd51 | |||
01edfed307 | |||
5e4d1d0d6d | |||
86f61f1487 | |||
461cfa7bdc | |||
75b296496e | |||
183277db21 | |||
2b597867f0 | |||
7f7312c0a2 | |||
73214165a5 | |||
54be4f7e88 | |||
3ccab5f534 | |||
f635af5f95 | |||
cc3a183cac | |||
173b686658 | |||
a0d5743232 | |||
7598d211cd | |||
6b064d0e68 | |||
8fc0673bb2 | |||
aa062a9d11 | |||
8b4b2f97e0 | |||
c4f1d0c06f | |||
20d4e886fc | |||
e36ace1671 | |||
2f055fbecb | |||
d193686c79 | |||
ba2ada569f | |||
850fd9aa4a | |||
1fb14ca1dd | |||
499472a126 | |||
28459e4702 | |||
57dda8367c | |||
cdf03b4353 | |||
5ec66e8c7e | |||
f57aeb8fb0 | |||
adb3834836 | |||
d82d6fd704 | |||
ec0683f610 | |||
2d118a44a9 | |||
64cd7f7393 | |||
9a1fc8ea36 | |||
75247af337 | |||
d20b062b70 | |||
4b36574255 | |||
bba42797d8 | |||
365e38e63a | |||
5a3106ace8 | |||
8cb4ef111c | |||
50d6cf471c | |||
e942f0bf75 | |||
f8231aeb3f | |||
eddbcf515c | |||
00ac914066 | |||
179fe9d665 | |||
67c86aea24 | |||
e4bb1ef6aa | |||
16b02e3dec | |||
70e248202b | |||
51ef752259 | |||
b3e40462e2 | |||
73a91c02c6 | |||
7b8ba0bdf5 | |||
bd9d6114ba | |||
0435174342 | |||
796ef3d359 | |||
a3f3903760 | |||
5c99aa9a44 | |||
8292eb20ae | |||
d9e0791a3b | |||
dbfec1e86d | |||
31e03d6348 | |||
46494a2c87 | |||
b11eb0f762 | |||
730b0e2c83 | |||
60a9de7e7c | |||
8a4fa946fd | |||
9bc0859fdf | |||
742450d016 | |||
ad06bea3ae | |||
68d83fa397 | |||
fe84c3a2a0 | |||
6e5e70ac90 | |||
489549a0ea | |||
56b55eb3e2 | |||
4ef5f59fb9 | |||
d31ad2e9fc | |||
8a9dfca6d3 | |||
55ddf5a30a | |||
59e890c654 | |||
b0e62add9f | |||
7cdf1abcf2 | |||
ee0ebd85fc | |||
518537413b | |||
802d02d653 | |||
f3cb57c9cd | |||
c7c2795f41 | |||
20b117a703 | |||
8522570db5 | |||
08e4a4a171 | |||
a0affddeed | |||
c82113dc22 | |||
9315227906 | |||
00e9b4ea1f | |||
22b0781020 | |||
7df24c6b86 | |||
0e9044ffc3 | |||
3371f54c06 | |||
5e4649a4d0 | |||
d8560ebc1f | |||
7f2e72ee51 | |||
c98909df12 | |||
d613e0266b | |||
92d7c58957 | |||
478244773b | |||
5237fa0ca2 | |||
b3b182e753 | |||
a54c113a86 | |||
ec8a528564 | |||
6365672eda | |||
d087dc1148 | |||
a3a484dc58 | |||
b89ccb2d55 | |||
9b66304f63 | |||
4784348027 | |||
2705bb4534 | |||
0f6f21e4c6 | |||
527ac6c286 | |||
192b9ea9d9 | |||
fa1a082972 | |||
cf135e211d | |||
56a5a7304a | |||
4b671cc4c7 | |||
10443ff0d5 | |||
5f1f9184ae | |||
a1bb6a34a0 | |||
dfd5f2dba0 | |||
988e62213e | |||
49601035a5 | |||
d05f8b7169 | |||
fbca5f0527 | |||
1c14889bdf | |||
114372194a | |||
49b841acc2 | |||
302b538a3a | |||
539f28549a | |||
716ba57739 | |||
0d32ca5451 | |||
b8b8ed8608 | |||
ca5b79331b | |||
78c1a2eaaf | |||
be4ec7fc04 | |||
794ad2e57a | |||
d2a5c399f0 | |||
67d8bfce09 | |||
90aa3ab420 | |||
a395904c43 | |||
42812be4c5 | |||
049432789f | |||
8b2532e9e9 | |||
e5902fc5e8 | |||
71862d6e41 | |||
7dffea0ba2 | |||
67c09546f7 | |||
8b51fd215f | |||
275204fb2e | |||
1330d2b3af | |||
4204210f66 | |||
8297d03a86 | |||
75353ae4b1 | |||
a28959db0e | |||
b2e27ec8bf | |||
c42bc23bfe | |||
e29d4673dd | |||
2ce7e518fb | |||
9ba316464e | |||
60f71c9dfc | |||
3e71286507 | |||
6d48c90d16 | |||
d7ed667b89 | |||
9c61cc2768 | |||
4daad76e74 | |||
05884ae806 | |||
aa0fd34859 | |||
2c14773c9b | |||
695168ebfe | |||
bbc1255963 | |||
34d15d4c96 | |||
75bc17cd8f | |||
87f338194c | |||
b5760afbad | |||
5cfaf8970d | |||
9a48ec04aa | |||
24fca9af97 | |||
a9ef738602 | |||
27a04635a2 | |||
0f58746525 | |||
a8d4b5f582 | |||
d7f1de4cb7 | |||
ddbb6228f1 | |||
d4c3a4ad45 | |||
7140e4c8df | |||
808e02f660 | |||
bed78248fb | |||
ee39e89093 | |||
9405604efc | |||
73acb2448b | |||
c63540129f | |||
6ba96b427d | |||
acd8373f81 | |||
0c4c36b2bd | |||
7ce052900e | |||
f8741b0d4f | |||
6fca19fa41 | |||
7e75287e61 | |||
52641466ff | |||
67f096fbfa | |||
8f24e44c79 | |||
28b9f3089d | |||
6b906864b3 | |||
c2aba0e798 | |||
c78e6483ac | |||
1ef6fcbb70 | |||
ce5d23a5bc | |||
280ddf61f7 | |||
a821f7b606 | |||
1a5f854552 | |||
a38f7b3469 | |||
13eeccbc40 | |||
2b611a2bee | |||
ed0aef033c | |||
2d655e4009 | |||
81995f38a1 | |||
9f889efa76 | |||
1e79b90249 | |||
70a24486b8 | |||
d863a9e274 | |||
902fc0ba11 | |||
415d25da4b | |||
3583c1dbdc | |||
f49c4568b2 | |||
01807d1f0f | |||
c5ddc60b97 | |||
97b27cd7b4 | |||
faeaa3aab7 | |||
e10ab45bda | |||
7b59350833 | |||
adbc658cc7 | |||
927e46a431 | |||
65ba053aee | |||
81ee5f04dd | |||
ded31e4640 | |||
1416429910 | |||
8cdff6a3c1 | |||
8ba477140b | |||
5606fdae1f | |||
4bcd0eb61f | |||
18e4943216 | |||
549c5231e8 | |||
7144894848 | |||
fef5f7604b | |||
2d421178db | |||
650bd11ab0 | |||
05ad222148 | |||
4cde6a53ba | |||
18ed009ddd | |||
b7efe3983d | |||
eb01c0db86 | |||
562e354f37 | |||
b845ff3f7e | |||
3c9245bfaf | |||
4bef1a06a4 | |||
e70f8ffff3 | |||
896af4198a | |||
d1ffbe0412 | |||
8f70fa2c82 | |||
a89948f76d | |||
41cca7cd6a | |||
0067e2cc65 | |||
2168aa957a | |||
3babf8388c | |||
0b0e17e526 | |||
5247a33f88 | |||
3f2aa224f6 | |||
bc00e42990 | |||
88103cefc2 | |||
3819c57adf | |||
c3f8bd33ff | |||
baf7a3b2c1 | |||
74bfdad389 | |||
08a9329864 | |||
be87075337 | |||
ada803cd7d | |||
0b146943ff | |||
0f31ea2953 | |||
3ca46853ac | |||
ee6b93e208 | |||
3e5e11197f | |||
6035f9e50b | |||
f45cc11846 | |||
b28a0778b4 | |||
174043fa58 | |||
dfb6df63c8 | |||
7a6cc55640 | |||
5c61ff27b0 | |||
3da03393e6 | |||
5876f86ac3 | |||
fbdf2b5fc2 | |||
fd6aa7b94b | |||
5981f7f33f | |||
55d94b5d59 | |||
d71b043102 | |||
143b323854 | |||
1f32455e06 | |||
8718b3a8c2 | |||
f5e21f69fd | |||
bf7877addc | |||
6d0b8362b7 | |||
10f905ea36 | |||
dcb6a4513e | |||
ff4751941b | |||
e64fd42855 | |||
467d1d2d3a | |||
6ba8dcaa58 | |||
a3cf53f5b1 | |||
23907ef7e4 | |||
485945047b | |||
75ec2330f5 | |||
5c32c66390 | |||
4494a4c039 | |||
f53b67abf1 | |||
2827ca98a7 | |||
64b1e568b3 | |||
3e57696a21 | |||
fd1bd995ed | |||
9fe05add7f | |||
25fbb0c05a | |||
f646a5122a | |||
af4071c582 | |||
86ee0e96d2 | |||
57efdd2269 | |||
26bcd3ec1c | |||
fd372066eb | |||
122bef2d5a | |||
339518f4f4 | |||
8ce0defb52 | |||
ec6e8431e3 | |||
0964871e8b | |||
422a7716f3 | |||
f1ab8296e4 | |||
f9cbf11abb | |||
b0090a5412 | |||
b94efb525f | |||
5c8f98089e | |||
7879fa24e4 | |||
6fcaed6253 | |||
656dbf8867 | |||
23032e6f9a | |||
ad5a236bc2 | |||
e23db244a5 | |||
eb4622fc28 | |||
0f6b053727 | |||
259335958a | |||
31375b82c3 | |||
0a2d5c8258 | |||
bac25258b0 | |||
c69918d725 | |||
c1d0c01524 | |||
a59e6added | |||
56493adcae | |||
4b91de7414 | |||
c636ee043a | |||
6a5306dd7a | |||
4603dc5613 | |||
af7e6c5d41 | |||
699d366efb | |||
41ed416a51 | |||
074630f720 | |||
4e3c9a6b9e | |||
bea480c1f1 | |||
69fd3566af | |||
f3ac19a616 | |||
696ec119c6 | |||
326c3f6a2b | |||
38b1035020 | |||
1ae6eb8a5a | |||
2c4eca8551 | |||
f23c61d0b3 | |||
c10e0deb8b | |||
d4dfe06ec0 | |||
bcd9658b3d | |||
9b62731e94 | |||
03553b6254 | |||
d40c143afc | |||
95afb51321 | |||
4813b8ae27 | |||
e8d36b31f7 | |||
b2eec1ef01 | |||
3bcc4fd7a7 | |||
e0efb63123 | |||
028d1a07b2 | |||
5b34facdd3 | |||
218fd21774 | |||
0901c02c7e | |||
a4e9bc76a3 | |||
be8314cf63 | |||
f21c7aa5c5 | |||
3f61e05609 | |||
fe93d1ce07 | |||
5132bb6550 | |||
6b7a5d8d70 | |||
6a4a11a2f4 | |||
cbe7cdc474 | |||
07f4bf82ea | |||
8e7c9dcd8e | |||
1ab74dae05 | |||
8ac91f7097 | |||
c482349f47 | |||
b24f1d9247 | |||
2079e0ea66 | |||
0e477f8437 | |||
c3fc085adc | |||
aad8f17455 | |||
d43fa35e52 | |||
fdfa30b349 | |||
e56c273457 | |||
f3087f0dca | |||
dbed7b7f83 | |||
4caa984cef | |||
ef2e17c33f | |||
53614d174e | |||
123884329c | |||
37e78dceec | |||
8f6d71fffb | |||
3935bcf09f | |||
b9bd046105 | |||
1fcda4a8fc | |||
f8e62a9893 | |||
aaf96d00a9 | |||
4903f009b3 | |||
3dc51715c5 | |||
f2aaba17de | |||
fa1c9a255c | |||
3c80aaa7c4 | |||
279f69e3de | |||
22bf0c2f62 | |||
f21e50e002 | |||
6d9e9406ec | |||
cd16c7fb10 | |||
11c945c504 | |||
c70e3ad8fd | |||
f63805cca2 | |||
5868540cbb | |||
8ca518528f | |||
4cbbf10871 | |||
93914370a1 | |||
ee87d1147d | |||
44f72815e1 | |||
391e417882 | |||
0dca359e4c | |||
15fbd0e1f3 | |||
1d9e6ae931 | |||
a0cf0e9352 | |||
797de66e10 | |||
d40d5b461d | |||
8751e0454c | |||
3f29f788d5 | |||
5c2e67ae1d | |||
61db5de20d | |||
ed9204c735 | |||
9fc237390e | |||
ba22aedc58 | |||
44fb26b27f | |||
fab341608b |
17
.github/workflows/maven.yml
vendored
Normal file
17
.github/workflows/maven.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: Java CI
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Set up JDK 1.8
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B package --file pom.xml
|
36
.gitignore
vendored
36
.gitignore
vendored
@ -1,14 +1,34 @@
|
|||||||
# Netbeans excludes - StevenLawson & JeromSar
|
# TFM excludes
|
||||||
/nbproject/private/
|
build.properties
|
||||||
/dist/
|
dependency-reduced-pom.xml
|
||||||
/build/
|
|
||||||
manifest.mf
|
|
||||||
|
|
||||||
# Eclipse excludes - JeromSar (old)
|
# Netbeans excludes
|
||||||
|
/nbproject/private
|
||||||
|
/dist
|
||||||
|
/build
|
||||||
|
manifest.mf
|
||||||
|
# Now defines that Maven CheckStyle is used
|
||||||
|
# nb-configuration.xml
|
||||||
|
|
||||||
|
# Eclipse excludes
|
||||||
.project
|
.project
|
||||||
.classpath
|
.classpath
|
||||||
/bin/
|
/bin
|
||||||
/.settings/
|
/.settings
|
||||||
|
|
||||||
|
# IntelliJ excludes
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
/.idea/modules.xml
|
||||||
|
/.idea/discord.xml
|
||||||
|
/.idea/jarRepositories.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/uiDesigner.xml
|
||||||
|
/.idea/libraries
|
||||||
|
*.iml
|
||||||
|
|
||||||
|
# Maven excludes
|
||||||
|
/target
|
||||||
|
|
||||||
# OS generated files
|
# OS generated files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
28
.idea/codeStyles/Project.xml
generated
Normal file
28
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<JavaCodeStyleSettings>
|
||||||
|
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
||||||
|
<option name="IMPORT_LAYOUT_TABLE">
|
||||||
|
<value>
|
||||||
|
<package name="" withSubpackages="true" static="false" />
|
||||||
|
<package name="" withSubpackages="true" static="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</JavaCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="BRACE_STYLE" value="2" />
|
||||||
|
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||||
|
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||||
|
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
||||||
|
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
||||||
|
<option name="IF_BRACE_FORCE" value="3" />
|
||||||
|
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
17
.idea/compiler.xml
generated
Normal file
17
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="true" />
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="TotalFreedomMod" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="TotalFreedomMod" target="1.8" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/encodings.xml
generated
Normal file
8
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
16
.idea/misc.xml
generated
Normal file
16
.idea/misc.xml
generated
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<list size="1">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||||
|
</list>
|
||||||
|
</component>
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
1
.travis.yml
Normal file
1
.travis.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
language: java
|
@ -1,65 +1,3 @@
|
|||||||
# How to contribute
|
# Contributing to TotalFreedomMod #
|
||||||
|
|
||||||
TotalFreedomMod aims to be a fully functional all-op server mod which works in
|
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).
|
||||||
a large range of configurations. In order to be as flexible as possible on the
|
|
||||||
server-end, we encourage contributing to TotalFreedomMod by making 'pull-requests'
|
|
||||||
to this repository.
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
|
||||||
* If the issue is a bug, submit a ticket for it, assuming one does not already exist.
|
|
||||||
* Clearly describe the issue including steps to reproduce it.
|
|
||||||
* Make sure you fill in the earliest version that you know has the issue.
|
|
||||||
* Fork the repository on GitHub
|
|
||||||
|
|
||||||
## Making Changes
|
|
||||||
|
|
||||||
* Create a topic branch from where you want to base your work.
|
|
||||||
* This is usually the master branch.
|
|
||||||
* Only target release branches if you are certain your addition must be on that
|
|
||||||
branch.
|
|
||||||
* To quickly create a topic branch based on master; `git checkout -b contribution`
|
|
||||||
Please avoid working directly on the `master` branch.
|
|
||||||
* Make changes and commit where necessary.
|
|
||||||
* Check for unnecessary whitespace with `git diff --check` before committing.
|
|
||||||
* Make sure your commit messages are in line with those which are already made.
|
|
||||||
* Make sure your changes build (*and work!*).
|
|
||||||
|
|
||||||
## Tips on getting your pull request accepted
|
|
||||||
* Make sure your changes work and compile without difficulty.
|
|
||||||
* Make sure your change adds something useful, do not add commands to micromanage
|
|
||||||
the server. (ie: Shorthands for a collection of commands)
|
|
||||||
* Features must be in line the general idea of "Total Freedom".
|
|
||||||
* Changes must be directed towards the main "TotalFreedom" server. Adding names such
|
|
||||||
as the name of your own TotalFreedom-like server will get your pull request denied.
|
|
||||||
* Do not add yourself to the developer list.
|
|
||||||
* Ensure that you use the correct whitespace-style. That is: 4 spaces as indentation.
|
|
||||||
* Please make sure your changes are written such as other features would be. Eg: commands
|
|
||||||
have their own class and extend TFM_Command.
|
|
||||||
* Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style).
|
|
||||||
* Do not increment the version number.
|
|
||||||
* If you want to add multiple changes, please make one pull request per change. This
|
|
||||||
way, it's easier to accept your changes faster and won't block the other changes if there
|
|
||||||
is an issue with a specific line of code.
|
|
||||||
* Please make sure there are no bugs in your code.
|
|
||||||
* Please avoid having to add files in the main namespace where possible.
|
|
||||||
* Make sure all changes work before you commit these, this avoids having multiple
|
|
||||||
unnecessary commits.
|
|
||||||
* Please refrain from using an excessive amount of commits. As few as possible is generally the best.
|
|
||||||
* Please do not spread your addition over several pull-requests.
|
|
||||||
|
|
||||||
## Submitting Changes
|
|
||||||
|
|
||||||
* Push your changes to a topic branch in your fork of the repository.
|
|
||||||
* Submit a pull request to this repository.
|
|
||||||
* Explain in detail what each one of your commits changes and point out any big changes.
|
|
||||||
* Wait as a developer evaluates your changes.
|
|
||||||
|
|
||||||
# Additional Resources
|
|
||||||
|
|
||||||
* [TotalFreedom information](http://totalfreedom.me)
|
|
||||||
* [TotalFreedom forums](http://totalfreedom.boards.net)
|
|
||||||
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)
|
|
||||||
* [General GitHub documentation](http://help.github.com/)
|
|
||||||
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
|
12
Jenkinsfile
vendored
Normal file
12
Jenkinsfile
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
mvn -B package --file pom.xml
|
||||||
|
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
LICENCE.md
16
LICENCE.md
@ -1,16 +0,0 @@
|
|||||||
# Legal
|
|
||||||
|
|
||||||
TotalFreedomMod by Madgeek1450 and DarthSalamon is an effort to create an opensource plugin to effectively run a "Total Freedom" like all-Op server. 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 server "TotalFreedom" (http://totalfreedom.me) TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feel of openness towards the administrators and the players themselves.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
TotalFreedomMod sourcecode is freely available under the GNU GPLv3 License with a few restrictions in place. The license is available here: http://www.gnu.org/licenses/gpl.txt
|
|
||||||
|
|
||||||
The few restrictions are in place to make sure that credit is given to the original authors who remain the maintainers of the plugin and it's sourcecode.
|
|
||||||
|
|
||||||
These are the restrictions under which the sourcecode is licensed:
|
|
||||||
* A un-edited copy of this license must always be included with this sourcecode.
|
|
||||||
* TotalFreedomMod sourcecode and its derrivations are freely distributable between anyone who choses to download it.
|
|
||||||
* You may not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" and "jeromsar" from any part of the sourcecode.
|
|
||||||
* However, compiled binaries (*.jar's) are not to be distributed. If you wish to obtain a copy of TotalFreedomMod you must compile the original sourcecode or it's derivations yourself using an IDE like netbeans. Official superadmins and above of the TotalFreedom (totalfreedom.me) server may obtain a compiled libary with the same limitations as described in this document.
|
|
||||||
* Any conditions on this license may be waived by any of the official developers.
|
|
54
LICENSE.md
Normal file
54
LICENSE.md
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
# TotalFreedom General License #
|
||||||
|
_Version 2.0, 27th February 2015_
|
||||||
|
|
||||||
|
Copyright (c) 2011 Steven Lawson
|
||||||
|
|
||||||
|
Copyright (c) 2012 Jerom van der Sar
|
||||||
|
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
##### 1. Definitions #####
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You", "Your" or "Yourself" shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, binary data, generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" and "This Software" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another.
|
||||||
|
|
||||||
|
##### 2. Grant of Copyright License #####
|
||||||
|
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor.
|
||||||
|
|
||||||
|
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
|
||||||
|
|
||||||
|
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
|
||||||
|
|
||||||
|
4. Accreditations referencing This Software's copyright holders or contributors may neither be altered or removed from source code nor withheld from reproduction in Object form whatsoever.
|
||||||
|
|
||||||
|
5. Any conditions specified by this license may be temporarily or permanently waived by any the aforementioned copyright holders.
|
||||||
|
|
||||||
|
6. Redistributions of This Software must retain this License document in its exact form.
|
||||||
|
|
||||||
|
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
|
||||||
|
|
||||||
|
##### 3. Submission of Contributions #####
|
||||||
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
##### 4. Disclaimer of Warranty #####
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
16
README.md
16
README.md
@ -1,6 +1,14 @@
|
|||||||
TotalFreedomMod
|
# TotalFreedomMod [](https://travis-ci.org/TFPatches/TotalFreedomMod) [](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
||||||
===============
|
|
||||||
|
|
||||||
TotalFreedomMod is a CraftBukkit mod for the TotalFreedom server.
|
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.
|
||||||
|
|
||||||
Information about the TotalFreedom server can be found at http://totalfreedom.me/
|
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
||||||
|
|
||||||
|
### Contributing ###
|
||||||
|
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).
|
||||||
|
|
||||||
|
### 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.
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
#Sun, 23 Jun 2013 15:16:34 +0200
|
|
||||||
|
|
||||||
program.VERSION=2.19
|
|
||||||
program.BUILDNUM=221
|
|
||||||
program.BUILDDATE=06/23/2013 03\:16 PM
|
|
83
build.xml
83
build.xml
@ -1,83 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!-- You may freely edit this file. See commented blocks below for -->
|
|
||||||
<!-- some examples of how to customize the build. -->
|
|
||||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
|
||||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
|
||||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
|
||||||
<!-- the Compile on Save feature is turned off for the project. -->
|
|
||||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
|
||||||
<!-- in the project's Project Properties dialog box.-->
|
|
||||||
<project name="TotalFreedomMod" default="default" basedir=".">
|
|
||||||
<description>Builds, tests, and runs the project TotalFreedomMod.</description>
|
|
||||||
<import file="nbproject/build-impl.xml"/>
|
|
||||||
<!--
|
|
||||||
|
|
||||||
There exist several targets which are by default empty and which can be
|
|
||||||
used for execution of your tasks. These targets are usually executed
|
|
||||||
before and after some main targets. They are:
|
|
||||||
|
|
||||||
-pre-init: called before initialization of project properties
|
|
||||||
-post-init: called after initialization of project properties
|
|
||||||
-pre-compile: called before javac compilation
|
|
||||||
-post-compile: called after javac compilation
|
|
||||||
-pre-compile-single: called before javac compilation of single file
|
|
||||||
-post-compile-single: called after javac compilation of single file
|
|
||||||
-pre-compile-test: called before javac compilation of JUnit tests
|
|
||||||
-post-compile-test: called after javac compilation of JUnit tests
|
|
||||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
|
||||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
|
||||||
-pre-jar: called before JAR building
|
|
||||||
-post-jar: called after JAR building
|
|
||||||
-post-clean: called after cleaning build products
|
|
||||||
|
|
||||||
(Targets beginning with '-' are not intended to be called on their own.)
|
|
||||||
|
|
||||||
Example of inserting an obfuscator after compilation could look like this:
|
|
||||||
|
|
||||||
<target name="-post-compile">
|
|
||||||
<obfuscate>
|
|
||||||
<fileset dir="${build.classes.dir}"/>
|
|
||||||
</obfuscate>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
For list of available properties check the imported
|
|
||||||
nbproject/build-impl.xml file.
|
|
||||||
|
|
||||||
|
|
||||||
Another way to customize the build is by overriding existing main targets.
|
|
||||||
The targets of interest are:
|
|
||||||
|
|
||||||
-init-macrodef-javac: defines macro for javac compilation
|
|
||||||
-init-macrodef-junit: defines macro for junit execution
|
|
||||||
-init-macrodef-debug: defines macro for class debugging
|
|
||||||
-init-macrodef-java: defines macro for class execution
|
|
||||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
|
||||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
|
||||||
run: execution of project
|
|
||||||
-javadoc-build: Javadoc generation
|
|
||||||
test-report: JUnit report generation
|
|
||||||
|
|
||||||
An example of overriding the target for project execution could look like this:
|
|
||||||
|
|
||||||
<target name="run" depends="TotalFreedomMod-impl.jar">
|
|
||||||
<exec dir="bin" executable="launcher.exe">
|
|
||||||
<arg file="${dist.jar}"/>
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
Notice that the overridden target depends on the jar target and not only on
|
|
||||||
the compile target as the regular run target does. Again, for a list of available
|
|
||||||
properties which you can use, check the target you are overriding in the
|
|
||||||
nbproject/build-impl.xml file.
|
|
||||||
|
|
||||||
-->
|
|
||||||
<target name="-pre-jar">
|
|
||||||
<buildnumber file="buildnumber.properties" />
|
|
||||||
<propertyfile file="appinfo.properties">
|
|
||||||
<entry key="program.VERSION" default="0.0" />
|
|
||||||
<entry key="program.BUILDNUM" value="${build.number}" />
|
|
||||||
<entry key="program.BUILDDATE" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
|
|
||||||
</propertyfile>
|
|
||||||
<copy file="appinfo.properties" todir="${build.classes.dir}" />
|
|
||||||
</target>
|
|
||||||
</project>
|
|
@ -1,3 +0,0 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
|
||||||
#Sun Jun 23 15:16:34 CEST 2013
|
|
||||||
build.number=222
|
|
136
checkstyle.xml
Normal file
136
checkstyle.xml
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||||
|
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
<property name="charset" value="UTF-8"/>
|
||||||
|
<property name="severity" value="warning"/>
|
||||||
|
<property name="fileExtensions" value="java, properties, xml"/>
|
||||||
|
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="supressions.xml"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="FileTabCharacter">
|
||||||
|
<property name="eachLine" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<module name="OuterTypeFilename"/>
|
||||||
|
<module name="IllegalTokenText">
|
||||||
|
<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="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||||
|
</module>
|
||||||
|
<module name="LineLength">
|
||||||
|
<property name="max" value="200"/>
|
||||||
|
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||||
|
</module>
|
||||||
|
<module name="AvoidStarImport"/>
|
||||||
|
<module name="OneTopLevelClass"/>
|
||||||
|
<module name="NoLineWrap"/>
|
||||||
|
<module name="NeedBraces"/>
|
||||||
|
<module name="LeftCurly">
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
</module>
|
||||||
|
<module name="RightCurly">
|
||||||
|
<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"/>
|
||||||
|
</module>
|
||||||
|
<module name="WhitespaceAround">
|
||||||
|
<property name="allowEmptyConstructors" value="true"/>
|
||||||
|
<property name="allowEmptyMethods" value="true"/>
|
||||||
|
<property name="allowEmptyTypes" value="true"/>
|
||||||
|
<property name="allowEmptyLoops" value="true"/>
|
||||||
|
<message key="ws.notFollowed"
|
||||||
|
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||||
|
<message key="ws.notPreceded"
|
||||||
|
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||||
|
</module>
|
||||||
|
<module name="OneStatementPerLine"/>
|
||||||
|
<module name="ArrayTypeStyle"/>
|
||||||
|
<module name="FallThrough"/>
|
||||||
|
<module name="UpperEll"/>
|
||||||
|
<module name="ModifierOrder"/>
|
||||||
|
<module name="SeparatorWrap">
|
||||||
|
<property name="tokens" value="DOT"/>
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
</module>
|
||||||
|
<module name="SeparatorWrap">
|
||||||
|
<property name="tokens" value="COMMA"/>
|
||||||
|
<property name="option" value="EOL"/>
|
||||||
|
</module>
|
||||||
|
<module name="PackageName">
|
||||||
|
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="TypeName">
|
||||||
|
<property name="format" value="(^[A-Z][0-9]?)$|(^[A-Z][_a-zA-Z0-9]*$)"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="MemberName">
|
||||||
|
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="ParameterName">
|
||||||
|
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="LocalVariableName">
|
||||||
|
<property name="tokens" value="VARIABLE_DEF"/>
|
||||||
|
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
|
||||||
|
<property name="allowOneCharVarInForLoop" value="true"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="ClassTypeParameterName">
|
||||||
|
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="MethodTypeParameterName">
|
||||||
|
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="NoFinalizer"/>
|
||||||
|
<module name="GenericWhitespace">
|
||||||
|
<message key="ws.followed"
|
||||||
|
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||||
|
<message key="ws.preceded"
|
||||||
|
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||||
|
<message key="ws.illegalFollow"
|
||||||
|
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||||
|
<message key="ws.notPreceded"
|
||||||
|
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||||
|
</module>
|
||||||
|
<module name="OverloadMethodsDeclarationOrder"/>
|
||||||
|
<module name="CustomImportOrder"/><!-- http://checkstyle.sourceforge.net/config_imports.html -->
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
|
<module name="OperatorWrap">
|
||||||
|
<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 "/>
|
||||||
|
</module>
|
||||||
|
<module name="AnnotationLocation">
|
||||||
|
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||||
|
</module>
|
||||||
|
<module name="AnnotationLocation">
|
||||||
|
<property name="tokens" value="VARIABLE_DEF"/>
|
||||||
|
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||||
|
</module>
|
||||||
|
<module name="MethodName">
|
||||||
|
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="CommentsIndentation"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
build.xml.data.CRC32=7bf70ec5
|
|
||||||
build.xml.script.CRC32=b1031e10
|
|
||||||
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
|
||||||
nbproject/build-impl.xml.data.CRC32=7bf70ec5
|
|
||||||
nbproject/build-impl.xml.script.CRC32=8511de95
|
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
|
|
@ -1,84 +0,0 @@
|
|||||||
annotation.processing.enabled=true
|
|
||||||
annotation.processing.enabled.in.editor=false
|
|
||||||
annotation.processing.processors.list=
|
|
||||||
annotation.processing.run.all.processors=true
|
|
||||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
|
||||||
application.title=TotalFreedomMod
|
|
||||||
application.vendor=Michael
|
|
||||||
build.classes.dir=${build.dir}/classes
|
|
||||||
build.classes.excludes=**/*.java,**/*.form
|
|
||||||
# This directory is removed when the project is cleaned:
|
|
||||||
build.dir=build
|
|
||||||
build.generated.dir=${build.dir}/generated
|
|
||||||
build.generated.sources.dir=${build.dir}/generated-sources
|
|
||||||
# Only compile against the classpath explicitly listed here:
|
|
||||||
build.sysclasspath=ignore
|
|
||||||
build.test.classes.dir=${build.dir}/test/classes
|
|
||||||
build.test.results.dir=${build.dir}/test/results
|
|
||||||
# Uncomment to specify the preferred debugger connection transport:
|
|
||||||
#debug.transport=dt_socket
|
|
||||||
debug.classpath=\
|
|
||||||
${run.classpath}
|
|
||||||
debug.test.classpath=\
|
|
||||||
${run.test.classpath}
|
|
||||||
# This directory is removed when the project is cleaned:
|
|
||||||
dist.dir=dist
|
|
||||||
dist.jar=${dist.dir}/TotalFreedomMod.jar
|
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
|
||||||
endorsed.classpath=
|
|
||||||
excludes=
|
|
||||||
includes=**
|
|
||||||
jar.archive.disabled=${jnlp.enabled}
|
|
||||||
jar.compress=false
|
|
||||||
jar.index=${jnlp.enabled}
|
|
||||||
javac.classpath=\
|
|
||||||
${libs.CraftBukkit.classpath}
|
|
||||||
# Space-separated list of extra javac options
|
|
||||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
|
||||||
javac.deprecation=false
|
|
||||||
javac.processorpath=\
|
|
||||||
${javac.classpath}
|
|
||||||
javac.source=1.6
|
|
||||||
javac.target=1.6
|
|
||||||
javac.test.classpath=\
|
|
||||||
${javac.classpath}:\
|
|
||||||
${build.classes.dir}
|
|
||||||
javac.test.processorpath=\
|
|
||||||
${javac.test.classpath}
|
|
||||||
javadoc.additionalparam=
|
|
||||||
javadoc.author=false
|
|
||||||
javadoc.encoding=${source.encoding}
|
|
||||||
javadoc.noindex=false
|
|
||||||
javadoc.nonavbar=false
|
|
||||||
javadoc.notree=false
|
|
||||||
javadoc.private=false
|
|
||||||
javadoc.splitindex=true
|
|
||||||
javadoc.use=true
|
|
||||||
javadoc.version=false
|
|
||||||
javadoc.windowtitle=
|
|
||||||
jnlp.codebase.type=no.codebase
|
|
||||||
jnlp.descriptor=application
|
|
||||||
jnlp.enabled=false
|
|
||||||
jnlp.mixed.code=default
|
|
||||||
jnlp.offline-allowed=false
|
|
||||||
jnlp.signed=false
|
|
||||||
jnlp.signing=
|
|
||||||
jnlp.signing.alias=
|
|
||||||
jnlp.signing.keystore=
|
|
||||||
main.class=totalfreedommod.TotalFreedomMod
|
|
||||||
manifest.file=manifest.mf
|
|
||||||
meta.inf.dir=${src.dir}/META-INF
|
|
||||||
mkdist.disabled=false
|
|
||||||
platform.active=default_platform
|
|
||||||
run.classpath=\
|
|
||||||
${javac.classpath}:\
|
|
||||||
${build.classes.dir}
|
|
||||||
# Space-separated list of JVM arguments used when running the project
|
|
||||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
|
||||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
|
||||||
run.jvmargs=
|
|
||||||
run.test.classpath=\
|
|
||||||
${javac.test.classpath}:\
|
|
||||||
${build.test.classes.dir}
|
|
||||||
source.encoding=UTF-8
|
|
||||||
src.dir=src
|
|
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
|
||||||
<type>org.netbeans.modules.java.j2seproject</type>
|
|
||||||
<configuration>
|
|
||||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
|
||||||
<name>TotalFreedomMod</name>
|
|
||||||
<source-roots>
|
|
||||||
<root id="src.dir"/>
|
|
||||||
</source-roots>
|
|
||||||
<test-roots/>
|
|
||||||
</data>
|
|
||||||
</configuration>
|
|
||||||
</project>
|
|
453
pom.xml
Normal file
453
pom.xml
Normal file
@ -0,0 +1,453 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<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>
|
||||||
|
|
||||||
|
<groupId>me.totalfreedom</groupId>
|
||||||
|
<artifactId>TotalFreedomMod</artifactId>
|
||||||
|
<version>2020.9</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<tfm.build.codename>Antaeus</tfm.build.codename>
|
||||||
|
<jar.finalName>${project.name}</jar.finalName>
|
||||||
|
<timestamp>${maven.build.timestamp}</timestamp>
|
||||||
|
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<name>TotalFreedomMod</name>
|
||||||
|
<description>Server modification for the TotalFreedom server</description>
|
||||||
|
<url>https://github.com/TFPatches/TotalFreedomMod</url>
|
||||||
|
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>TotalFreedom General License</name>
|
||||||
|
<url>https://github.com/TotalFreedom/License/blob/master/LICENSE.md</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<organization>
|
||||||
|
<name>TotalFreedom</name>
|
||||||
|
<url>https://totalfreedom.me</url>
|
||||||
|
</organization>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</connection>
|
||||||
|
<developerConnection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</developerConnection>
|
||||||
|
<url>git@github.com:TFPatches/TotalFreedomMod.git</url>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>CodeMC</id>
|
||||||
|
<url>https://repo.codemc.org/repository/maven-public</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>http://maven.elmakers.com/repository/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-snapshots</id>
|
||||||
|
<url>http://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>http://repo.md-5.net/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>http://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://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>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.12</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.7</version>
|
||||||
|
<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.9</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot</artifactId>
|
||||||
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TotalFreedom</groupId>
|
||||||
|
<artifactId>BukkitTelnet</artifactId>
|
||||||
|
<version>4.5-pre1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TFPatches</groupId>
|
||||||
|
<artifactId>TF-LibsDisguises</artifactId>
|
||||||
|
<version>0cfa32159a</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
|
<version>7.1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.ess3</groupId>
|
||||||
|
<artifactId>EssentialsX</artifactId>
|
||||||
|
<version>2.18.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.dv8tion</groupId>
|
||||||
|
<artifactId>JDA</artifactId>
|
||||||
|
<version>4.2.0_168</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.coreprotect</groupId>
|
||||||
|
<artifactId>coreprotect</artifactId>
|
||||||
|
<version>2.18.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
<version>7.0.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.destroystokyo.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</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>org.bukkit</groupId>
|
||||||
|
<artifactId>bukkit</artifactId>
|
||||||
|
<version>1.16.1-R0.1-SNAPSHOT</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.11</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>javassist</groupId>
|
||||||
|
<artifactId>javassist</artifactId>
|
||||||
|
<version>3.12.1.GA</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TFPatches</groupId>
|
||||||
|
<artifactId>TFGuilds</artifactId>
|
||||||
|
<version>ad93b9ed00</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.dean.jraw</groupId>
|
||||||
|
<artifactId>JRAW</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- Filter resources for build.properties -->
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<!-- Compiler -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||||
|
<compilerVersion>1.8</compilerVersion>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Git describe -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>pl.project13.maven</groupId>
|
||||||
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
<version>4.0.1</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>get-the-git-infos</id>
|
||||||
|
<goals>
|
||||||
|
<goal>revision</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>validate-the-git-infos</id>
|
||||||
|
<goals>
|
||||||
|
<goal>validateRevision</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>package</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
|
||||||
|
<prefix>git</prefix>
|
||||||
|
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
|
||||||
|
<verbose>false</verbose>
|
||||||
|
<format>properties</format>
|
||||||
|
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||||
|
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
|
||||||
|
<includeOnlyProperties>
|
||||||
|
<includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
|
||||||
|
</includeOnlyProperties>
|
||||||
|
<gitDescribe>
|
||||||
|
<skip>false</skip>
|
||||||
|
<always>false</always>
|
||||||
|
<abbrev>7</abbrev>
|
||||||
|
<dirty>-dirty</dirty>
|
||||||
|
<match>*</match>
|
||||||
|
</gitDescribe>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Antrun -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<version>1.8</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>default-cli</id>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<propertyfile file="${project.basedir}/src/main/resources/build.properties"
|
||||||
|
comment="Build information. Edit this to your liking.">
|
||||||
|
<entry key="buildAuthor" default="unknown"/>
|
||||||
|
<entry key="buildNumber" default="0"/>
|
||||||
|
<entry key="buildCodeName" value="${tfm.build.codename}"/>
|
||||||
|
<entry key="buildVersion" value="${project.version}"/>
|
||||||
|
<entry key="buildDate" value="${timestamp}"/>
|
||||||
|
<!--suppress UnresolvedMavenProperty -->
|
||||||
|
<entry key="buildHead" value="${git.commit.id.abbrev}"/>
|
||||||
|
</propertyfile>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Properties -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>properties-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>read-project-properties</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<files>
|
||||||
|
<file>${project.basedir}/src/main/resources/build.properties</file>
|
||||||
|
</files>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Buildnumber -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>create</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
||||||
|
<buildNumberPropertiesFileLocation>${project.basedir}/src/main/resources/build.properties
|
||||||
|
</buildNumberPropertiesFileLocation>
|
||||||
|
<format>{0,number,#}</format>
|
||||||
|
<items>
|
||||||
|
<item>buildNumber</item>
|
||||||
|
</items>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Shade -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<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>javassist:javassist</include>
|
||||||
|
<include>me.rayzr522:jsonmessage</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<!-- Checkstyle -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
|
<failOnViolation>true</failOnViolation>
|
||||||
|
<failsOnError>true</failsOnError>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
</project>
|
@ -1,72 +0,0 @@
|
|||||||
# TotalFreedomMod v2.19 Configuration
|
|
||||||
# by Madgeek1450 and DarthSalamon
|
|
||||||
|
|
||||||
# Block placement prevention:
|
|
||||||
allow_fire_place: false
|
|
||||||
allow_fire_spread: false
|
|
||||||
allow_lava_damage: false
|
|
||||||
allow_lava_place: false
|
|
||||||
allow_water_place: false
|
|
||||||
allow_fluid_spread: false
|
|
||||||
allow_tnt_minecarts: false
|
|
||||||
|
|
||||||
# Explosion management:
|
|
||||||
allow_explosions: false
|
|
||||||
explosiveRadius: 4.0
|
|
||||||
|
|
||||||
#Automatically wipe dropped objects:
|
|
||||||
auto_wipe: true
|
|
||||||
|
|
||||||
# Nuking prevention:
|
|
||||||
nuke_monitor: true
|
|
||||||
nuke_monitor_count_break: 100
|
|
||||||
nuke_monitor_count_place: 25
|
|
||||||
nuke_monitor_range: 10.0
|
|
||||||
freecam_trigger_count: 10
|
|
||||||
|
|
||||||
# Show all attempted commands in the log, will result in duplicate log messages:
|
|
||||||
preprocess_log: true
|
|
||||||
|
|
||||||
# Disable nighttime:
|
|
||||||
disable_night: true
|
|
||||||
|
|
||||||
# Disable weather:
|
|
||||||
disable_weather: true
|
|
||||||
|
|
||||||
# Enable misc. features:
|
|
||||||
landmines_enabled: false
|
|
||||||
mp44_enabled: false
|
|
||||||
tossmob_enabled: false
|
|
||||||
|
|
||||||
# Moblimiter:
|
|
||||||
mob_limiter_enabled: true
|
|
||||||
# Max per world:
|
|
||||||
mob_limiter_max: 50
|
|
||||||
mob_limiter_disable_dragon: true
|
|
||||||
mob_limiter_disable_ghast: true
|
|
||||||
mob_limiter_disable_slime: true
|
|
||||||
mob_limiter_disable_giant: true
|
|
||||||
|
|
||||||
# Flatlands
|
|
||||||
generate_flatlands: true
|
|
||||||
# Flatlands generation parameters, uses CleanroomGenerator syntax - http://dev.bukkit.org/server-mods/cleanroomgenerator/
|
|
||||||
flatlands_generation_params: 16,stone,32,dirt,1,grass
|
|
||||||
|
|
||||||
# Admin-Only Mode
|
|
||||||
admin_only_mode: false
|
|
||||||
|
|
||||||
# Protected Areas - Protect areas so that only superadmins can directly modify blocks in those areas. WorldEdit and other such plugins might bypass this.
|
|
||||||
protected_areas_enabled: true
|
|
||||||
auto_protect_spawnpoints: true
|
|
||||||
auto_protect_radius: 25.0
|
|
||||||
|
|
||||||
# Host Sender Names - Names that indicate automated services or host-based consoles you want to block from using some commands.
|
|
||||||
# Make sure these are all lower-case.
|
|
||||||
host_sender_names:
|
|
||||||
- rcon
|
|
||||||
- remotebukkit
|
|
||||||
|
|
||||||
# TwitterBot - Used to allow superadmins to verify themselves using twitter
|
|
||||||
twitterbot_enabled: false
|
|
||||||
twitterbot_url: 'http://tftwitter.darthcraft.net/'
|
|
||||||
twitterbot_secret: ''
|
|
23
src/main/java/ca/momothereal/mojangson/MojangsonFinder.java
Normal file
23
src/main/java/ca/momothereal/mojangson/MojangsonFinder.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package ca.momothereal.mojangson;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonString;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||||
|
|
||||||
|
public class MojangsonFinder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically detects the appropriate MojangsonValue from the given value.
|
||||||
|
*
|
||||||
|
* @param value The value to parse
|
||||||
|
* @return The resulting MojangsonValue. If the type couldn't be found, it falls back to MojangsonString
|
||||||
|
* @throws MojangsonParseException if the given value could not be parsed
|
||||||
|
*/
|
||||||
|
public static MojangsonValue readFromValue(String value) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
MojangsonValue val = new MojangsonString();
|
||||||
|
val.read(value);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
53
src/main/java/ca/momothereal/mojangson/MojangsonToken.java
Normal file
53
src/main/java/ca/momothereal/mojangson/MojangsonToken.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package ca.momothereal.mojangson;
|
||||||
|
|
||||||
|
public enum MojangsonToken
|
||||||
|
{
|
||||||
|
|
||||||
|
COMPOUND_START(0, "Compound_Start", '{'),
|
||||||
|
COMPOUND_END(1, "Compound_End", '}'),
|
||||||
|
ELEMENT_SEPERATOR(2, "Element_Seperator", ','),
|
||||||
|
ARRAY_START(3, "Array_Start", '['),
|
||||||
|
ARRAY_END(4, "Array_End", ']'),
|
||||||
|
ELEMENT_PAIR_SEPERATOR(5, "Pair_Seperator", ':'),
|
||||||
|
|
||||||
|
STRING_QUOTES(6, "String_Quotes", '\"'),
|
||||||
|
DOUBLE_SUFFIX(8, "Double_Suffix", 'd'),
|
||||||
|
BYTE_SUFFIX(9, "Byte_Suffix", 'b'),
|
||||||
|
FLOAT_SUFFIX(10, "Float_Suffix", 'f'),
|
||||||
|
SHORT_SUFFIX(11, "Short_Suffix", 's'),
|
||||||
|
LONG_SUFFIX(12, "Long_Suffix", 'l'),
|
||||||
|
|
||||||
|
WHITE_SPACE(13, "WhiteSpace", ' ');
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private char symbol;
|
||||||
|
|
||||||
|
MojangsonToken(int id, String name, char symbol)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.symbol = symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getSymbol()
|
||||||
|
{
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return String.valueOf(symbol);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package ca.momothereal.mojangson.ex;
|
||||||
|
|
||||||
|
public class MojangsonParseException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
private ParseExceptionReason reason;
|
||||||
|
|
||||||
|
public MojangsonParseException(String message, ParseExceptionReason reason)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParseExceptionReason getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return reason.getMessage() + ": " + super.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ParseExceptionReason
|
||||||
|
{
|
||||||
|
INVALID_FORMAT_NUM("Given value is not numerical"),
|
||||||
|
UNEXPECTED_SYMBOL("Unexpected symbol in Mojangson string");
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
ParseExceptionReason(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package ca.momothereal.mojangson.value;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.MojangsonFinder;
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import static ca.momothereal.mojangson.MojangsonToken.*;
|
||||||
|
|
||||||
|
public class MojangsonCompound extends HashMap<String, List<MojangsonValue>> implements MojangsonValue<Map<String, MojangsonValue>>
|
||||||
|
{
|
||||||
|
|
||||||
|
private final int C_COMPOUND_START = 0; // Parsing context
|
||||||
|
private final int C_COMPOUND_PAIR_KEY = 1; // Parsing context
|
||||||
|
private final int C_COMPOUND_PAIR_VALUE = 2; // Parsing context
|
||||||
|
|
||||||
|
public MojangsonCompound()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MojangsonCompound(Map map)
|
||||||
|
{
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(StringBuilder builder)
|
||||||
|
{
|
||||||
|
builder.append(COMPOUND_START);
|
||||||
|
boolean start = true;
|
||||||
|
|
||||||
|
for (String key : keySet())
|
||||||
|
{
|
||||||
|
if (start)
|
||||||
|
{
|
||||||
|
start = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.append(ELEMENT_SEPERATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append(key).append(ELEMENT_PAIR_SEPERATOR);
|
||||||
|
List<MojangsonValue> value = get(key);
|
||||||
|
for (MojangsonValue val : value)
|
||||||
|
{
|
||||||
|
val.write(builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.append(COMPOUND_END);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(String string) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
int context = C_COMPOUND_START;
|
||||||
|
String tmp_key = "", tmp_val = "";
|
||||||
|
int scope = 0;
|
||||||
|
boolean inString = false;
|
||||||
|
|
||||||
|
for (int index = 0; index < string.length(); index++)
|
||||||
|
{
|
||||||
|
Character character = string.charAt(index);
|
||||||
|
|
||||||
|
if (character == STRING_QUOTES.getSymbol())
|
||||||
|
{
|
||||||
|
inString = !inString;
|
||||||
|
}
|
||||||
|
if (character == WHITE_SPACE.getSymbol())
|
||||||
|
{
|
||||||
|
if (!inString)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((character == COMPOUND_START.getSymbol() || character == ARRAY_START.getSymbol()) && !inString)
|
||||||
|
{
|
||||||
|
scope++;
|
||||||
|
}
|
||||||
|
if ((character == COMPOUND_END.getSymbol() || character == ARRAY_END.getSymbol()) && !inString)
|
||||||
|
{
|
||||||
|
scope--;
|
||||||
|
}
|
||||||
|
if (context == C_COMPOUND_START)
|
||||||
|
{
|
||||||
|
if (character != COMPOUND_START.getSymbol())
|
||||||
|
{
|
||||||
|
parseException(index, character);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (context == C_COMPOUND_PAIR_KEY)
|
||||||
|
{
|
||||||
|
if (character == ELEMENT_PAIR_SEPERATOR.getSymbol() && scope <= 1)
|
||||||
|
{
|
||||||
|
context++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tmp_key += character;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (context == C_COMPOUND_PAIR_VALUE)
|
||||||
|
{
|
||||||
|
if ((character == ELEMENT_SEPERATOR.getSymbol() || character == COMPOUND_END.getSymbol()) && scope <= 1 && !inString)
|
||||||
|
{
|
||||||
|
context = C_COMPOUND_PAIR_KEY;
|
||||||
|
computeIfAbsent(tmp_key, k -> new ArrayList<>()).add(MojangsonFinder.readFromValue(tmp_val));
|
||||||
|
tmp_key = tmp_val = "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tmp_val += character;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, MojangsonValue> getValue()
|
||||||
|
{
|
||||||
|
HashMap<String, MojangsonValue> hack = new HashMap<>();
|
||||||
|
for (String string : keySet())
|
||||||
|
{
|
||||||
|
for (MojangsonValue value : get(string))
|
||||||
|
{
|
||||||
|
hack.put(string, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getValueClass()
|
||||||
|
{
|
||||||
|
return Map.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseException(int index, char symbol) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
throw new MojangsonParseException("Index: " + index + ", symbol: \'" + symbol + "\'", MojangsonParseException.ParseExceptionReason.UNEXPECTED_SYMBOL);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package ca.momothereal.mojangson.value;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.MojangsonToken;
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
|
||||||
|
public class MojangsonString implements MojangsonValue<String>
|
||||||
|
{
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public MojangsonString()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MojangsonString(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(StringBuilder builder)
|
||||||
|
{
|
||||||
|
builder.append(MojangsonToken.STRING_QUOTES).append(value).append(MojangsonToken.STRING_QUOTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getValueClass()
|
||||||
|
{
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(String string) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
Character lastChar = string.charAt(string.length() - 1);
|
||||||
|
Character firstChar = string.charAt(0);
|
||||||
|
|
||||||
|
if (firstChar == MojangsonToken.STRING_QUOTES.getSymbol() && lastChar == MojangsonToken.STRING_QUOTES.getSymbol())
|
||||||
|
{
|
||||||
|
value = string.substring(1, string.length() - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package ca.momothereal.mojangson.value;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a value inside a compound or array.
|
||||||
|
*
|
||||||
|
* @param <T> The type of value this MojangsonValue holds
|
||||||
|
*/
|
||||||
|
public interface MojangsonValue<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the value to a StringBuilder buffer.
|
||||||
|
*
|
||||||
|
* @param builder The buffer to write to
|
||||||
|
*/
|
||||||
|
void write(StringBuilder builder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses and updates the current value to the given string representation
|
||||||
|
*
|
||||||
|
* @param string The string representation of the value
|
||||||
|
* @throws MojangsonParseException if the given value cannot be parsed
|
||||||
|
*/
|
||||||
|
void read(String string) throws MojangsonParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current literal value
|
||||||
|
*
|
||||||
|
* @return The current literal value of the MojangsonValue
|
||||||
|
*/
|
||||||
|
T getValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the literal value's class
|
||||||
|
*
|
||||||
|
* @return The literal value's class
|
||||||
|
*/
|
||||||
|
Class getValueClass();
|
||||||
|
|
||||||
|
}
|
187
src/main/java/me/totalfreedom/totalfreedommod/AMP.java
Normal file
187
src/main/java/me/totalfreedom/totalfreedommod/AMP.java
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import joptsimple.internal.Strings;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
public class AMP extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public String URL = ConfigEntry.AMP_URL.getString();
|
||||||
|
private String API_URL = URL + "/API/Core";
|
||||||
|
private String USERNAME = ConfigEntry.AMP_USERNAME.getString();
|
||||||
|
private String PASSWORD = ConfigEntry.AMP_PASSWORD.getString();
|
||||||
|
private String SESSION_ID;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||||
|
|
||||||
|
private final List<String> headers = Arrays.asList("Accept:application/json");
|
||||||
|
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
login();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
logout();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void login()
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("username", USERNAME);
|
||||||
|
json.put("password", PASSWORD);
|
||||||
|
json.put("token", "");
|
||||||
|
json.put("rememberMe", false);
|
||||||
|
|
||||||
|
String response;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = FUtil.sendRequest(API_URL + "/Login", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject jsonResponse;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
jsonResponse = (JSONObject)new JSONParser().parse(response);
|
||||||
|
}
|
||||||
|
catch (ParseException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object sessionID = jsonResponse.get("sessionID");
|
||||||
|
if (sessionID == null)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid AMP credentials have been specified in the config");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SESSION_ID = sessionID.toString();
|
||||||
|
FLog.info("Logged into AMP");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logout()
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/Logout", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Logged out of AMP");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAccountStatus(StaffMember staffMember)
|
||||||
|
{
|
||||||
|
String username = staffMember.getAmpUsername();
|
||||||
|
|
||||||
|
if (username == null || !enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!staffMember.isActive() || staffMember.getRank() != Rank.ADMIN)
|
||||||
|
{
|
||||||
|
FLog.debug("Disabling amp acc");
|
||||||
|
setAccountEnabled(username, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.debug("Enabling amp acc");
|
||||||
|
setAccountEnabled(username, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createAccount(String username, String password)
|
||||||
|
{
|
||||||
|
makeAccount(username);
|
||||||
|
setPassword(username, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAccountEnabled(String username, boolean enable)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("Username", username);
|
||||||
|
json.put("Disabled", !enable);
|
||||||
|
json.put("PasswordExpires", false);
|
||||||
|
json.put("CannotChangePassword", false);
|
||||||
|
json.put("MustChangePassword", false);
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/UpdateUserInfo", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void makeAccount(String username)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("Username", username);
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/CreateUser", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String username, String password)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("Username", username);
|
||||||
|
json.put("NewPassword", password);
|
||||||
|
json.put("SESSIONID", SESSION_ID);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(API_URL + "/ResetUserPassword", "POST", headers, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
83
src/main/java/me/totalfreedom/totalfreedommod/Announcer.java
Normal file
83
src/main/java/me/totalfreedom/totalfreedommod/Announcer.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class Announcer extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final List<String> announcements = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
private boolean enabled;
|
||||||
|
@Getter
|
||||||
|
private long interval;
|
||||||
|
@Getter
|
||||||
|
private String prefix;
|
||||||
|
private BukkitTask announcer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
|
||||||
|
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
|
||||||
|
prefix = FUtil.colorize(ConfigEntry.ANNOUNCER_PREFIX.getString());
|
||||||
|
|
||||||
|
announcements.clear();
|
||||||
|
for (Object announcement : ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList())
|
||||||
|
{
|
||||||
|
announcements.add(FUtil.colorize((String)announcement));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
announcer = new BukkitRunnable()
|
||||||
|
{
|
||||||
|
private int current = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
current++;
|
||||||
|
|
||||||
|
if (current >= announcements.size())
|
||||||
|
{
|
||||||
|
current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
announce(announcements.get(current));
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, interval, interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
if (announcer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.cancel(announcer);
|
||||||
|
announcer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAnnouncements()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableList(announcements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void announce(String message)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(prefix + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
71
src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java
Normal file
71
src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
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;
|
||||||
|
|
||||||
|
public class AntiNuke extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||||
|
{
|
||||||
|
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.");
|
||||||
|
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||||
|
|
||||||
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||||
|
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
||||||
|
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
|
||||||
|
|
||||||
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
136
src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java
Normal file
136
src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class AntiSpam extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int MSG_PER_CYCLE = 8;
|
||||||
|
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||||
|
List<Player> markedForDeath = new ArrayList<>();
|
||||||
|
//
|
||||||
|
public BukkitTask cycleTask = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
cycle();
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, TICKS_PER_CYCLE, TICKS_PER_CYCLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
FUtil.cancel(cycleTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cycle()
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
// TODO: Move each to their own section
|
||||||
|
playerdata.resetMsgCount();
|
||||||
|
playerdata.resetBlockDestroyCount();
|
||||||
|
playerdata.resetBlockPlaceCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
|
// Check for spam
|
||||||
|
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
|
{
|
||||||
|
if (!markedForDeath.contains(player))
|
||||||
|
{
|
||||||
|
markedForDeath.add(player);
|
||||||
|
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||||
|
FSync.autoEject(player, "Kicked for spamming chat.");
|
||||||
|
|
||||||
|
playerdata.resetMsgCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
String command = event.getMessage();
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
fPlayer.setLastCommand(command);
|
||||||
|
|
||||||
|
if (fPlayer.allCommandsBlocked())
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||||
|
plugin.ae.autoEject(player, "Kicked for spamming commands.");
|
||||||
|
|
||||||
|
fPlayer.resetMsgCount();
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
|
{
|
||||||
|
if (markedForDeath.contains(event.getPlayer()))
|
||||||
|
{
|
||||||
|
markedForDeath.remove(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
110
src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
Normal file
110
src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class AutoEject extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void autoEject(Player player, String kickMessage)
|
||||||
|
{
|
||||||
|
EjectMethod method = EjectMethod.STRIKE_ONE;
|
||||||
|
final String ip = FUtil.getIp(player);
|
||||||
|
|
||||||
|
if (!ejects.containsKey(ip))
|
||||||
|
{
|
||||||
|
ejects.put(ip, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int kicks = ejects.get(ip);
|
||||||
|
kicks += 1;
|
||||||
|
|
||||||
|
ejects.put(ip, kicks);
|
||||||
|
|
||||||
|
if (kicks <= 1)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_ONE;
|
||||||
|
}
|
||||||
|
else if (kicks == 2)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_TWO;
|
||||||
|
}
|
||||||
|
else if (kicks >= 3)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_THREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("AutoEject -> name: " + player.getName() + " - player ip: " + ip + " - method: " + method.toString());
|
||||||
|
|
||||||
|
player.setOp(false);
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
switch (method)
|
||||||
|
{
|
||||||
|
case STRIKE_ONE:
|
||||||
|
{
|
||||||
|
final Calendar cal = new GregorianCalendar();
|
||||||
|
cal.add(Calendar.MINUTE, 5);
|
||||||
|
final Date expires = cal.getTime();
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 5 minutes.");
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRIKE_TWO:
|
||||||
|
{
|
||||||
|
final Calendar c = new GregorianCalendar();
|
||||||
|
c.add(Calendar.MINUTE, 10);
|
||||||
|
final Date expires = c.getTime();
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 10 minutes.");
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRIKE_THREE:
|
||||||
|
{
|
||||||
|
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||||
|
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EjectMethod
|
||||||
|
{
|
||||||
|
|
||||||
|
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
68
src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java
Normal file
68
src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class AutoKick extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final long AUTOKICK_RATE = 10 * 20L;
|
||||||
|
//
|
||||||
|
private BukkitTask kickTask = null;
|
||||||
|
private long autoKickTicks;
|
||||||
|
private double autoKickThreshold;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
|
||||||
|
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
|
||||||
|
|
||||||
|
if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kickTask = new BukkitRunnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
autoKickCheck();
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, AUTOKICK_RATE, AUTOKICK_RATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
FUtil.cancel(kickTask);
|
||||||
|
kickTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void autoKickCheck()
|
||||||
|
{
|
||||||
|
final boolean doAwayKickCheck
|
||||||
|
= plugin.esb.isEnabled()
|
||||||
|
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
||||||
|
|
||||||
|
if (!doAwayKickCheck)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final long lastActivity = plugin.esb.getLastActivity(player.getName());
|
||||||
|
if (lastActivity > 0 && lastActivity + autoKickTicks < System.currentTimeMillis())
|
||||||
|
{
|
||||||
|
player.kickPlayer("Automatically kicked by server for inactivity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
102
src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java
Normal file
102
src/main/java/me/totalfreedom/totalfreedommod/BackupManager.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
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.FUtil;
|
||||||
|
import org.bukkit.util.FileUtil;
|
||||||
|
|
||||||
|
public class BackupManager extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createBackups(String file)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
final String save = file.split("\\.")[0];
|
||||||
|
final YamlConfig config = new YamlConfig(plugin, "backup/backup.yml", false);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
// Weekly
|
||||||
|
if (!config.isInt(save + ".weekly"))
|
||||||
|
{
|
||||||
|
performBackup(file, "weekly");
|
||||||
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int lastBackupWeekly = config.getInt(save + ".weekly");
|
||||||
|
|
||||||
|
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime())
|
||||||
|
{
|
||||||
|
performBackup(file, "weekly");
|
||||||
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlyWeekly)
|
||||||
|
{
|
||||||
|
config.save();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Daily
|
||||||
|
if (!config.isInt(save + ".daily"))
|
||||||
|
{
|
||||||
|
performBackup(file, "daily");
|
||||||
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int lastBackupDaily = config.getInt(save + ".daily");
|
||||||
|
|
||||||
|
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime())
|
||||||
|
{
|
||||||
|
performBackup(file, "daily");
|
||||||
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performBackup(String file, String type)
|
||||||
|
{
|
||||||
|
FLog.info("Backing up " + file + " to " + file + "." + type + ".bak");
|
||||||
|
final File backupFolder = new File(plugin.getDataFolder(), "backup");
|
||||||
|
|
||||||
|
if (!backupFolder.exists())
|
||||||
|
{
|
||||||
|
backupFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
final File oldYaml = new File(plugin.getDataFolder(), file);
|
||||||
|
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
|
||||||
|
FileUtil.copy(oldYaml, newYaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
193
src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java
Normal file
193
src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.SoundCategory;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
|
|
||||||
|
public class ChatManager extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
handleChatEvent(event);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleChatEvent(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
|
// Format colors and strip &k
|
||||||
|
message = FUtil.colorize(message);
|
||||||
|
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
||||||
|
|
||||||
|
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
||||||
|
{
|
||||||
|
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.sl.isStaff(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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
if (fPlayer.isLockedUp())
|
||||||
|
{
|
||||||
|
FSync.playerMsg(player, "You're locked up and cannot talk.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for staffchat
|
||||||
|
if (fPlayer.inStaffChat())
|
||||||
|
{
|
||||||
|
FSync.staffChatMessage(player, message);
|
||||||
|
event.setCancelled(true);
|
||||||
|
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
|
||||||
|
event.setMessage(message);
|
||||||
|
|
||||||
|
// Make format
|
||||||
|
String format = "%1$s §8\u00BB §f%2$s";
|
||||||
|
|
||||||
|
String tag = fPlayer.getTag();
|
||||||
|
if (tag != null && !tag.isEmpty())
|
||||||
|
{
|
||||||
|
format = tag.replace("%", "%%") + " " + format;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for mentions
|
||||||
|
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.sl.isStaff(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
|
||||||
|
event.setFormat(format);
|
||||||
|
|
||||||
|
// Send to discord
|
||||||
|
if (!ConfigEntry.STAFF_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
||||||
|
{
|
||||||
|
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getColor(Displayable display)
|
||||||
|
{
|
||||||
|
ChatColor color = display.getColor();
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColoredTag(Displayable display)
|
||||||
|
{
|
||||||
|
ChatColor color = display.getColor();
|
||||||
|
return color + display.getAbbr();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void staffChat(CommandSender sender, String message)
|
||||||
|
{
|
||||||
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
|
FLog.info("[STAFF] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||||
|
if (!Strings.isNullOrEmpty(staffMember.getAcFormat()))
|
||||||
|
{
|
||||||
|
String format = staffMember.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 + "STAFF" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reportAction(Player reporter, Player reported, String report)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class CommandSpy extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.sl.isStaff(player) && plugin.sl.getAdmin(player).getCommandSpy())
|
||||||
|
{
|
||||||
|
if (plugin.sl.isStaff(event.getPlayer()) && !plugin.sl.isAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (player != event.getPlayer())
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
111
src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java
Normal file
111
src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class EntityWiper extends FreedomService
|
||||||
|
{
|
||||||
|
private BukkitTask wiper;
|
||||||
|
|
||||||
|
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||||
|
EntityType.ARMOR_STAND,
|
||||||
|
EntityType.PAINTING,
|
||||||
|
EntityType.BOAT,
|
||||||
|
EntityType.LEASH_HITCH,
|
||||||
|
EntityType.ITEM_FRAME,
|
||||||
|
EntityType.MINECART
|
||||||
|
);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
// Continuous Entity Wiper
|
||||||
|
wiper = new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
wipeEntities(false);
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
wiper.cancel();
|
||||||
|
wiper = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methods for wiping
|
||||||
|
|
||||||
|
public int wipeEntities(boolean bypassBlacklist)
|
||||||
|
{
|
||||||
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
for (Entity entity : world.getEntities())
|
||||||
|
{
|
||||||
|
if (!(entity instanceof Player))
|
||||||
|
{
|
||||||
|
if ((!bypassBlacklist && BLACKLIST.contains(entity.getType())) || Groups.MOB_TYPES.contains(entity.getType()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int wipeEntities(EntityType entityType)
|
||||||
|
{
|
||||||
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
for (Entity entity : world.getEntities())
|
||||||
|
{
|
||||||
|
if (!entity.getType().equals(entityType))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int purgeMobs(EntityType type)
|
||||||
|
{
|
||||||
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public abstract class FreedomService implements Listener
|
||||||
|
{
|
||||||
|
protected final TotalFreedomMod plugin;
|
||||||
|
protected final Server server;
|
||||||
|
protected final FLog logger;
|
||||||
|
|
||||||
|
public FreedomService()
|
||||||
|
{
|
||||||
|
plugin = TotalFreedomMod.getPlugin();
|
||||||
|
server = plugin.getServer();
|
||||||
|
logger = new FLog();
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
plugin.fsh.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onStart();
|
||||||
|
public abstract void onStop();
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public class FreedomServiceHandler
|
||||||
|
{
|
||||||
|
@Getter
|
||||||
|
private 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
56
src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java
Normal file
56
src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
public class Fuckoff extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
final Player fuckoffPlayer = event.getPlayer();
|
||||||
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
|
||||||
|
if (!fPlayer.isFuckOff()
|
||||||
|
|| fuckoffPlayer.equals(onlinePlayer))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
double fuckoffRange = fPlayer.getFuckoffRadius();
|
||||||
|
Location opLocation = onlinePlayer.getLocation();
|
||||||
|
Location foLocation = fuckoffPlayer.getLocation();
|
||||||
|
|
||||||
|
double distanceSquared;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
distanceSquared = opLocation.distanceSquared(foLocation);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||||
|
{
|
||||||
|
fuckoffPlayer.setVelocity(onlinePlayer.getLocation().toVector().add(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,122 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
public class GameRuleHandler extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
|
||||||
|
|
||||||
|
public GameRuleHandler()
|
||||||
|
{
|
||||||
|
for (GameRule gameRule : GameRule.values())
|
||||||
|
{
|
||||||
|
rules.put(gameRule, gameRule.getDefaultValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
|
||||||
|
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
|
||||||
|
setGameRule(GameRule.DO_MOB_LOOT, false, false);
|
||||||
|
setGameRule(GameRule.DO_MOB_SPAWNING, !ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
|
||||||
|
setGameRule(GameRule.DO_TILE_DROPS, false, false);
|
||||||
|
setGameRule(GameRule.MOB_GRIEFING, false, false);
|
||||||
|
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGameRule(GameRule gameRule, boolean value)
|
||||||
|
{
|
||||||
|
setGameRule(gameRule, value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGameRule(GameRule gameRule, boolean value, boolean doCommit)
|
||||||
|
{
|
||||||
|
rules.put(gameRule, value);
|
||||||
|
if (doCommit)
|
||||||
|
{
|
||||||
|
commitGameRules();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void commitGameRules()
|
||||||
|
{
|
||||||
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
|
Iterator<Map.Entry<GameRule, Boolean>> it = rules.entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
|
||||||
|
Map.Entry<GameRule, Boolean> gameRuleEntry = it.next();
|
||||||
|
String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
|
||||||
|
String gameRuleValue = gameRuleEntry.getValue().toString();
|
||||||
|
|
||||||
|
for (World world : worlds)
|
||||||
|
{
|
||||||
|
world.setGameRuleValue(gameRuleName, gameRuleValue);
|
||||||
|
if (gameRuleEntry.getKey() == GameRule.DO_DAYLIGHT_CYCLE && !gameRuleEntry.getValue())
|
||||||
|
{
|
||||||
|
long time = world.getTime();
|
||||||
|
time -= time % 24000;
|
||||||
|
world.setTime(time + 24000 + 6000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum GameRule
|
||||||
|
{
|
||||||
|
|
||||||
|
DO_FIRE_TICK("doFireTick", true),
|
||||||
|
MOB_GRIEFING("mobGriefing", true),
|
||||||
|
KEEP_INVENTORY("keepInventory", false),
|
||||||
|
DO_MOB_SPAWNING("doMobSpawning", true),
|
||||||
|
DO_MOB_LOOT("doMobLoot", true),
|
||||||
|
DO_TILE_DROPS("doTileDrops", true),
|
||||||
|
COMMAND_BLOCK_OUTPUT("commandBlockOutput", true),
|
||||||
|
NATURAL_REGENERATION("naturalRegeneration", 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 boolean defaultValue;
|
||||||
|
|
||||||
|
private GameRule(String gameRuleName, boolean defaultValue)
|
||||||
|
{
|
||||||
|
this.gameRuleName = gameRuleName;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGameRuleName()
|
||||||
|
{
|
||||||
|
return gameRuleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getDefaultValue()
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
204
src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
Normal file
204
src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
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.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class LogViewer extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
||||||
|
{
|
||||||
|
updateLogsRegistration(sender, target.getName(), mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
|
||||||
|
{
|
||||||
|
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
||||||
|
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
||||||
|
|
||||||
|
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (sender != null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String key = SecureCodeGenerator.generateCode(20);
|
||||||
|
|
||||||
|
final URL urlAdd = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", mode.name())
|
||||||
|
.addQueryParameter("password", logsRegisterPassword)
|
||||||
|
.addQueryParameter("name", targetName)
|
||||||
|
.addQueryParameter("key", key)
|
||||||
|
.getURL();
|
||||||
|
|
||||||
|
final HttpURLConnection connection = (HttpURLConnection)urlAdd.openConnection();
|
||||||
|
connection.setConnectTimeout(1000 * 5);
|
||||||
|
connection.setReadTimeout(1000 * 5);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setRequestMethod("HEAD");
|
||||||
|
|
||||||
|
final int responseCode = connection.getResponseCode();
|
||||||
|
|
||||||
|
if (sender != null)
|
||||||
|
{
|
||||||
|
if (!plugin.isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (responseCode == 200)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum LogsRegistrationMode
|
||||||
|
{
|
||||||
|
|
||||||
|
ADD, DELETE, VERIFY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class URLBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
private final String requestPath;
|
||||||
|
private final Map<String, String> queryStringMap = new HashMap<>();
|
||||||
|
|
||||||
|
private URLBuilder(String requestPath)
|
||||||
|
{
|
||||||
|
this.requestPath = requestPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URLBuilder addQueryParameter(String key, String value)
|
||||||
|
{
|
||||||
|
queryStringMap.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL getURL() throws MalformedURLException
|
||||||
|
{
|
||||||
|
List<String> pairs = new ArrayList<>();
|
||||||
|
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
Map.Entry<String, String> pair = it.next();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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, "&"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
271
src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
Normal file
271
src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
Normal file
@ -0,0 +1,271 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.rayzr522.jsonmessage.JSONMessage;
|
||||||
|
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.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class LoginProcess extends FreedomService
|
||||||
|
{
|
||||||
|
public static final int DEFAULT_PORT = 25565;
|
||||||
|
public static final int MIN_USERNAME_LENGTH = 2;
|
||||||
|
public static final int MAX_USERNAME_LENGTH = 20;
|
||||||
|
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
||||||
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private static boolean lockdownEnabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Banning and Permban checks are their respective services
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
||||||
|
{
|
||||||
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
|
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
|
// Check if the player is already online
|
||||||
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!onlinePlayer.getName().equalsIgnoreCase(event.getName()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isStaff)
|
||||||
|
{
|
||||||
|
event.allow();
|
||||||
|
FSync.playerKick(onlinePlayer, "A staff member just logged in with the username you are using.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username is already logged into this server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final String username = player.getName();
|
||||||
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
|
// Check username length
|
||||||
|
if (username.length() < MIN_USERNAME_LENGTH || username.length() > MAX_USERNAME_LENGTH)
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is an invalid length (must be between 3 and 20 characters long).");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check username characters
|
||||||
|
if (!USERNAME_REGEX.matcher(username).find())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username contains invalid characters.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check force-IP match
|
||||||
|
if (ConfigEntry.FORCE_IP_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
final String hostname = event.getHostname().replace("\u0000FML\u0000", ""); // Forge fix - https://github.com/TotalFreedom/TotalFreedomMod/issues/493
|
||||||
|
final String connectAddress = ConfigEntry.SERVER_ADDRESS.getString();
|
||||||
|
final int connectPort = server.getPort();
|
||||||
|
|
||||||
|
if (!hostname.equalsIgnoreCase(connectAddress + ":" + connectPort) && !hostname.equalsIgnoreCase(connectAddress + ".:" + connectPort))
|
||||||
|
{
|
||||||
|
final int forceIpPort = ConfigEntry.FORCE_IP_PORT.getInteger();
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||||
|
ConfigEntry.FORCE_IP_KICKMSG.getString()
|
||||||
|
.replace("%address%", ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == DEFAULT_PORT ? "" : ":" + forceIpPort)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if player is staff
|
||||||
|
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
|
// Validation below this point
|
||||||
|
if (isStaff) // Player is staff
|
||||||
|
{
|
||||||
|
// Force-allow log in
|
||||||
|
event.allow();
|
||||||
|
|
||||||
|
int count = server.getOnlinePlayers().size();
|
||||||
|
if (count >= server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.sl.isStaff(onlinePlayer))
|
||||||
|
{
|
||||||
|
onlinePlayer.kickPlayer("You have been kicked to free up room for a staff member.");
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count < server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count >= server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player is not a staff member
|
||||||
|
// Server full check
|
||||||
|
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Sorry, but this server is full.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Staff-only mode
|
||||||
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to staff only.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lockdown mode
|
||||||
|
if (lockdownEnabled)
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is currently in lockdown mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Whitelist
|
||||||
|
if (plugin.si.isWhitelisted())
|
||||||
|
{
|
||||||
|
if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
player.teleport(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.sl.isStaff(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 + " staff 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.sl.isStaffImpostor(p))
|
||||||
|
{
|
||||||
|
notice.send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "Server is currently closed to non-staff.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lockdownEnabled)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 20L);
|
||||||
|
}
|
||||||
|
}
|
145
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal file
145
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
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 lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
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
|
||||||
|
{
|
||||||
|
@Getter
|
||||||
|
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.sl.messageAllStaff(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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,186 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonCompound;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_16_R1.NBTTagList;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class MovementValidator extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int MAX_XYZ_COORD = 29999998;
|
||||||
|
public static final int MAX_DISTANCE_TRAVELED = 100;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
|
{
|
||||||
|
// 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); // 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();
|
||||||
|
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);
|
||||||
|
player.teleport(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)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
// Validate position
|
||||||
|
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
||||||
|
{
|
||||||
|
player.teleport(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_R1.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()
|
||||||
|
{
|
||||||
|
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_R1.ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.getTag() == null)
|
||||||
|
{
|
||||||
|
stack.setTag(new NBTTagCompound());
|
||||||
|
}
|
||||||
|
NBTTagList attr = stack.getTag().getList("AttributeModifiers", 10);
|
||||||
|
if (attr == null)
|
||||||
|
{
|
||||||
|
stack.getTag().set("AttributeModifiers", new NBTTagList());
|
||||||
|
}
|
||||||
|
return stack.getTag().getList("AttributeModifiers", 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
118
src/main/java/me/totalfreedom/totalfreedommod/Muter.java
Normal file
118
src/main/java/me/totalfreedom/totalfreedommod/Muter.java
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
|
public class Muter extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
||||||
|
public final List<String> MUTED_PLAYERS = new ArrayList<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
|
if (!fPlayer.isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.sl.isStaffSync(player))
|
||||||
|
{
|
||||||
|
fPlayer.setMuted(false);
|
||||||
|
MUTED_PLAYERS.remove(player.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
|
||||||
|
// Block commands if player is muted
|
||||||
|
if (!fPlayer.isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = event.getMessage();
|
||||||
|
if (plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
fPlayer.setMuted(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmdName = message.split(" ")[0].toLowerCase();
|
||||||
|
if (cmdName.startsWith("/"))
|
||||||
|
{
|
||||||
|
cmdName = cmdName.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Command command = server.getPluginCommand(cmdName);
|
||||||
|
if (command != null)
|
||||||
|
{
|
||||||
|
cmdName = command.getName().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MUTE_COMMANDS.contains(cmdName))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Should this go here?
|
||||||
|
if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean())
|
||||||
|
{
|
||||||
|
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (MUTED_PLAYERS.contains(player.getName()))
|
||||||
|
{
|
||||||
|
playerdata.setMuted(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
40
src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java
Normal file
40
src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class Orbiter extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (!fPlayer.isOrbiting())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.getVelocity().length() < fPlayer.orbitStrength() * (2.0 / 3.0))
|
||||||
|
{
|
||||||
|
player.setVelocity(new Vector(0, fPlayer.orbitStrength(), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
223
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
223
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.dean.jraw.ApiException;
|
||||||
|
import net.dean.jraw.RedditClient;
|
||||||
|
import net.dean.jraw.http.OkHttpNetworkAdapter;
|
||||||
|
import net.dean.jraw.http.UserAgent;
|
||||||
|
import net.dean.jraw.models.CurrentFlair;
|
||||||
|
import net.dean.jraw.models.Flair;
|
||||||
|
import net.dean.jraw.oauth.Credentials;
|
||||||
|
import net.dean.jraw.oauth.OAuthHelper;
|
||||||
|
import net.dean.jraw.references.SubredditReference;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Reddit extends FreedomService
|
||||||
|
{
|
||||||
|
private final String SUBREDDIT_NAME = ConfigEntry.REDDIT_SUBREDDIT_NAME.getString();
|
||||||
|
private final String USERNAME = ConfigEntry.REDDIT_USERNAME.getString();
|
||||||
|
private final String PASSWORD = ConfigEntry.REDDIT_PASSWORD.getString();
|
||||||
|
private final String CLIENT_ID = ConfigEntry.REDDIT_CLIENT_ID.getString();
|
||||||
|
private final String CLIENT_SECRET = ConfigEntry.REDDIT_CLIENT_SECRET.getString();
|
||||||
|
|
||||||
|
private final UserAgent userAgent = new UserAgent("bot", "me.totalfreedom.reddit", plugin.build.version, USERNAME);
|
||||||
|
private final Credentials credentials = Credentials.script(USERNAME, PASSWORD, CLIENT_ID, CLIENT_SECRET);
|
||||||
|
|
||||||
|
private RedditClient reddit = null;
|
||||||
|
private SubredditReference subreddit = null;
|
||||||
|
|
||||||
|
private HashMap<String, PlayerData> linkCodes = new HashMap<>();
|
||||||
|
private HashMap<PlayerData, String> pending = new HashMap<>();
|
||||||
|
|
||||||
|
private Map<Displayable, String> flairList = new HashMap<>();
|
||||||
|
|
||||||
|
private Map<Displayable, String> flairNameList = new HashMap<>();
|
||||||
|
|
||||||
|
private List<Displayable> noFlairDisplays = Arrays.asList(Title.VERIFIED_STAFF, Rank.IMPOSTOR, Rank.NON_OP, Rank.OP);
|
||||||
|
|
||||||
|
public boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
enabled = ConfigEntry.REDDIT_CLIENT_ID.getString() == null;
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reddit == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reddit = OAuthHelper.automatic(new OkHttpNetworkAdapter(userAgent), credentials);
|
||||||
|
reddit.setLogHttp(FUtil.inDeveloperMode());
|
||||||
|
}
|
||||||
|
catch (NoClassDefFoundError e)
|
||||||
|
{
|
||||||
|
FLog.warning("The JRAW plugin is not installed, therefore the Reddit service cannot start.");
|
||||||
|
FLog.warning("To resolve this error, please download the latest JRAW from: https://github.com/TFPatches/Minecraft-JRAW/releases");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (NullPointerException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid Reddit credentials specified, please double check everything in the config.");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subreddit == null)
|
||||||
|
{
|
||||||
|
subreddit = reddit.subreddit(SUBREDDIT_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadFlairList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlair(String username, String flairID)
|
||||||
|
{
|
||||||
|
List<Flair> flairs = subreddit.userFlairOptions();
|
||||||
|
Flair flair = null;
|
||||||
|
for (Flair f : flairs)
|
||||||
|
{
|
||||||
|
if (f.getId().equals(flairID))
|
||||||
|
{
|
||||||
|
flair = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flair == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
subreddit.otherUserFlair(username).updateToTemplate(flair.getId(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFlair(String username)
|
||||||
|
{
|
||||||
|
subreddit.otherUserFlair(username).updateToTemplate("", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendModMessage(String username, String subject, String body) throws ApiException
|
||||||
|
{
|
||||||
|
reddit.me().inbox().compose("/r/" + SUBREDDIT_NAME, username, subject, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String addLinkCode(PlayerData data, String username)
|
||||||
|
{
|
||||||
|
String code = FUtil.randomAlphanumericString(10);
|
||||||
|
linkCodes.put(code, data);
|
||||||
|
pending.put(data, username);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String checkLinkCode(String code)
|
||||||
|
{
|
||||||
|
PlayerData data = linkCodes.get(code);
|
||||||
|
String username = pending.get(data);
|
||||||
|
if (data == null || username == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
linkCodes.remove(code);
|
||||||
|
pending.remove(data);
|
||||||
|
|
||||||
|
data.setRedditUsername(username);
|
||||||
|
plugin.pl.save(data);
|
||||||
|
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateFlair(Player player)
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
String username = data.getRedditUsername();
|
||||||
|
Displayable display = plugin.rm.getDisplay(player);
|
||||||
|
if (username == null)
|
||||||
|
{
|
||||||
|
FLog.debug("No Reddit account");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentFlair currentFlair = subreddit.otherUserFlair(username).current();
|
||||||
|
String currentFlairName = currentFlair.getText();
|
||||||
|
String currentFlairID = currentFlair.getId();
|
||||||
|
String neededFlairID = flairList.get(display);
|
||||||
|
String neededFlairName = flairNameList.get(display);
|
||||||
|
|
||||||
|
FLog.debug("Current ID: " + currentFlairID);
|
||||||
|
FLog.debug("Needed ID: " + neededFlairID);
|
||||||
|
|
||||||
|
FLog.debug("Current Name: " + currentFlairName);
|
||||||
|
FLog.debug("Needed Name: " + neededFlairName);
|
||||||
|
|
||||||
|
|
||||||
|
// Work around
|
||||||
|
//if (currentFlairID == null && neededFlairID != null || currentFlairID != null && neededFlairID != null && !currentFlairID.equals(neededFlairID))
|
||||||
|
if (Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null || !Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null && !currentFlairName.equals(neededFlairName))
|
||||||
|
{
|
||||||
|
FLog.debug("Setting flair");
|
||||||
|
setFlair(username, neededFlairID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noFlairDisplays.contains(display) && !Strings.isNullOrEmpty(currentFlairName))
|
||||||
|
{
|
||||||
|
FLog.debug("Removing flair");
|
||||||
|
removeFlair(username);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFlairList()
|
||||||
|
{
|
||||||
|
flairList.put(Title.OWNER, ConfigEntry.REDDIT_SERVER_OWNER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.EXECUTIVE, ConfigEntry.REDDIT_EXECUTIVE_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.ASSISTANT_EXECUTIVE, ConfigEntry.REDDIT_ASSISTANT_EXECUTIVE_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.DEVELOPER, ConfigEntry.REDDIT_DEVELOPER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.ADMIN, ConfigEntry.REDDIT_ADMIN_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.MOD, ConfigEntry.REDDIT_MOD_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.TRIAL_MOD, ConfigEntry.REDDIT_TRIAL_MOD_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.MASTER_BUILDER, ConfigEntry.REDDIT_MASTER_BUILDER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.DONATOR, ConfigEntry.REDDIT_DONATOR_FLAIR_ID.getString());
|
||||||
|
|
||||||
|
// Work around because the current flair id keeps returning null, either a JRAW bug or a reddit bug
|
||||||
|
flairNameList.put(Title.OWNER, "Server Owner");
|
||||||
|
flairNameList.put(Title.EXECUTIVE, "Executive");
|
||||||
|
flairNameList.put(Title.ASSISTANT_EXECUTIVE, "Assistant Executive");
|
||||||
|
flairNameList.put(Title.DEVELOPER, "Developer");
|
||||||
|
flairNameList.put(Rank.ADMIN, "Admin");
|
||||||
|
flairNameList.put(Rank.MOD, "Mod");
|
||||||
|
flairNameList.put(Rank.TRIAL_MOD, "Trial Mod");
|
||||||
|
flairNameList.put(Title.MASTER_BUILDER, "Master Builder");
|
||||||
|
flairNameList.put(Title.DONATOR, "Premium");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
||||||
|
|
||||||
|
public class SavedFlags extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map<String, Boolean> getSavedFlags()
|
||||||
|
{
|
||||||
|
Map<String, Boolean> flags = null;
|
||||||
|
|
||||||
|
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||||
|
if (input.exists())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis))
|
||||||
|
{
|
||||||
|
flags = (HashMap<String, Boolean>)ois.readObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSavedFlag(String flag) throws Exception
|
||||||
|
{
|
||||||
|
Boolean flagValue = null;
|
||||||
|
|
||||||
|
Map<String, Boolean> flags = getSavedFlags();
|
||||||
|
|
||||||
|
if (flags != null)
|
||||||
|
{
|
||||||
|
if (flags.containsKey(flag))
|
||||||
|
{
|
||||||
|
flagValue = flags.get(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flagValue != null)
|
||||||
|
{
|
||||||
|
return flagValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSavedFlag(String flag, boolean value)
|
||||||
|
{
|
||||||
|
Map<String, Boolean> flags = getSavedFlags();
|
||||||
|
|
||||||
|
if (flags == null)
|
||||||
|
{
|
||||||
|
flags = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.put(flag, value);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), SAVED_FLAGS_FILENAME));
|
||||||
|
final ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
|
oos.writeObject(flags);
|
||||||
|
oos.close();
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.minecraft.server.v1_16_R1.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_16_R1.MinecraftServer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.CraftServer;
|
||||||
|
|
||||||
|
public class ServerInterface extends FreedomService
|
||||||
|
{
|
||||||
|
public static final String COMPILE_NMS_VERSION = "v1_16_R1";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warnVersion()
|
||||||
|
{
|
||||||
|
final String nms = FUtil.getNMSVersion();
|
||||||
|
|
||||||
|
if (!COMPILE_NMS_VERSION.equals(nms))
|
||||||
|
{
|
||||||
|
FLog.warning(TotalFreedomMod.pluginName + " is compiled for " + COMPILE_NMS_VERSION + " but the server is running version " + nms + "!");
|
||||||
|
FLog.warning("This might result in unexpected behaviour!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOnlineMode(boolean mode)
|
||||||
|
{
|
||||||
|
getServer().setOnlineMode(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int purgeWhitelist()
|
||||||
|
{
|
||||||
|
String[] whitelisted = getServer().getPlayerList().getWhitelisted();
|
||||||
|
int size = whitelisted.length;
|
||||||
|
for (EntityPlayer player : getServer().getPlayerList().players)
|
||||||
|
{
|
||||||
|
getServer().getPlayerList().getWhitelist().remove(player.getProfile());
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
getServer().getPlayerList().getWhitelist().save();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.warning("Could not purge the whitelist!");
|
||||||
|
FLog.warning(ex);
|
||||||
|
}
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelisted()
|
||||||
|
{
|
||||||
|
return getServer().getPlayerList().getHasWhitelist();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<?> getWhitelisted()
|
||||||
|
{
|
||||||
|
return Arrays.asList(getServer().getPlayerList().getWhitelisted());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion()
|
||||||
|
{
|
||||||
|
return getServer().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
private MinecraftServer getServer()
|
||||||
|
{
|
||||||
|
return ((CraftServer)Bukkit.getServer()).getServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,77 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
|
||||||
|
public class ServerPing extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onServerPing(ServerListPingEvent event)
|
||||||
|
{
|
||||||
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
|
if (plugin.bm.isIpBanned(ip))
|
||||||
|
{
|
||||||
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_BAN_MOTD.getString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_STAFFMODE_MOTD.getString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LoginProcess.isLockdownEnabled())
|
||||||
|
{
|
||||||
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_LOCKDOWN_MOTD.getString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bukkit.hasWhitelist())
|
||||||
|
{
|
||||||
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_WHITELIST_MOTD.getString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
||||||
|
{
|
||||||
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_FULL_MOTD.getString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
||||||
|
baseMotd = baseMotd.replace("\\n", "\n");
|
||||||
|
baseMotd = FUtil.colorize(baseMotd);
|
||||||
|
|
||||||
|
if (!ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
|
||||||
|
{
|
||||||
|
event.setMotd(baseMotd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Colorful MOTD
|
||||||
|
final StringBuilder motd = new StringBuilder();
|
||||||
|
for (String word : baseMotd.split(" "))
|
||||||
|
{
|
||||||
|
motd.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setMotd(motd.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,358 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.PVPBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.SignBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.FAWEBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.CurseListener;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
|
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.punishments.PunishmentList;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||||
|
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||||
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.ActivityLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffList;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||||
|
import org.bstats.Metrics;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
|
{
|
||||||
|
private static TotalFreedomMod plugin;
|
||||||
|
|
||||||
|
public static TotalFreedomMod getPlugin()
|
||||||
|
{
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
|
//
|
||||||
|
public static final BuildProperties build = new BuildProperties();
|
||||||
|
//
|
||||||
|
public static String pluginName;
|
||||||
|
public static String pluginVersion;
|
||||||
|
//
|
||||||
|
public MainConfig config;
|
||||||
|
public PermissionConfig permissions;
|
||||||
|
//
|
||||||
|
// Service Handler
|
||||||
|
public FreedomServiceHandler fsh;
|
||||||
|
// Command Loader
|
||||||
|
public CommandLoader cl;
|
||||||
|
// Services
|
||||||
|
public ServerInterface si;
|
||||||
|
public SavedFlags sf;
|
||||||
|
public WorldManager wm;
|
||||||
|
public LogViewer lv;
|
||||||
|
public StaffList sl;
|
||||||
|
public ActivityLog acl;
|
||||||
|
public RankManager rm;
|
||||||
|
public CommandBlocker cb;
|
||||||
|
public EventBlocker eb;
|
||||||
|
public BlockBlocker bb;
|
||||||
|
public MobBlocker mb;
|
||||||
|
public InteractBlocker ib;
|
||||||
|
public PotionBlocker pb;
|
||||||
|
public LoginProcess lp;
|
||||||
|
public AntiNuke nu;
|
||||||
|
public AntiSpam as;
|
||||||
|
public PlayerList pl;
|
||||||
|
public Shop sh;
|
||||||
|
public Votifier vo;
|
||||||
|
public SQLite sql;
|
||||||
|
public Announcer an;
|
||||||
|
public ChatManager cm;
|
||||||
|
public Discord dc;
|
||||||
|
public PunishmentList pul;
|
||||||
|
public BanManager bm;
|
||||||
|
public IndefiniteBanList im;
|
||||||
|
public PermissionManager pem;
|
||||||
|
public Reddit rd;
|
||||||
|
public GameRuleHandler gr;
|
||||||
|
public CommandSpy cs;
|
||||||
|
public Cager ca;
|
||||||
|
public Freezer fm;
|
||||||
|
public EditBlocker ebl;
|
||||||
|
public PVPBlocker pbl;
|
||||||
|
public Orbiter or;
|
||||||
|
public Muter mu;
|
||||||
|
public Fuckoff fo;
|
||||||
|
public AutoKick ak;
|
||||||
|
public AutoEject ae;
|
||||||
|
public Monitors mo;
|
||||||
|
public MovementValidator mv;
|
||||||
|
public ServerPing sp;
|
||||||
|
public CurseListener cul;
|
||||||
|
public ItemFun it;
|
||||||
|
public Landminer lm;
|
||||||
|
public MP44 mp;
|
||||||
|
public Jumppads jp;
|
||||||
|
public Trailer tr;
|
||||||
|
public HTTPDaemon hd;
|
||||||
|
public WorldRestrictions wr;
|
||||||
|
public SignBlocker snp;
|
||||||
|
public EntityWiper ew;
|
||||||
|
public Sitter st;
|
||||||
|
public VanishHandler vh;
|
||||||
|
public AMP amp;
|
||||||
|
|
||||||
|
//public HubWorldRestrictions hwr;
|
||||||
|
//
|
||||||
|
// Bridges
|
||||||
|
public BukkitTelnetBridge btb;
|
||||||
|
public EssentialsBridge esb;
|
||||||
|
public LibsDisguisesBridge ldb;
|
||||||
|
public CoreProtectBridge cpb;
|
||||||
|
public TFGuildsBridge tfg;
|
||||||
|
public WorldEditBridge web;
|
||||||
|
public FAWEBridge fab;
|
||||||
|
public WorldGuardBridge wgb;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad()
|
||||||
|
{
|
||||||
|
plugin = this;
|
||||||
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
||||||
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
|
FLog.setPluginLogger(plugin.getLogger());
|
||||||
|
FLog.setServerLogger(getServer().getLogger());
|
||||||
|
|
||||||
|
build.load(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable()
|
||||||
|
{
|
||||||
|
FLog.info("Created by Madgeek1450 and Prozza");
|
||||||
|
FLog.info("Version " + build.version);
|
||||||
|
FLog.info("Compiled " + build.date + " by " + build.author);
|
||||||
|
|
||||||
|
final MethodTimer timer = new MethodTimer();
|
||||||
|
timer.start();
|
||||||
|
|
||||||
|
// Warn if we're running on a wrong version
|
||||||
|
ServerInterface.warnVersion();
|
||||||
|
|
||||||
|
// Delete unused files
|
||||||
|
FUtil.deleteCoreDumps();
|
||||||
|
FUtil.deleteFolder(new File("./_deleteme"));
|
||||||
|
|
||||||
|
fsh = new FreedomServiceHandler();
|
||||||
|
|
||||||
|
config = new MainConfig();
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
if (FUtil.inDeveloperMode())
|
||||||
|
{
|
||||||
|
FLog.debug("Developer mode enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
cl = new CommandLoader();
|
||||||
|
cl.loadCommands();
|
||||||
|
|
||||||
|
BackupManager backups = new BackupManager();
|
||||||
|
backups.createAllBackups();
|
||||||
|
|
||||||
|
permissions = new PermissionConfig(this);
|
||||||
|
permissions.load();
|
||||||
|
|
||||||
|
// Start services
|
||||||
|
si = new ServerInterface();
|
||||||
|
sf = new SavedFlags();
|
||||||
|
wm = new WorldManager();
|
||||||
|
lv = new LogViewer();
|
||||||
|
sql = new SQLite();
|
||||||
|
sl = new StaffList();
|
||||||
|
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();
|
||||||
|
rd = new Reddit();
|
||||||
|
gr = new GameRuleHandler();
|
||||||
|
snp = new SignBlocker();
|
||||||
|
ew = new EntityWiper();
|
||||||
|
st = new Sitter();
|
||||||
|
vh = new VanishHandler();
|
||||||
|
amp = new AMP();
|
||||||
|
|
||||||
|
// 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();
|
||||||
|
|
||||||
|
mv = new MovementValidator();
|
||||||
|
sp = new ServerPing();
|
||||||
|
|
||||||
|
// Fun
|
||||||
|
cul = new CurseListener();
|
||||||
|
it = new ItemFun();
|
||||||
|
lm = new Landminer();
|
||||||
|
mp = new MP44();
|
||||||
|
jp = new Jumppads();
|
||||||
|
tr = new Trailer();
|
||||||
|
// HTTPD
|
||||||
|
hd = new HTTPDaemon();
|
||||||
|
|
||||||
|
// Start bridges
|
||||||
|
btb = new BukkitTelnetBridge();
|
||||||
|
cpb = new CoreProtectBridge();
|
||||||
|
esb = new EssentialsBridge();
|
||||||
|
ldb = new LibsDisguisesBridge();
|
||||||
|
tfg = new TFGuildsBridge();
|
||||||
|
web = new WorldEditBridge();
|
||||||
|
fab = new FAWEBridge();
|
||||||
|
wgb = new WorldGuardBridge();
|
||||||
|
|
||||||
|
fsh.startServices();
|
||||||
|
|
||||||
|
FLog.info("Started " + fsh.getServiceAmount() + " services.");
|
||||||
|
|
||||||
|
timer.update();
|
||||||
|
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
|
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
||||||
|
new Metrics(this, 2966);
|
||||||
|
|
||||||
|
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
||||||
|
SpigotConfig.config.set("settings.restart-on-crash", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable()
|
||||||
|
{
|
||||||
|
// Stop services and bridges
|
||||||
|
fsh.stopServices();
|
||||||
|
|
||||||
|
getServer().getScheduler().cancelTasks(plugin);
|
||||||
|
|
||||||
|
FLog.info("Plugin disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BuildProperties
|
||||||
|
{
|
||||||
|
public String author;
|
||||||
|
public String codename;
|
||||||
|
public String version;
|
||||||
|
public String number;
|
||||||
|
public String date;
|
||||||
|
public String head;
|
||||||
|
|
||||||
|
public void load(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Properties props;
|
||||||
|
|
||||||
|
try (InputStream in = plugin.getResource("build.properties"))
|
||||||
|
{
|
||||||
|
props = new Properties();
|
||||||
|
props.load(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
author = props.getProperty("buildAuthor", "unknown");
|
||||||
|
codename = props.getProperty("buildCodeName", "unknown");
|
||||||
|
version = props.getProperty("buildVersion", pluginVersion);
|
||||||
|
number = props.getProperty("buildNumber", "1");
|
||||||
|
date = props.getProperty("buildDate", "unknown");
|
||||||
|
// 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)
|
||||||
|
{
|
||||||
|
FLog.severe("Could not load build properties! Did you compile with NetBeans/Maven?");
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formattedVersion()
|
||||||
|
{
|
||||||
|
return pluginVersion + "." + number + " (" + head + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TotalFreedomMod plugin()
|
||||||
|
{
|
||||||
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
||||||
|
{
|
||||||
|
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||||
|
{
|
||||||
|
return (TotalFreedomMod)plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||||
|
{
|
||||||
|
return new CleanroomChunkGenerator(id);
|
||||||
|
}
|
||||||
|
}
|
@ -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.sl.isStaff(player) && plugin.sl.isVanished(p.getName()))
|
||||||
|
{
|
||||||
|
player.hidePlayer(plugin, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.sl.isStaff(p) && plugin.sl.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
p.hidePlayer(plugin, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.sl.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
plugin.esb.setVanished(player.getName(), true);
|
||||||
|
FLog.info(player.getName() + " joined while still vanished.");
|
||||||
|
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||||
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!plugin.sl.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.sl.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
FLog.info(player.getName() + " left while still vanished.");
|
||||||
|
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
268
src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java
Normal file
268
src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Ban
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String username = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private UUID uuid = null;
|
||||||
|
@Getter
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String by = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Date at = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private long expiryUnix = -1;
|
||||||
|
|
||||||
|
public Ban()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban(String username, UUID uuid, String ip, String by, Date at, Date expire, String reason)
|
||||||
|
{
|
||||||
|
this(username,
|
||||||
|
uuid,
|
||||||
|
Arrays.asList(ip),
|
||||||
|
by,
|
||||||
|
at,
|
||||||
|
expire,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban(String username, UUID uuid, List<String> ips, String by, Date at, Date expire, String reason)
|
||||||
|
{
|
||||||
|
this.username = username;
|
||||||
|
this.uuid = uuid;
|
||||||
|
if (ips != null)
|
||||||
|
{
|
||||||
|
this.ips.addAll(ips);
|
||||||
|
}
|
||||||
|
dedupeIps();
|
||||||
|
this.by = by;
|
||||||
|
this.at = at;
|
||||||
|
this.expiryUnix = FUtil.getUnixTime(expire);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// For player IP
|
||||||
|
public static Ban forPlayerIp(Player player, CommandSender by)
|
||||||
|
{
|
||||||
|
return forPlayerIp(player, by, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(null, null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(null, null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// For player name
|
||||||
|
public static Ban forPlayerName(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return forPlayerName(player.getName(), by, expiry, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(player,
|
||||||
|
null,
|
||||||
|
new ArrayList<>(),
|
||||||
|
by.getName(),
|
||||||
|
Date.from(Instant.now()),
|
||||||
|
expiry,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// For player
|
||||||
|
public static Ban forPlayer(Player player, CommandSender by)
|
||||||
|
{
|
||||||
|
return forPlayerName(player, by, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(player.getName(),
|
||||||
|
player.getUniqueId(),
|
||||||
|
FUtil.getIp(player),
|
||||||
|
by.getName(),
|
||||||
|
Date.from(Instant.now()),
|
||||||
|
expiry,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(player.getName(),
|
||||||
|
player.getUniqueId(),
|
||||||
|
FUtil.getFuzzyIp(FUtil.getIp(player)),
|
||||||
|
by.getName(),
|
||||||
|
Date.from(Instant.now()),
|
||||||
|
expiry,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUsername()
|
||||||
|
{
|
||||||
|
return username != null && !username.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUUID()
|
||||||
|
{
|
||||||
|
return uuid != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addIp(String ip)
|
||||||
|
{
|
||||||
|
return ips.add(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeIp(String ip)
|
||||||
|
{
|
||||||
|
return ips.remove(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasIps()
|
||||||
|
{
|
||||||
|
return !ips.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExpiry()
|
||||||
|
{
|
||||||
|
return expiryUnix > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExpired()
|
||||||
|
{
|
||||||
|
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String bakeKickMessage()
|
||||||
|
{
|
||||||
|
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
||||||
|
|
||||||
|
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)
|
||||||
|
.append(ConfigEntry.SERVER_BAN_URL.getString());
|
||||||
|
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Reason: ").append(ChatColor.GOLD)
|
||||||
|
.append(ChatColor.translateAlternateColorCodes('&', reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (by != null)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Banned by: ").append(ChatColor.GOLD)
|
||||||
|
.append(by);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (at != null)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Issued: ").append(ChatColor.GOLD)
|
||||||
|
.append(DATE_FORMAT.format(at));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getExpiryUnix() != 0)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
|
||||||
|
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object)
|
||||||
|
{
|
||||||
|
if (object == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(object instanceof Ban))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Ban ban = (Ban)object;
|
||||||
|
if (hasIps() != ban.hasIps()
|
||||||
|
|| hasUsername() != ban.hasUsername())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasIps() && !(getIps().equals(ban.getIps())))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dedupeIps()
|
||||||
|
{
|
||||||
|
|
||||||
|
Set<String> uniqueIps = new HashSet<>();
|
||||||
|
|
||||||
|
Iterator<String> it = ips.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
if (!uniqueIps.add(it.next()))
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,332 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
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.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
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 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.PlayerLoginEvent;
|
||||||
|
|
||||||
|
public class BanManager extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Set<Ban> bans = Sets.newHashSet();
|
||||||
|
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();
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
bans.clear();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet banSet = plugin.sql.getBanList();
|
||||||
|
{
|
||||||
|
while (banSet.next())
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load ban list: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove expired bans, repopulate ipBans and nameBans,
|
||||||
|
updateViews();
|
||||||
|
|
||||||
|
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
||||||
|
|
||||||
|
// Load unbannable usernames
|
||||||
|
unbannableUsernames.clear();
|
||||||
|
unbannableUsernames.addAll((Collection<? extends String>)ConfigEntry.FAMOUS_PLAYERS.getList());
|
||||||
|
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Ban> getAllBans()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableSet(bans);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Ban> getIpBans()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableCollection(ipBans.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Ban> getUsernameBans()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableCollection(nameBans.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban getByIp(String ip)
|
||||||
|
{
|
||||||
|
final Ban directBan = ipBans.get(ip);
|
||||||
|
if (directBan != null && !directBan.isExpired())
|
||||||
|
{
|
||||||
|
return directBan;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match fuzzy IP
|
||||||
|
for (Ban loopBan : ipBans.values())
|
||||||
|
{
|
||||||
|
if (loopBan.isExpired())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String loopIp : loopBan.getIps())
|
||||||
|
{
|
||||||
|
if (!loopIp.contains("*"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FUtil.fuzzyIpMatch(ip, loopIp, 4))
|
||||||
|
{
|
||||||
|
return loopBan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban getByUsername(String username)
|
||||||
|
{
|
||||||
|
username = username.toLowerCase();
|
||||||
|
final Ban directBan = nameBans.get(username);
|
||||||
|
|
||||||
|
if (directBan != null && !directBan.isExpired())
|
||||||
|
{
|
||||||
|
return directBan;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
final Ban ban = getByIp(ip);
|
||||||
|
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
bans.remove(ban);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ban;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban unbanUsername(String username)
|
||||||
|
{
|
||||||
|
final Ban ban = getByUsername(username);
|
||||||
|
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
bans.remove(ban);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ban;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIpBanned(String ip)
|
||||||
|
{
|
||||||
|
return getByIp(ip) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUsernameBanned(String username)
|
||||||
|
{
|
||||||
|
return getByUsername(username) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addBan(Ban ban)
|
||||||
|
{
|
||||||
|
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
for (String ip : ban.getIps())
|
||||||
|
{
|
||||||
|
if (getByIp(ip) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bans.add(ban))
|
||||||
|
{
|
||||||
|
plugin.sql.addBan(ban);
|
||||||
|
updateViews();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeBan(Ban ban)
|
||||||
|
{
|
||||||
|
if (bans.remove(ban))
|
||||||
|
{
|
||||||
|
plugin.sql.removeBan(ban);
|
||||||
|
updateViews();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int purge()
|
||||||
|
{
|
||||||
|
int size = bans.size();
|
||||||
|
bans.clear();
|
||||||
|
updateViews();
|
||||||
|
plugin.sql.truncate("bans");
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final String username = event.getPlayer().getName();
|
||||||
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
final String ip = FUtil.getIp(event);
|
||||||
|
|
||||||
|
// Regular ban
|
||||||
|
Ban ban = getByUsername(username);
|
||||||
|
if (ban == null)
|
||||||
|
{
|
||||||
|
ban = getByUUID(uuid);
|
||||||
|
|
||||||
|
if (ban == null)
|
||||||
|
{
|
||||||
|
ban = getByIp(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban != null && !ban.isExpired())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final PlayerData data = plugin.pl.getData(player);
|
||||||
|
|
||||||
|
if (!plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unban admins
|
||||||
|
Ban ban = getByUsername(player.getName());
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ban = getByIp(FUtil.getIp(player));
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateViews()
|
||||||
|
{
|
||||||
|
// Remove expired bans
|
||||||
|
for (Ban ban : new ArrayList<>(bans))
|
||||||
|
{
|
||||||
|
if (ban.isExpired())
|
||||||
|
{
|
||||||
|
bans.remove(ban);
|
||||||
|
plugin.sql.removeBan(ban);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nameBans.clear();
|
||||||
|
uuidBans.clear();
|
||||||
|
ipBans.clear();
|
||||||
|
for (Ban ban : bans)
|
||||||
|
{
|
||||||
|
if (ban.hasUsername())
|
||||||
|
{
|
||||||
|
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban.hasUUID())
|
||||||
|
{
|
||||||
|
uuidBans.put(ban.getUuid(), ban);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban.hasIps())
|
||||||
|
{
|
||||||
|
for (String ip : ban.getIps())
|
||||||
|
{
|
||||||
|
ipBans.put(ip, ban);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public class IndefiniteBan implements IConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String username = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private UUID uuid = null;
|
||||||
|
@Getter
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
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 lombok.Getter;
|
||||||
|
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";
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int nameBanCount = 0;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int uuidBanCount = 0;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int ipBanCount = 0;
|
||||||
|
|
||||||
|
@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);
|
||||||
|
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.toLowerCase().equals(indefBan.getUsername().toLowerCase()))
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,186 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
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.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
|
public class BlockBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
switch (event.getBlockPlaced().getType())
|
||||||
|
{
|
||||||
|
case LAVA:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WATER:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FIRE:
|
||||||
|
case SOUL_FIRE:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRUCTURE_BLOCK:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
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));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
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,62 @@
|
|||||||
|
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.sl.isStaffSync(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.sl.isStaffSync(event.getPlayer()))
|
||||||
|
{
|
||||||
|
fPlayer.setEditBlocked(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,258 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
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.Tameable;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
|
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.BlockRedstoneEvent;
|
||||||
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
|
import org.bukkit.event.entity.FireworkExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
public class EventBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockBurn(BlockBurnEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockIgnite(BlockIgniteEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockFromTo(BlockFromToEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
event.blockList().clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setYield(0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityCombust(EntityCombustEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityDeath(EntityDeathEvent event)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setDroppedExp(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
|
{
|
||||||
|
switch (event.getCause())
|
||||||
|
{
|
||||||
|
case LAVA:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
||||||
|
{
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
if (entity instanceof Tameable)
|
||||||
|
{
|
||||||
|
if (((Tameable)entity).isTamed())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
|
{
|
||||||
|
if (!plugin.sl.isStaff(event.getPlayer()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getPlayer().getWorld().getEntities().size() > 750)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onLeavesDecay(LeavesDecayEvent event)
|
||||||
|
{
|
||||||
|
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(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockRedstone(BlockRedstoneEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setNewCurrent(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
|
||||||
|
private ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
|
||||||
|
@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 = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
|
if (maxHealth < 1)
|
||||||
|
{
|
||||||
|
for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers())
|
||||||
|
{
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,163 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class InteractBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
switch (event.getAction())
|
||||||
|
{
|
||||||
|
case RIGHT_CLICK_AIR:
|
||||||
|
case RIGHT_CLICK_BLOCK:
|
||||||
|
{
|
||||||
|
handleRightClick(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LEFT_CLICK_AIR:
|
||||||
|
case LEFT_CLICK_BLOCK:
|
||||||
|
{
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
{
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
case WATER_BUCKET:
|
||||||
|
{
|
||||||
|
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LAVA_BUCKET:
|
||||||
|
{
|
||||||
|
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case TNT_MINECART:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,133 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
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.EnderDragon;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.Giant;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.Wither;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
|
|
||||||
|
public class MobBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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 (((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0)
|
||||||
|
{
|
||||||
|
((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0);
|
||||||
|
}
|
||||||
|
if (((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0)
|
||||||
|
{
|
||||||
|
((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(10.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Entity spawned = event.getEntity();
|
||||||
|
|
||||||
|
if (spawned instanceof EnderDragon)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Ghast)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Slime)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Wither)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Giant)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Bat)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger();
|
||||||
|
|
||||||
|
if (mobLimiterMax <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mobcount = 0;
|
||||||
|
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
||||||
|
{
|
||||||
|
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
||||||
|
{
|
||||||
|
mobcount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mobcount > mobLimiterMax)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
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.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 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.sl.isStaff(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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,86 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
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;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
|
public class PotionBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onThrowPotion(PotionSplashEvent 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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,66 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import net.minecraft.server.v1_16_R1.NBTTagCompound;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Tag;
|
||||||
|
import org.bukkit.craftbukkit.v1_16_R1.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_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||||
|
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,226 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
|
|
||||||
|
public class CommandBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
|
||||||
|
//
|
||||||
|
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||||
|
private final List<String> unknownCommands = Lists.newArrayList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
entryList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandMap getCommandMap()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SimplePluginManager simplePluginManager = (SimplePluginManager) Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||||
|
commandMapField.setAccessible(true);
|
||||||
|
|
||||||
|
SimpleCommandMap simpleCommandMap = (SimpleCommandMap) commandMapField.get(simplePluginManager);
|
||||||
|
return simpleCommandMap;
|
||||||
|
}
|
||||||
|
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load()
|
||||||
|
{
|
||||||
|
entryList.clear();
|
||||||
|
unknownCommands.clear();
|
||||||
|
|
||||||
|
final CommandMap commandMap = getCommandMap();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
|
||||||
|
for (String rawEntry : blockedCommands)
|
||||||
|
{
|
||||||
|
final String[] parts = rawEntry.split(":");
|
||||||
|
if (parts.length < 3 || parts.length > 4)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
|
||||||
|
final CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
|
||||||
|
String commandName = parts[2].toLowerCase().substring(1);
|
||||||
|
final String message = (parts.length > 3 ? parts[3] : null);
|
||||||
|
|
||||||
|
if (rank == null || action == null || commandName == null || commandName.isEmpty())
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] commandParts = commandName.split(" ");
|
||||||
|
String subCommand = null;
|
||||||
|
if (commandParts.length > 1)
|
||||||
|
{
|
||||||
|
commandName = commandParts[0];
|
||||||
|
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Command command = commandMap.getCommand(commandName);
|
||||||
|
|
||||||
|
// Obtain command from alias
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
unknownCommands.add(commandName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
commandName = command.getName().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entryList.containsKey(commandName))
|
||||||
|
{
|
||||||
|
FLog.warning("Not blocking: /" + commandName + " - Duplicate entry exists!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
|
||||||
|
entryList.put(commandName, blockedCommandEntry);
|
||||||
|
if (command != null)
|
||||||
|
{
|
||||||
|
for (String alias : command.getAliases())
|
||||||
|
{
|
||||||
|
entryList.put(alias.toLowerCase(), blockedCommandEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Loaded " + blockedCommands.size() + " blocked commands (" + (blockedCommands.size() - unknownCommands.size()) + " known).");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
// Blocked commands
|
||||||
|
if (isCommandBlocked(event.getMessage(), event.getPlayer(), true))
|
||||||
|
{
|
||||||
|
// CommandBlocker handles messages and broadcasts
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||||
|
{
|
||||||
|
return isCommandBlocked(command, sender, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||||
|
{
|
||||||
|
if (command == null || command.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format
|
||||||
|
command = command.toLowerCase().trim();
|
||||||
|
command = command.startsWith("/") ? command.substring(1) : command;
|
||||||
|
|
||||||
|
// Check for plugin specific commands
|
||||||
|
final String[] commandParts = command.split(" ");
|
||||||
|
if (commandParts[0].contains(":"))
|
||||||
|
{
|
||||||
|
if (doAction)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "Plugin specific commands are disabled.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String part : commandParts)
|
||||||
|
{
|
||||||
|
if (command.startsWith("/") && !plugin.sl.isStaff(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Matcher matcher = flagPattern.matcher(part);
|
||||||
|
if (!matcher.matches())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (doAction)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "That command contains an illegal number: " + matcher.group(1));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain sub command, if it exists
|
||||||
|
String subCommand = null;
|
||||||
|
if (commandParts.length > 1)
|
||||||
|
{
|
||||||
|
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain entry
|
||||||
|
final CommandBlockerEntry entry = entryList.get(commandParts[0]);
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate sub command
|
||||||
|
if (entry.getSubCommand() != null)
|
||||||
|
{
|
||||||
|
if (subCommand == null || !subCommand.startsWith(entry.getSubCommand()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.getRank().hasPermission(sender))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doAction)
|
||||||
|
{
|
||||||
|
entry.doActions(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
public enum CommandBlockerAction
|
||||||
|
{
|
||||||
|
|
||||||
|
BLOCK("b"),
|
||||||
|
BLOCK_AND_EJECT("a"),
|
||||||
|
BLOCK_UNKNOWN("u");
|
||||||
|
private final String token;
|
||||||
|
|
||||||
|
private CommandBlockerAction(String token)
|
||||||
|
{
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandBlockerAction fromToken(String token)
|
||||||
|
{
|
||||||
|
for (CommandBlockerAction action : CommandBlockerAction.values())
|
||||||
|
{
|
||||||
|
if (action.getToken().equalsIgnoreCase(token))
|
||||||
|
{
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
|
public class CommandBlockerEntry
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final CommandBlockerRank rank;
|
||||||
|
@Getter
|
||||||
|
private final CommandBlockerAction action;
|
||||||
|
@Getter
|
||||||
|
private final String command;
|
||||||
|
@Getter
|
||||||
|
private final String subCommand;
|
||||||
|
@Getter
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||||
|
{
|
||||||
|
this(rank, action, command, null, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String subCommand, String message)
|
||||||
|
{
|
||||||
|
this.rank = rank;
|
||||||
|
this.action = action;
|
||||||
|
this.command = command;
|
||||||
|
this.subCommand = ((subCommand == null) ? null : subCommand.toLowerCase().trim());
|
||||||
|
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doActions(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||||
|
{
|
||||||
|
TotalFreedomMod.plugin().ae.autoEject((Player)sender, "You used a prohibited command: " + command);
|
||||||
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
||||||
|
{
|
||||||
|
sender.sendMessage(SpigotConfig.unknownCommandMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FUtil.playerMsg(sender, FUtil.colorize(message));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public enum CommandBlockerRank
|
||||||
|
{
|
||||||
|
|
||||||
|
ANYONE("a"),
|
||||||
|
OP("o"),
|
||||||
|
SUPER("s"),
|
||||||
|
TELNET("t"),
|
||||||
|
SENIOR("c"),
|
||||||
|
NOBODY("n");
|
||||||
|
//
|
||||||
|
private final String token;
|
||||||
|
|
||||||
|
private CommandBlockerRank(String 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)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
return TELNET;
|
||||||
|
}
|
||||||
|
|
||||||
|
StaffMember staffMember = TotalFreedomMod.plugin().sl.getAdmin(sender);
|
||||||
|
if (staffMember != null)
|
||||||
|
{
|
||||||
|
if (staffMember.getRank() == Rank.ADMIN)
|
||||||
|
{
|
||||||
|
return SENIOR;
|
||||||
|
}
|
||||||
|
return SUPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender.isOp())
|
||||||
|
{
|
||||||
|
return OP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ANYONE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandBlockerRank fromToken(String token)
|
||||||
|
{
|
||||||
|
for (CommandBlockerRank rank : CommandBlockerRank.values())
|
||||||
|
{
|
||||||
|
if (rank.getToken().equalsIgnoreCase(token))
|
||||||
|
{
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ANYONE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,182 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||||
|
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class BukkitTelnetBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onTelnetPreLogin(TelnetPreLoginEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
final String ip = event.getIp();
|
||||||
|
if (ip == null || ip.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final StaffMember staffMember = plugin.sl.getEntryByIpFuzzy(ip);
|
||||||
|
|
||||||
|
if (staffMember == null || !staffMember.isActive() || !staffMember.getRank().hasConsoleVariant())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setBypassPassword(true);
|
||||||
|
event.setName(staffMember.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onTelnetCommand(TelnetCommandEvent event)
|
||||||
|
{
|
||||||
|
if (plugin.cb.isCommandBlocked(event.getCommand(), event.getSender()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
|
||||||
|
{
|
||||||
|
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final Map.Entry<Player, Map<String, Object>> entry = it.next();
|
||||||
|
final Player player = entry.getKey();
|
||||||
|
final Map<String, Object> playerTags = entry.getValue();
|
||||||
|
|
||||||
|
boolean isAdmin = false;
|
||||||
|
boolean isTelnetAdmin = false;
|
||||||
|
boolean isSeniorAdmin = false;
|
||||||
|
|
||||||
|
final StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||||
|
if (staffMember != null)
|
||||||
|
{
|
||||||
|
boolean active = staffMember.isActive();
|
||||||
|
|
||||||
|
isAdmin = active;
|
||||||
|
isSeniorAdmin = active && staffMember.getRank() == Rank.ADMIN;
|
||||||
|
isTelnetAdmin = active && (isSeniorAdmin || staffMember.getRank() == Rank.MOD);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||||
|
playerTags.put("tfm.admin.isTelnetAdmin", isTelnetAdmin);
|
||||||
|
playerTags.put("tfm.admin.isSeniorAdmin", isSeniorAdmin);
|
||||||
|
|
||||||
|
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
|
||||||
|
|
||||||
|
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<StaffMember> getConnectedAdmins()
|
||||||
|
{
|
||||||
|
List<StaffMember> staffMembers = new ArrayList<>();
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
for (ClientSession session : telnet.appender.getSessions())
|
||||||
|
{
|
||||||
|
StaffMember staffMember = plugin.sl.getEntryByName(session.getUserName().toLowerCase());
|
||||||
|
if (staffMember != null && !staffMembers.contains(staffMember))
|
||||||
|
{
|
||||||
|
staffMembers.add(staffMember);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return staffMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void killTelnetSessions(final String name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final List<ClientSession> sessionsToRemove = new ArrayList<>();
|
||||||
|
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
final Iterator<ClientSession> it = telnet.appender.getSessions().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final ClientSession session = it.next();
|
||||||
|
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,220 @@
|
|||||||
|
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.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.coreprotect.CoreProtect;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class CoreProtectBridge extends FreedomService
|
||||||
|
{
|
||||||
|
private CoreProtectAPI coreProtectAPI = null;
|
||||||
|
|
||||||
|
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
||||||
|
|
||||||
|
private BukkitTask wiper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreProtect getCoreProtect()
|
||||||
|
{
|
||||||
|
CoreProtect coreProtect = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
|
||||||
|
|
||||||
|
if (coreProtectPlugin != null && 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, Arrays.asList(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, Arrays.asList(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 = null;
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,218 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
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.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class EssentialsBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private Essentials essentialsPlugin = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Essentials getEssentialsPlugin()
|
||||||
|
{
|
||||||
|
if (essentialsPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
||||||
|
if (essentials != null && essentials instanceof Essentials)
|
||||||
|
{
|
||||||
|
essentialsPlugin = (Essentials)essentials;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return essentialsPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getEssentialsUser(String username)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Essentials essentials = getEssentialsPlugin();
|
||||||
|
if (essentials != null)
|
||||||
|
{
|
||||||
|
return essentials.getUserMap().getUser(username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickname(String username, String nickname)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User user = getEssentialsUser(username);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
user.setNickname(nickname);
|
||||||
|
user.setDisplayNick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickname(String username)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User user = getEssentialsUser(username);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
return user.getNickname();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLastActivity(String username)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User user = getEssentialsUser(username);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
return FUtil.getField(user, "lastActivity");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVanished(String username, boolean vanished)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
User user = getEssentialsUser(username);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
user.setVanished(vanished);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 != null && 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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,177 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
public class FAWEBridge extends FreedomService
|
||||||
|
{
|
||||||
|
private CoreProtectAPI api;
|
||||||
|
private World world = null;
|
||||||
|
private final Map<Map.Entry<String, EditSession>, Map<BlockVector3, String>> blocksBroken = new HashMap<>();
|
||||||
|
private final Map<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> blocksPlaced = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
api = plugin.cpb.getCoreProtectAPI();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Iterates over blocks placed by GenerationCommands (in the EditSession) and adds them to the CoreProtect logs.
|
||||||
|
*/
|
||||||
|
server.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!(blocksBroken.isEmpty() && blocksPlaced.isEmpty()))
|
||||||
|
{
|
||||||
|
// Send all broken blocks from the last ticks to the CoreProtect API.
|
||||||
|
Map.Entry<String, EditSession> playerAndSessionEntry = null;
|
||||||
|
for (Map.Entry<Map.Entry<String, EditSession>, Map<BlockVector3, String>> entry : blocksBroken.entrySet())
|
||||||
|
{
|
||||||
|
playerAndSessionEntry = entry.getKey();
|
||||||
|
Map<BlockVector3, String> dataAndVectorEntry = entry.getValue();
|
||||||
|
List<BlockVector3> blockVector3List = new ArrayList<>();
|
||||||
|
blockVector3List.addAll(dataAndVectorEntry.keySet()); // Deep clone the block vector to avoid a change later in the code.
|
||||||
|
|
||||||
|
for (BlockVector3 blockVector3 : blockVector3List)
|
||||||
|
{
|
||||||
|
if (blockVector3 != null)
|
||||||
|
{
|
||||||
|
EditSession editSession = playerAndSessionEntry.getValue();
|
||||||
|
World world = server.getWorld(editSession.getWorld().getName());
|
||||||
|
Location location = new Location(world, blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||||
|
BlockData blockData = server.createBlockData(dataAndVectorEntry.get(blockVector3));
|
||||||
|
api.logRemoval(playerAndSessionEntry.getKey(), location, blockData.getMaterial(), blockData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear after broken blocks have been updated.
|
||||||
|
blocksBroken.values().clear();
|
||||||
|
blocksBroken.putIfAbsent(playerAndSessionEntry, new HashMap<>());
|
||||||
|
|
||||||
|
// Send all blocks placed to the CoreProtect API (except from the air as it's only a broken block).
|
||||||
|
for (Map.Entry<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> entry : blocksPlaced.entrySet())
|
||||||
|
{
|
||||||
|
playerAndSessionEntry = entry.getKey();
|
||||||
|
Map.Entry<Pattern, List<BlockVector3>> patternAndListEntry = entry.getValue();
|
||||||
|
Pattern pattern = patternAndListEntry.getKey();
|
||||||
|
List<BlockVector3> blockVector3List = new ArrayList<>();
|
||||||
|
blockVector3List.addAll(patternAndListEntry.getValue()); // Deep clone the block vector to avoid a change later in the code.
|
||||||
|
|
||||||
|
for (BlockVector3 blockVector3 : blockVector3List)
|
||||||
|
{
|
||||||
|
if (blockVector3 != null && !pattern.apply(blockVector3).getBlockType().getMaterial().isAir())
|
||||||
|
{
|
||||||
|
World world = server.getWorld(playerAndSessionEntry.getValue().getWorld().getName());
|
||||||
|
Location location = new Location(world, blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||||
|
BaseBlock block = pattern.apply(blockVector3);
|
||||||
|
Material material = Material.getMaterial(block.getBlockType().getId().replaceFirst("minecraft:", "").toUpperCase());
|
||||||
|
api.logPlacement(playerAndSessionEntry.getKey(), location, material, material.createBlockData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blocksPlaced.values().forEach(collection -> collection.getValue().clear());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0L, 40L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, BlockVector3 blockVector3)
|
||||||
|
{
|
||||||
|
// Cache the world used for the next iterations to come.
|
||||||
|
if (world == null || !world.getName().equals(editSession.getWorld().getName()))
|
||||||
|
{
|
||||||
|
world = server.getWorld(editSession.getWorld().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map.Entry<String, EditSession> playerAndSessionEntry = new AbstractMap.SimpleEntry(playerName, editSession);
|
||||||
|
Block block = world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
||||||
|
|
||||||
|
// Add the broken block to CoreProtect if it's not air.
|
||||||
|
if (!block.getType().isAir())
|
||||||
|
{
|
||||||
|
String blockData = block.getBlockData().getAsString();
|
||||||
|
blockData = new Gson().fromJson(new Gson().toJson(blockData), blockData.getClass()); // Overwrite original with deep clones.
|
||||||
|
blockVector3 = new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass()); // Overwrite original with deep clones.
|
||||||
|
blocksBroken.putIfAbsent(playerAndSessionEntry, new HashMap<>());
|
||||||
|
blocksBroken.get(playerAndSessionEntry).put(blockVector3, blockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the placed block to CoreProtect if it's not air.
|
||||||
|
if (!pattern.apply(blockVector3).getBlockType().getMaterial().isAir())
|
||||||
|
{
|
||||||
|
blocksPlaced.putIfAbsent(playerAndSessionEntry, new AbstractMap.SimpleEntry<>(pattern, new ArrayList<>()));
|
||||||
|
blocksPlaced.get(playerAndSessionEntry).getValue().add(new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBlockEdits(String playerName, EditSession editSession, Region region, Pattern pattern)
|
||||||
|
{
|
||||||
|
// Add the broken blocks to CoreProtect.
|
||||||
|
if (world == null || !world.getName().equals(editSession.getWorld().getName()))
|
||||||
|
{
|
||||||
|
world = server.getWorld(editSession.getWorld().getName());
|
||||||
|
}
|
||||||
|
List<Block> blocks = new ArrayList<>();
|
||||||
|
|
||||||
|
for (BlockVector3 blockVector3 : region)
|
||||||
|
{
|
||||||
|
blocks.add(world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()));
|
||||||
|
}
|
||||||
|
|
||||||
|
logBlockEdit(playerName, editSession, pattern, blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, List<Block> blocks)
|
||||||
|
{
|
||||||
|
Map.Entry<String, EditSession> playerAndSessionEntry = new AbstractMap.SimpleEntry(playerName, editSession);
|
||||||
|
|
||||||
|
server.getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||||
|
{
|
||||||
|
for (Block block : blocks)
|
||||||
|
{
|
||||||
|
BlockVector3 blockVector3 = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||||
|
|
||||||
|
// Add the broken block to CoreProtect if it's not air.
|
||||||
|
if (!block.getType().isAir())
|
||||||
|
{
|
||||||
|
api.logRemoval(playerAndSessionEntry.getKey(), block.getLocation(), block.getType(), block.getBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the placed block to CoreProtect if it's not air.
|
||||||
|
BaseBlock baseBlock = pattern.apply(blockVector3);
|
||||||
|
if (!baseBlock.getBlockType().getMaterial().isAir())
|
||||||
|
{
|
||||||
|
Material material = Material.getMaterial(baseBlock.getBlockType().getId().replaceFirst("minecraft:", "").toUpperCase());
|
||||||
|
api.logPlacement(playerAndSessionEntry.getKey(), block.getLocation(), material, material.createBlockData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0L);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
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 Boolean isDisguised(Player player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
if (libsDisguises != null)
|
||||||
|
{
|
||||||
|
return DisguiseAPI.isDisguised(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void undisguiseAll(boolean staff)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
if (libsDisguises == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (DisguiseAPI.isDisguised(player))
|
||||||
|
{
|
||||||
|
if (!staff && plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DisguiseAPI.undisguiseToAll(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisguisesEnabled(boolean state)
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
if (libsDisguises == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockedDisguises.disabled = !state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisguisesEnabled()
|
||||||
|
{
|
||||||
|
return !BlockedDisguises.disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
return libsDisguises != null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,177 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class WorldEditBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
//
|
||||||
|
private WorldEditPlugin worldeditPlugin = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public WorldEditPlugin getWorldEditPlugin()
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LocalSession session = getPlayerSession(player);
|
||||||
|
if (session != null)
|
||||||
|
{
|
||||||
|
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
||||||
|
if (bukkitPlayer != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
||||||
|
session.undo(session.getBlockBag(fuckyou), fuckyou);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void redo(Player player, int count)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LocalSession session = getPlayerSession(player);
|
||||||
|
if (session != null)
|
||||||
|
{
|
||||||
|
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
||||||
|
if (bukkitPlayer != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
||||||
|
session.redo(session.getBlockBag(fuckyou), fuckyou);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLimit(Player player, int limit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final LocalSession session = getPlayerSession(player);
|
||||||
|
if (session != null)
|
||||||
|
{
|
||||||
|
session.setBlockChangeLimit(limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return wep.getSession(player);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BukkitPlayer getBukkitPlayer(Player player)
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return wep.wrapPlayer(player);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,238 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.caging;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Skull;
|
||||||
|
|
||||||
|
public class CageData
|
||||||
|
{
|
||||||
|
|
||||||
|
private final FPlayer fPlayer;
|
||||||
|
//
|
||||||
|
private final List<BlockData> cageHistory = new ArrayList<>();
|
||||||
|
//
|
||||||
|
@Getter
|
||||||
|
private boolean caged = false;
|
||||||
|
@Getter
|
||||||
|
private Location location;
|
||||||
|
@Getter
|
||||||
|
private Material outerMaterial = Material.GLASS;
|
||||||
|
@Getter
|
||||||
|
private Material innerMaterial = Material.AIR;
|
||||||
|
@Getter
|
||||||
|
private static String input = null;
|
||||||
|
|
||||||
|
public CageData(FPlayer player)
|
||||||
|
{
|
||||||
|
this.fPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaged(boolean cage)
|
||||||
|
{
|
||||||
|
if (cage)
|
||||||
|
{
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caged = false;
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
this.input = null;
|
||||||
|
|
||||||
|
buildHistory(location, 2, fPlayer);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner, String input)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
this.input = input;
|
||||||
|
|
||||||
|
buildHistory(location, 2, fPlayer);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void regenerate()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!caged
|
||||||
|
|| location == null
|
||||||
|
|| outerMaterial == null
|
||||||
|
|| innerMaterial == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateHollowCube(location, 2, outerMaterial);
|
||||||
|
generateCube(location, 1, innerMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: EventHandlerize this?
|
||||||
|
public void playerJoin()
|
||||||
|
{
|
||||||
|
if (!isCaged())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerQuit()
|
||||||
|
{
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearHistory()
|
||||||
|
{
|
||||||
|
cageHistory.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertHistoryBlock(Location location, Material material)
|
||||||
|
{
|
||||||
|
cageHistory.add(new BlockData(location, material));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void regenerateHistory()
|
||||||
|
{
|
||||||
|
for (BlockData blockdata : this.cageHistory)
|
||||||
|
{
|
||||||
|
blockdata.location.getBlock().setType(blockdata.material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildHistory(Location location, int length, FPlayer playerdata)
|
||||||
|
{
|
||||||
|
final Block center = location.getBlock();
|
||||||
|
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||||
|
{
|
||||||
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
insertHistoryBlock(block.getLocation(), block.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Util methods
|
||||||
|
public static void generateCube(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++)
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
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 e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BlockData
|
||||||
|
{
|
||||||
|
|
||||||
|
public Material material;
|
||||||
|
public Location location;
|
||||||
|
|
||||||
|
private BlockData(Location location, Material material)
|
||||||
|
{
|
||||||
|
this.location = location;
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
116
src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
Normal file
116
src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.caging;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
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.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class Cager extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onBreakBlock(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (player == null
|
||||||
|
|| plugin.sl.isStaff(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = fPlayer.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (!cage.isCaged())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location playerLoc = player.getPlayer().getLocation().add(0, 1, 0);
|
||||||
|
Location cageLoc = cage.getLocation();
|
||||||
|
|
||||||
|
final boolean outOfCage;
|
||||||
|
if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
|
||||||
|
{
|
||||||
|
outOfCage = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outOfCage = playerLoc.distanceSquared(cageLoc) > (2.5D * 2.5D);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outOfCage)
|
||||||
|
{
|
||||||
|
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
|
||||||
|
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
||||||
|
cage.regenerate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
cage.playerQuit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
cage.playerJoin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
public class CommandFailException extends RuntimeException
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -92333791173123L;
|
||||||
|
|
||||||
|
public CommandFailException(String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,78 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
|
public class CommandLoader extends FreedomService
|
||||||
|
{
|
||||||
|
@Getter
|
||||||
|
private final List<FreedomCommand> commands;
|
||||||
|
|
||||||
|
public CommandLoader()
|
||||||
|
{
|
||||||
|
commands = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(FreedomCommand command)
|
||||||
|
{
|
||||||
|
commands.add(command);
|
||||||
|
command.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FreedomCommand getByName(String name)
|
||||||
|
{
|
||||||
|
for (FreedomCommand command : commands)
|
||||||
|
{
|
||||||
|
if (name.equals(command.getName()))
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlias(String alias)
|
||||||
|
{
|
||||||
|
for (FreedomCommand command : commands)
|
||||||
|
{
|
||||||
|
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadCommands()
|
||||||
|
{
|
||||||
|
Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
|
||||||
|
|
||||||
|
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@ -6,6 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface CommandParameters
|
public @interface CommandParameters
|
||||||
{
|
{
|
||||||
|
|
||||||
String description();
|
String description();
|
||||||
|
|
||||||
String usage();
|
String usage();
|
@ -0,0 +1,18 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface CommandPermissions
|
||||||
|
{
|
||||||
|
|
||||||
|
Rank level() default Rank.NON_OP;
|
||||||
|
|
||||||
|
SourceType source() default SourceType.BOTH;
|
||||||
|
|
||||||
|
boolean blockHostConsole() default false;
|
||||||
|
|
||||||
|
int cooldown() default 0;
|
||||||
|
}
|
@ -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.TRIAL_MOD);
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
for (Player targetPlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.staffAction(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.TRIAL_MOD, 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.staffAction(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;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,101 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
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.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Manage your AMP account", usage = "/<command> <create | resetpassword>")
|
||||||
|
public class Command_amp extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!plugin.amp.isEnabled())
|
||||||
|
{
|
||||||
|
msg("AMP integration is currently disabled.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData playerData = getData(playerSender);
|
||||||
|
|
||||||
|
if (playerData.getDiscordID() == null)
|
||||||
|
{
|
||||||
|
msg("You must have a linked discord account.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("create"))
|
||||||
|
{
|
||||||
|
msg("Creating your AMP account...", ChatColor.GREEN);
|
||||||
|
StaffMember staffMember = getAdmin(playerSender);
|
||||||
|
|
||||||
|
if (staffMember.getAmpUsername() != null)
|
||||||
|
{
|
||||||
|
msg("You already have an AMP account.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String username = sender.getName();
|
||||||
|
String password = FUtil.randomString(30);
|
||||||
|
|
||||||
|
staffMember.setAmpUsername(username);
|
||||||
|
plugin.sl.save(staffMember);
|
||||||
|
plugin.sl.updateTables();
|
||||||
|
|
||||||
|
plugin.amp.createAccount(username, password);
|
||||||
|
plugin.dc.sendAMPInfo(playerData, username, password);
|
||||||
|
msg("Successfully created your AMP account. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (args[0].equals("resetpassword"))
|
||||||
|
{
|
||||||
|
StaffMember staffMember = getAdmin(playerSender);
|
||||||
|
|
||||||
|
if (staffMember.getAmpUsername() == null)
|
||||||
|
{
|
||||||
|
msg("You do not have an AMP account.", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Resetting your password...", ChatColor.GREEN);
|
||||||
|
|
||||||
|
String username = staffMember.getAmpUsername();
|
||||||
|
String password = FUtil.randomString(30);
|
||||||
|
plugin.amp.setPassword(username,password);
|
||||||
|
plugin.dc.sendAMPInfo(playerData, username, password);
|
||||||
|
|
||||||
|
msg("Successfully reset your AMP account password. Check your DMs from " + plugin.dc.formatBotTag() + " on discord to get your credentials.", ChatColor.GREEN);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1 && plugin.sl.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return Arrays.asList("create", "resetpassword");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.MOD, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
||||||
|
public class Command_announce extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.an.announce(StringUtils.join(args, " "));
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
String list = "All possible attributes: ";
|
||||||
|
|
||||||
|
for (Attribute attribute : Attribute.values())
|
||||||
|
{
|
||||||
|
list += attribute.name() + ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove extra comma at the end of the list
|
||||||
|
list = list.substring(0, list.length() - 2);
|
||||||
|
|
||||||
|
msg(list);
|
||||||
|
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.TRIAL_MOD, 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.TRIAL_MOD, 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,178 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
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.TRIAL_MOD, 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);
|
||||||
|
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.staffAction(sender.getName(), String.format(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.TRIAL_MOD, 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.sl.isStaff(player) ? "the IP " + ip : "an IP");
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Shows all banned player names. Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||||
|
public class Command_banlist extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
|
{
|
||||||
|
checkRank(Rank.ADMIN);
|
||||||
|
|
||||||
|
FUtil.staffAction(sender.getName(), "Purging the ban list", true);
|
||||||
|
int amount = plugin.bm.purge();
|
||||||
|
msg("Purged " + amount + " player bans.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(plugin.bm.getAllBans().size() + " player bans ("
|
||||||
|
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
||||||
|
+ plugin.bm.getIpBans().size() + " IPs)");
|
||||||
|
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.TRIAL_MOD, 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.staffAction(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.Random;
|
||||||
|
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);
|
||||||
|
Random random = new Random();
|
||||||
|
return fishTypes.get(random.nextInt(fishTypes.size()));
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user